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

Magnetometer system rotates with an incorrect angle #2536

Open
gmsanchez opened this issue Aug 22, 2024 · 0 comments
Open

Magnetometer system rotates with an incorrect angle #2536

gmsanchez opened this issue Aug 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@gmsanchez
Copy link

gmsanchez commented Aug 22, 2024

Environment

  • OS Version
Ubuntu 24.04 on a Docker container
  • Source or binary build?
Binary
---
echo $ROS_DISTRO 
jazzy
---
gz sim --version          
Gazebo Sim, version 8.5.0
Copyright (C) 2018 Open Source Robotics Foundation.
Released under the Apache 2.0 License.

Description

According to NOAA Magnetic Field Calculators the magnetic field intensity for my location is

  • North comp: 17,510.2 nT
  • East comp: -3,045.2 nT
  • Vertical Comp : -13,553.1 nT

magnetic_field_table

  • Expected behavior: After setting the spherical_coordinates to a latitude and longitude of my region, I expect the Magnetometer system to follow the rotations of the link it is attached to. For example, if I start a simulation with the magnetometer sensor initial pose of <pose>0 0 0 0 0 0</pose>, it is equivalent to say that the x axis is pointing to the North, the y axis is pointing to the East and the magnetic field message should read
magnetic_field:
  x: 0.17961739003658295
  y: -0.031671393662691116
  z: -0.12302243709564209

as it does, because the Magnetometer system uses a NED reference frame. If that sensor is rotated in Gazebo 90° anti-clockwise by modifying the pose to <pose>0 0 0 0 0 1.570796</pose>, now the x axis ends pointing West, y axis pointing to the North and the magnetic field should read

magnetic_field:
  x: 0.031671393662691116
  y: 0.17961739003658295
  z: -0.12302243709564209
  • Actual behavior: It seems that the Magnetometer system rotates in the opposite way, making the x, y and z readings not accurate. When I rotate the model 90° anti-clockwise in Gazebo, setting the pose to <pose>0 0 0 0 0 1.570796</pose>, the magnetic field measurements I get are
magnetic_field:
  x: -0.031671334964643014
  y: -0.1796174003866232
  z: -0.12302243709564209

Which correspond to a rotation of -90°. I think that the rotation angle in Gazebo reference frame should be transformed from ENU to NED before using it for the magnetic field calculation.

Steps to reproduce

  1. Create a ROS workspace
  2. Download the test code from magnetometer_demos into the src folder of the workspace
  3. Run ros2 launch magnetometer_demos magnetometer.launch.py
  4. Edit simple_mag.world on lines 92 to 95. Leave one of them without any comments
  5. Run colcon build to update the workspace
  6. Check the magnetometer topic
gz topic -e -t /magnetometer
ros2 topic echo /magnetometer

Please let me know if you need any modification to the provided code of if I am missing something.

@gmsanchez gmsanchez added the bug Something isn't working label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Inbox
Development

No branches or pull requests

1 participant