-
Notifications
You must be signed in to change notification settings - Fork 57
Add unit and frame enums to Magnetometer protobuf message #568
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
Open
bperseghetti
wants to merge
1
commit into
gazebosim:gz-msgs12
Choose a base branch
from
rudislabs:pr-wmm
base: gz-msgs12
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+36
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For all of our other sensors, I believe we require that measurements to be in SI units and ENU coordinates, correct? What is the benefit of diverging from that pattern here?
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.
Well, want to guess what units and coordinate frame our current magnetometer is publishing in?
Uh oh!
There was an error while loading. Please reload this page.
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.
Here's the SDF specification:
https://sdformat.org/spec/1.12/world/#world_magnetic_field
Now here's the test world values (roughly gauss units, but maybe it's some arbitrary environment):
https://github.com/gazebosim/gz-sim/blame/5049587241f63826dca7fd9a4b501d1ba91a0a73/test/worlds/magnetometer.sdf#L4
Here's what happens when you take that same world, don't define a magnetic field and instead just allow it to use spherical coordinates (in this case Tokyo):
This outputs:

Uh oh!
There was an error while loading. Please reload this page.
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.
Except the test world has the magnetometer with some rotations applied to it, so then remove those:
Granted this uses the old crude approximation method that as of today an "expired epoch".

Uh oh!
There was an error while loading. Please reload this page.
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.
The Official WMM for that exact same location in NED and nT gives:
x: 30086.0
y: -4179.3
z: 35641.7
or if you want it in Tesla (still the NED truth data):
x: 0.0000300860
y: -0.0000041793
z: 0.0000356417
Now for Gauss (still the NED truth data):
x: 0.300860
y: -0.041793
z: 0.356417
As you can see though, our unchanged current magnetometer is actually outputting NED Gauss...
And while I'm willing to allow for declaration of "Gauss" as the default since that's a meaningful unit for a magnetometer (compared to Tesla) the NED should not be the default and is definitely a MASSIVE BUG IMO:
https://xkcd.com/1172
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.
I think the easy obvious one here is that since this is protobuf, if you don't change from the default, the fields don't even show up. It breaks nobody. If for some reason you really need your output in NED or some other units, then by all means change it, but then that should show in the message.
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.
Hmm, what you write holds for people looking at gz topic. But that's a minority case I'd say. Tha majority case is code looking at the field. And code has to look at the field in any case. And then all subscribers need to implement the conversion routines because what if somebody decided to use nT. It seems that this is a quite high price for this little convenience.
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.
Not sure I follow, protobuf messages are for gazebo, not for ROS, those get converted anyhow for ROS, that conversion is trivial if we can say what frame and unit it is in. Have you ever used Ardupilot, PX4 or any POSIX rtos connected to gazebo before?
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.
Hmm, now I don't know if I follow... What do these systems have in common with the topic in this PR? Do they only support float32 or something like that? And if you're using SITL/HITL, you anyways need a bridge between Gazebo and the system, which usually runs on the full-fledged system... So your PX4 can happily send Gauss and the bridge can translate to Tesla.
Uh oh!
There was an error while loading. Please reload this page.
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.
I think the main thing is they take direct gz-transport messages and use gauss native internally. Anyone can convert anything anywhere... If they know what it is... I'm fine with throwing everyone under the bus and forcing it to ENU and Tesla if we are that scared/worried of enums in a single protobuf message...
I mean, people do realize that Gauss is the actual true unit of measure and that Tesla was a made up unit in 1960 to honor an "inventor" who didn't even believe in the electron let alone do ANYTHING for E&M theory or math that describes the magnetic field...
This is like a new measurement system coming out in 2060 for electromotive force and it gets the name "Musk" and happens to have units of 10^5 Volts.... Just so we can make sure we count all the zeros proceeding our lithium cells charge...