-
Notifications
You must be signed in to change notification settings - Fork 277
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
Magnetometer system publishes field strength in incorrect units #2312
Comments
World file mentioned above (since Github doesn't like me uploading .world files)
|
Looking at the PX4 PR from git blame, I'm convinced that the unit there was gauss (https://github.com/EliaTarasov/PX4-SITL_gazebo-classic/blob/67e1dda2ec339b50085f7793abdacdee2c05d53a/include/gazebo_mavlink_interface.h#L307). I'd be in favor of fixing this, but since it's been a year since #1907 was merged, we shouldn't break existing behavior in |
@gilborty Are you planning to create a PR for this? Is it okay if I assign this issue to you? |
Yes I should be able to get a PR up. To be clear, we would like a boolean parameter to enable the fix, right? And the units should be in tesla (as the message prescribes)? |
Yes to both. cc @ahcorde |
Environment
Description
Expected behavior
According to the
gz::msgs::Magnetometer
proto message, thefield_tesla
is reported in units of Tesla.However, consider the following minimal world file (see attached) using the Bay Area, California as the origin for the
spherical_coordinates
.Using this website, I would expect the local magnetic field to be something like this:
However, when I start up the simulation and echo the
/magnetometer
topicI get the following:
which is a few orders of magnitude off from what I was expecting.
I did some digging, and it looks like the tables that were used to estimate the field vector were added to gz-sim in this PR which actually use the field strength table from the old PX4 Sim.
However, I believe this line is incorrectly calculating the magnetic field in Tesla as I would expect the field to be measured in. Instead, it calculates it as a gauss and never converts it back to teslas.
I can demonstrate that this is the case using the previous message.
Steps to reproduce
field_tesla
is in Teslas)Unless I am mistaken, I think this is the case. My recommendation would be to fix the conversion in
systems/magnetometer/Magnetometer.cc
since we assume that the noise in the SDF file is measured in teslas. I think people would be okay with reporting it in tesla, not nT, even though that is what most sensors are reporting.As an aside, I'm actually surprised this seems like it was incorrect all the way back to the PX4 days. Was it originally reporting the field as Gauss? It isn't clear from the message signature
I can put up a PR if you'd all like and agree with the approach. Please let me know if I missed anything.
The text was updated successfully, but these errors were encountered: