Skip to content
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

AP_Compass: Add in BMM350 Driver #28079

Merged
merged 2 commits into from
Sep 21, 2024
Merged

Conversation

peterbarker
Copy link
Contributor

Replaceas #26987 as I could not force-push the branch

@cuav-chen2
Copy link
Contributor

I have just modified my pr base on your suggestions and still making a test... Any way, thank you for that!

@peterbarker
Copy link
Contributor Author

Has to wait until #28088 goes in

Fixed a problem with new vs NEW_NOTHROW

Comment on lines +458 to +462
if (temp > 0.0f) {
temp -= 25.49f;
} else if (temp < 0.0f) {
temp += 25.49f;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems quite suspect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @cuav-chen2 - do you see a problem with these lines?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh...my fault. We should compare with FLT_EPSILON here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is something more serious. Does the offset really change depending on the temperature sign? Right now if the input temperature value changes from e.g. 0.001 to -0.001 the reported temperature will change by 50°C (in the opposite direction too!)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you're right. I got this handle logic from the official routine of the sensor. I could do some testing on it if possible, but I'm not sure if I could control the temperature to this critical value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked the data sheet? This should definitely be in there.

Speaking of which, dropping a link to the datasheet in the comment at the top of the header is always a nice touch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The datasheet is particularly unhelpful, despite being 63 pages it doesn't have any description of the values and just refers to a broken code link...

I did do some searching and found the code and it does seem to be equivalent to what is proposed here, so I guess I can't argue any further.

Ardupilot does not log magnetometer temperature and Bosch's official API does not document the temperature units anyhow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'm marking this for merge - if it doesn't work we can fix it, nothing will crash because of this :-)

Comment on lines +482 to +484
// Store in field vector and convert uT to milligauss
Vector3f field { cr_ax_comp_x * 10.0f, cr_ax_comp_y * 10.0f, cr_ax_comp_z * 10.0f };
accumulate_sample(field, _compass_instance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Store in field vector and convert uT to milligauss
Vector3f field { cr_ax_comp_x * 10.0f, cr_ax_comp_y * 10.0f, cr_ax_comp_z * 10.0f };
accumulate_sample(field, _compass_instance);
// Store in field vector and convert uT to milligauss
Vector3f field { cr_ax_comp_x, cr_ax_comp_y, cr_ax_comp_z };
field *= 10.0f;
accumulate_sample(field, _compass_instance);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider suggesting this change but decided against in this instance. For no particular reason - perhaps just for re-testing reasons.

@peterbarker peterbarker merged commit 29176eb into ArduPilot:master Sep 21, 2024
95 checks passed
@peterbarker
Copy link
Contributor Author

@cuav-chen2 merged this one

@peterbarker peterbarker deleted the pr/bmm350 branch September 21, 2024 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants