Value of batometer and magnetometer in SITL is wrong

Hi, I’m using Gazebo simulator for SITL. Recently I found that the value of the barometer and the magnetometer is totally wrong. I used rostopic echo to see the value.

Whether the IRIS model goes up or down, the value of /mavros/atm_presure is always zero like below.

---
header: 
  seq: 5549
  stamp: 
    secs: 1509173803
    nsecs: 913831600
  frame_id: base_link
fluid_pressure: 0.0
variance: 0.0
---
header: 
  seq: 5550
  stamp: 
    secs: 1509173803
    nsecs: 936330600
  frame_id: base_link
fluid_pressure: 0.0
variance: 0.0
---
header: 
  seq: 5551
  stamp: 
    secs: 1509173803
    nsecs: 953833720
  frame_id: base_link
fluid_pressure: 0.0
variance: 0.0
---
header: 
  seq: 5552
  stamp: 
    secs: 1509173803
    nsecs: 983835720
  frame_id: base_link
fluid_pressure: 0.0
variance: 0.0
---
header: 
  seq: 5553
  stamp: 
    secs: 1509173804
    nsecs:   3833720
  frame_id: base_link
fluid_pressure: 0.0
variance: 0.0
---
header: 
  seq: 5554
  stamp: 
    secs: 1509173804
    nsecs:  23832720
  frame_id: base_link
fluid_pressure: 0.0
variance: 0.0
---
header: 
  seq: 5555
  stamp: 
    secs: 1509173804
    nsecs:  56334952
  frame_id: base_link
fluid_pressure: 0.0
variance: 0.0
---
header: 
  seq: 5556
  stamp: 
    secs: 1509173804
    nsecs:  76333952
  frame_id: base_link
fluid_pressure: 0.0
variance: 0.0
---

Also, the value of the /mavros/mag is always very small like below.

---
header: 
  seq: 6772
  stamp: 
    secs: 1509173742
    nsecs: 156332720
  frame_id: base_link
magnetic_field: 
  x: -3.53058543988e-07
  y: 2.16512322426e-05
  z: 4.32430148125e-05
magnetic_field_covariance: [-1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---
header: 
  seq: 6773
  stamp: 
    secs: 1509173742
    nsecs: 166333720
  frame_id: base_link
magnetic_field: 
  x: -1.27962669358e-06
  y: 2.20302283764e-05
  z: 4.28217947483e-05
magnetic_field_covariance: [-1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---
header: 
  seq: 6774
  stamp: 
    secs: 1509173742
    nsecs: 176331720
  frame_id: base_link
magnetic_field: 
  x: -2.2318450734e-06
  y: 2.36665427685e-05
  z: 4.30926203728e-05
magnetic_field_covariance: [-1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---
header: 
  seq: 6775
  stamp: 
    secs: 1509173742
    nsecs: 183834720
  frame_id: base_link
magnetic_field: 
  x: -1.13077359274e-06
  y: 2.19618141651e-05
  z: 4.25885289907e-05
magnetic_field_covariance: [-1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---

Of course, the local position (/mavros/local_position/pose) is very good. Does posix_sitl_default not use barometer and magnetometer sensor modules?

1 Like

Do you have a corresponding flight log? We’d need to look here https://github.com/PX4/sitl_gazebo/blob/master/src/gazebo_mavlink_interface.cpp and then here https://github.com/PX4/Firmware/blob/master/src/modules/simulator/simulator_mavlink.cpp to see how the data gets into the system.
I think it’ll be easier to first compare a PX4 flight log (https://logs.px4.io/) with what you’re seeing on the ROS/Gazebo side.