No GPS noise in Gazebo Sim

Hi,

I would like to have no gps noise in my gazebo sim (not gazebo classic). I have been trying to follow the instructions in Gazebo Simulation | PX4 Guide (main)

I see the instructions on how to eliminate sensor noise for gazebo classic: Gazebo Classic Simulation | PX4 Guide (main)

However the in gazebo sim there is no

<gpsNoise>true</gpsNoise>

in the sdf file. From my understanding the .sdf files of gazebo classic and gazebo sim are not transferable.

I also have been following the instructions in post Eliminating all sensor noise and bias
However based on the instructions, I think this is also for gazebo classic based on the dates of the question.

What I have tried:

in the default.sdf I looked for anything ‘gps’ but could not find anything

I then commented out the following in DataValidator.cpp

	//} else if (_value_equal_count > _value_equal_count_threshold) {
	//	/* we got the exact same sensor value N times in a row */
	//	_error_mask |= ERROR_FLAG_STALE_DATA;
	//	ret = 0.0f;

I modified the following lines in SensorGpsSim.cpp

double latitude = gpos.lat; //+ math::degrees((double)generate_wgn() * 0.2 / CONSTANTS_RADIUS_OF_EARTH);
double longitude = gpos.lon; //+ math::degrees((double)generate_wgn() * 0.2 / CONSTANTS_RADIUS_OF_EARTH);
float altitude = gpos.alt; //+ (generate_wgn() * 0.5f);

I modified the following lines in SensorBaroSim.cpp to eliminate the noise and drift (I added and then subtracted the noise so I would not get the build error of a variable not used):

const float absolute_pressure_noisy = absolute_pressure + abs_pressure_noise + _baro_drift_pa - abs_pressure_noise - _baro_drift_pa ;

I could not find the “gazebo_imu_plugin and gazebo_barometer_plugin” in the default.sdf for gazebo sim.

I then did a

make clean
make distclean
make px4_sitl

However, all of this did not work :frowning: . I feel this should be something simple based on how simple the approach is in the gazebo classic instructions, you just have to eliminate one line in the world .sdf (true).

I am using ubuntu 22
PX4 v 1.14
Gazebo Garden 7.7

If someone could show how to eliminate sensor noise in gazebo sim, I would really appreciate it! Thanks!

Could it come from here?

I don’t think so :frowning: I commented out everything past the gpos.lat and gpos.long (and gpos.alt) and I still see the gps bouncing around when my drone is stationary on the ground.

Hang on, are you using classic or new Gazebo?

For classic it should be here:

I am using new Gazebo.

I am a big fan of how simple the change for no noise is for gazebo classic - I wish there was something for the new gazebo - and if there is does anyone know how it is done?

So gpssim is not what’s used for new Gazebo? We have to figure out which module runs and publishes gps.

I did some digging and from what I found, it looks like new gazebo uses NavSat:

According to SDFormat Specification, it looks like you can specify no noise. SDFormat Specification

which corresponds to what I see in gz-sensors/src/NavSatSensor.cc at 08ab86ba271007b0f54f4a26932e194ee1ad236d · gazebosim/gz-sensors · GitHub in lines 120-148.

However I tried adding this to the model.sdf:

<sensor name="navsat_sensor" type="navsat">
  <always_on>1</always_on>
  <update_rate>1</update_rate>
  <topic>navsat</topic>
  <navsat>
    <position_sensing>
      <horizontal>
        <noise>
          <type>gaussian</type>
          <mean>0.0</mean>
          <stddev>0.0</stddev>
        </noise>
      </horizontal>
      <vertical>
        <noise>
          <type>gaussian</type>
          <mean>0.0</mean>
          <stddev>0.0</stddev>
        </noise>
      </vertical>
    </position_sensing>
    <velocity_sensing>
      <horizontal>
        <noise>
          <type>gaussian</type>
          <mean>0.0</mean>
          <stddev>0.0</stddev>
        </noise>
      </horizontal>
      <vertical>
        <noise>
          <type>gaussian</type>
          <mean>0.0</mean>
          <stddev>0.0</stddev>
        </noise>
      </vertical>
    </velocity_sensing>
  </navsat>
</sensor>

But then when I tried to spawn the gazebo world with the model, the model did not load :frowning:

Am I going about this right way? The only other sensors I see in the model.sdf is the imu_sensor and the air_pressure_sensor. So I really don’t know how the model is getting its gps information to begin with because navsat is not already existing in the model.sdf