-
Notifications
You must be signed in to change notification settings - Fork 276
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: correct field calculation #2460
Magnetometer: correct field calculation #2460
Conversation
- The magnetic intensity table has units centi gauss not centi tesla - Add conversion to publish field in telsa. - Field is calculated in NED frame. - Convert to ENU frame for Gazebo world frame convention. Signed-off-by: Rhys Mainwaring <[email protected]>
There's a stalled PR #2336 that was fixing the units. There we decided to add a flag to enable this so as to not break behavior. Can we do the same here? |
Thanks for the link to the PR, missed that. The problem with the approach of continuing with the wrong units and orientation by default is that it creates issues downstream - particularly once the data is pushed into the ROS data space where the assumption is that it will be standards conforming. Perhaps we could do the following: Add params, which for garden and harmonic default to current behaviour: <use_units_gauss>true</use_units_gauss>
<use_earth_frame_ned>true</use_earth_frame_ned> and mark this behaviour as deprecated. Then switch to standard conventions as default if omitted (i.e. both false) in a future release. Updated in: e8f1628 |
Signed-off-by: Rhys Mainwaring <[email protected]>
Signed-off-by: Rhys Mainwaring <[email protected]>
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.
Adding explicit parameters for this sounds good to me. As far as changing the default, I see that https://www.ros.org/reps/rep-0103.html NED for outdoor systems. Shouldn't NED be the default then?
I just have one minor comment. Thanks!
The reasoning is that for Gazebo the world frame is ENU, so to be consistent with the orientation given by other sensors (say NavSat when spherical coordinates are provided) I think we need to use ENU when setting the mag field in the world frame. I'll need to review REP 103 again for the ROS msgs, if the convention is NED rather than ENU that should probably be handled in the ros_gz bridge. Update REP 103 suggests
If magnetic field data is regarded as geographic data the default frame (no suffix) is ENU. To use the NED frame (which is what aerial vehicles use in flight controllers) the ROS frame_id would add the |
Signed-off-by: Rhys Mainwaring <[email protected]>
Okay, thanks for the explanation. |
🦟 Bug fix
Summary
Correct the magnitude and direction of the magnetic field calculation in the Magnetometer sensor.
Details
Context
The issue was found during the development of external sensor support for ArduPilot using DDS to subscribe to ROS based sensor topics (in this case magnetic field strength published from Gazebo via the
ros_gz
bridge).ArduPilot SITL and Gazebo use similar calculations to simulate the earth's magnetic field at a given location (lat, lon). There was an inconsistency between the two calculations which can be attributed to a combination of incorrect units and frame convention.
The attached notebook reproduces both calculations in Python for comparison.
earth_mag_field.ipynb.zip
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.