Error compass variance on sitl

Hello everyone,
I have the message “error compass variance” when using the sitl with gazebo.
Any idea ? :slight_smile:

Hi @sarah_gress, please don’t post the same question multiple times. This post has an almost identical question: SITL : my rover doing toilet bowl.

The most likely issue is that the model is not set up correctly and is not staying still long enough to initialise the gyros and magnetometer. This could be the SDF model joint parameters, the PWM scaling in the control blocks of the ArduPilot plugin, the AP params for the steering or throttle rate controllers or a number of other things.

Without the model and its AP parameters it’s not possible to diagnose what might be going wrong.

if I show you how my SDF file is and I share you my parameter file, you will be able to help me ?

Here it is :
the file.param :
rover_parameters.param (20.8 KB)

the sdf file :
sdf.txt (17.4 KB)

If you are able to help me , it would be perfect :slight_smile: Thank you !!

@sarah_gress, the rover model requires a number of mesh files, can you provide these. If you can zip the entire model folder with all required resources that would be ideal. In addition please provide the world file that is used to run the model so I can see which additional plugins you have loaded into the simulation.

Hi @sarah_gress, I’ve updated your model to use simple shapes in lieu of the meshes. Here a a few of the issues I’ve spotted that could explain why the rover is not behaving:

The pose for the IMU element specifies a rotation in degrees but is using a radian amount. The update rate should be much higher (1000 instead of 10).

Edit corrected - rotation should be about x axis

      <sensor name="imu_sensor" type="imu">
        <!-- <pose degrees="true">0 0 0 0 3.15149 0</pose> -->
        <pose degrees="true">0 0 0 180 0 0</pose>
        <always_on>1</always_on>
        <!-- <update_rate>10</update_rate> -->
        <update_rate>1000</update_rate>
        <visualize>true</visualize>
        <!-- <topic>imu</topic> -->
      </sensor>

The body collision seems to be oriented incorrectly. This should not have any impact on the motion, but may not be what you expect.

The wheel and body inertials are not aligned correctly. The wheel inertials need a rotation of (0 0 90) deg and the body inertial one of (90 0 0) deg. There may be some mistranslation from URDF to SDF?

Figure: collisions, visuals (wireframe), CoM and inertials prior to rotations.

Thank you for answer, I changed it and it helps me. But I forgot to change one parameter in Mission Planner and it was why I had a compass variance :slight_smile:

Thank you so much for your time !

There are a couple of other issues I’ve noted as I work through the model. The first few lines of the ArduPilot plugin xml should look like this:

    <plugin name="ArduPilotPlugin"
      filename="ArduPilotPlugin">
      <fdm_addr>127.0.0.1</fdm_addr>
      <fdm_port_in>9002</fdm_port_in>
      <connectionTimeoutMaxCount>5</connectionTimeoutMaxCount>
      <lock_step>1</lock_step>
      <have_32_channels>0</have_32_channels>
      <modelXYZToAirplaneXForwardZDown degrees="true">0 0 0 180 0 0</modelXYZToAirplaneXForwardZDown>
      <gazeboXYZToNED degrees="true">0 0 0 180 0 90</gazeboXYZToNED>
      <imuName>base_link::imu_sensor</imuName>

Note the change to the transform poses (in degrees and the extra rotation in the gazeboXYZToNED transform). I’m just checking the model runs properly when commanded by SITL, then I’ll post the updated SDF for the model and the commands to run. I think you should be able to use the standard set of parameters for the rover-skid frame and get reasonable behaviour.

Also note the correction to the IMU sensor rotation in the previous post - the 180 deg rotation must be about the x-axis.

Edit

The model is now working acceptably with rover defaults.

Save the world file as gress_rover.sdf

gress_rover.sdf.txt (3.5 KB)

Save the model files in a subfolder gress_rover as model.config and model.sdf
model.config.txt (225 Bytes)
model.sdf.txt (18.5 KB)

Ensure the model and world are included in the GZ_SIM_RESOURCE_PATH

Run Gazebo

gz sim -v4 -r gress_rover.sdf

Run SITL for skid steer

sim_vehicle.py -v Rover -f rover-skid --model json --console --map

Auto missions should work without any further parameter adjustments. Additional tuning will improve performance but the defaults are enough for basic usage.

Figure: updated collisions, visuals (wireframe), CoM and inertials.

Thank you!!!
I have another question regarding the maximum speed values, in what parameter is this adjusted? max linear and angular speed ??

For forward speed the parameters are: CRUISE_SPEED and WP_SPEED. In rover these both default to 3 m/s. See Tuning Speed and Throttle — Rover documentation for speed tuning and Tuning Navigation — Rover documentation for navigation.

The angular speed is controlled by ACRO_TURN_RATE and ATC_STR_RATE_MAX. See Tuning Turn Rate — Rover documentation for details.