Conversation
There was a problem hiding this comment.
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.
src/robot/magnet.cpp
Outdated
| 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.
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]); |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…d slightly and causing PID oscillations
all we needed to do was measure the actual loop time instead of the expected loop time
…ion and velocity instead of expected
No description provided.