-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/magnetometer class #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces magnetometer functionality by adding a new Magnet
class and integrating BMM350 magnetometer sensor support. The changes include implementing a magnetometer class with calibration support, updating control logic to use profiled PID controllers, and adding extensive BMM350 library support for sensor interfacing.
- Magnetometer class implementation with hard/soft iron calibration support
- Updated control system with new trapezoidal profiling and PID constants
- Comprehensive BMM350 sensor library integration with Python bindings
Reviewed Changes
Copilot reviewed 42 out of 49 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
src/utils/logging.cpp | Added float overload for serialLogln function |
src/robot/trapezoidalProfileNew.cpp | New trapezoidal motion profile implementation |
src/robot/magnet.cpp | Magnetometer class with BMM350 sensor interface and calibration |
src/robot/control.cpp | Updated control loop with profiled PID and magnetometer integration |
src/main.cpp | Added magnetometer header include |
pid_vis.py | Enhanced visualization with heading plots and polar displays |
lib/DFRobot_BMM350/ | Complete BMM350 sensor library with C++ and Python implementations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
for (int i = 0; i < 3; i++) { | ||
mag_data[i] = (soft_iron_matrix[i][0] * mag_data[0]) + (soft_iron_matrix[i][1] * mag_data[1]) + (soft_iron_matrix[i][2] * mag_data[2]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop overwrites mag_data
values during iteration, causing incorrect soft iron calibration. Store the original values before applying the transformation matrix.
for (int i = 0; i < 3; i++) { | |
mag_data[i] = (soft_iron_matrix[i][0] * mag_data[0]) + (soft_iron_matrix[i][1] * mag_data[1]) + (soft_iron_matrix[i][2] * mag_data[2]); | |
float orig_mag_data[3] = { mag_data[0], mag_data[1], mag_data[2] }; | |
for (int i = 0; i < 3; i++) { | |
mag_data[i] = (soft_iron_matrix[i][0] * orig_mag_data[0]) + (soft_iron_matrix[i][1] * orig_mag_data[1]) + (soft_iron_matrix[i][2] * orig_mag_data[2]); |
Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
…d slightly and causing PID oscillations
No description provided.