-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Add Bosch BMM350 magnetometer #23362
Conversation
@jlaitine You made a BMM350 driver as well right for PX4? |
Yes, I also offered to upstream it back then, but there was no interest I guess at the time. Our version of the driver is here, if needed for reference: tiiuae#692 . I can check it out for sure, but not until some time next week |
I started by trying it out on my BMM350 board. The driver initializes and values change when turning the mag, but the values I am getting are suspicious: listener sensor_mag TOPIC: sensor_mag Earth's magnetic field is supposed to be < 1 gauss, it looks like there is some very large offset on all axis. I didn't debug what that might be, but is it possible that self test internal flux was left on on the axis? |
I added some minor comments, overall it looks quite nice to me! I wonder if it is reasonable to poll the sensor at ODR rate, or should the default ODR be lower than 200MHz? All the older mags are polled less frequently. I don't really have a strong opinion on this, but at least I don't have use for higher frequency mag data than 50Hz or so. Just maybe it is better to set the ODR & averaging in a way that the mag produces more averaged data less frequently? I don't think I have rights to bring review any further than commenting, so approvals need to come from maintainers... |
Thank you for the review, great notes! I have updated the code accordingly. As for the big offsets I had the OTP word LSB/MSB registers mixed up. Regarding the polling rate, I wasnt too sure too, I left it as is. If needed I can modify it to use the 50Hz polling rate as the older BMM150 magnetometer does. |
Maybe make ODR configurable using a CLI argument and default to 50Hz. |
Should I then remove the parameter settings for it? Or do I extend the functionality which would use the set parameters if no CLI arguments are passed and keep the default values for the parameters 50Hz? |
Nvm parameters are fine, boards can override using the |
Perfect, updated the module.yaml 😄 |
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.
LGTM!
I also made a quick smoke test on my desk. It worked out of the box and the outputs look good.
I don't have a possibility to make any comprehensive ( or flight ) testing atm. But after this is merged, we'll replace our own driver with this one, which will then take it to the air in TII/SSRC organization.
Suggest squashing the commits before merging though
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: https://discuss.px4.io/t/review-request-bosch-bmm350-driver/39830/1 |
I see that this one is still pending merging, @PetervdPerk-NXP is this waiting for something? |
We need an approval from someone with write access. |
@justas- Could you rebase on main and fix the CI errors?
|
Code looking good, could you remove the merge commit, we typically rebase pull requests instead of merging them. |
Rebased and changed the head to remove merge commit. |
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.
LGTM!
Breaking out the configuration to parameters is fine if you're actually going to use it, but sometimes less is more. For example the estimator isn't even going to do anything with magnetometer data faster than 100 Hz. On the extreme lower end it's just going to cause problems hitting timeouts and delayed data (EKF2_MAG_DELAY) that's wildly different than typical. A good setting would be whatever maximizes the actual data sampling (minimize potential for aliasing), while fitting comfortably on the bus at a reasonable rate (eg 100 kHz), doesn't add any additional filtering or latency in the device itself, and most importantly has actually been tested end-to-end. |
* Add Bosch BMM350 magnetometer * BMM350 replace info messages with debug messages * BMM350 update measurement interval * BMM350 fix offsets, update based on review * BMM350 Update default parameters to 50Hz * Update OTP Word LSB check * BMM350 fix styles and formatting * BMM350 update error checks
* Add Bosch BMM350 magnetometer * BMM350 replace info messages with debug messages * BMM350 update measurement interval * BMM350 fix offsets, update based on review * BMM350 Update default parameters to 50Hz * Update OTP Word LSB check * BMM350 fix styles and formatting * BMM350 update error checks
* Add Bosch BMM350 magnetometer * BMM350 replace info messages with debug messages * BMM350 update measurement interval * BMM350 fix offsets, update based on review * BMM350 Update default parameters to 50Hz * Update OTP Word LSB check * BMM350 fix styles and formatting * BMM350 update error checks
* Add Bosch BMM350 magnetometer * BMM350 replace info messages with debug messages * BMM350 update measurement interval * BMM350 fix offsets, update based on review * BMM350 Update default parameters to 50Hz * Update OTP Word LSB check * BMM350 fix styles and formatting * BMM350 update error checks
* Add Bosch BMM350 magnetometer * BMM350 replace info messages with debug messages * BMM350 update measurement interval * BMM350 fix offsets, update based on review * BMM350 Update default parameters to 50Hz * Update OTP Word LSB check * BMM350 fix styles and formatting * BMM350 update error checks
* Add Bosch BMM350 magnetometer * BMM350 replace info messages with debug messages * BMM350 update measurement interval * BMM350 fix offsets, update based on review * BMM350 Update default parameters to 50Hz * Update OTP Word LSB check * BMM350 fix styles and formatting * BMM350 update error checks
Solved Problem
Added Bosch BMM350 magnetometer released in 2023 with variable sampling, averaging rates. And another option to set the pad drive settings, to fix issues with data overshooting/undershooting that happen using long wires.
New parameters:
Context
https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmm350-ds001.pdf