Skip to content

Conversation

Kandles11
Copy link
Member

No description provided.

@Kandles11 Kandles11 requested a review from Copilot September 17, 2025 03:11
Copy link

@Copilot Copilot AI left a 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.

Comment on lines +39 to +40
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]);
Copy link
Preview

Copilot AI Sep 17, 2025

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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants