ROS and Gazebo SITL fail - v1.9.0 - mavros_posix_sitl.launch - Preflight Fail: Compass Uncalibrated

Hi all

I am new to this forum and its conventions, so please be gentle with Feedback. I am trying to get the Px4 firmware running in a SITL with Gazebo and ROS. I can run the
make px4_sitl gazebo
Command coming from here
and then get it to take-off with the command
commander takeoff
after which I receive:

INFO  [logger] Opened mission log file: ./mission_log/2019-06-19/01_27_02.ulg
INFO  [commander] Takeoff detected
WARN  [commander] Failsafe enabled: no datalink
INFO  [navigator] RTL HOME activated

Following that, I continue with the instructions on ROS and Gazebo
But when I try to run
roslaunch -v px4 mavros_posix_sitl.launch
and then try to input
commander takeoff
I get the output

[ INFO] [1560905617.622815264, 3.374000000]: VER: 1.1: Board hardware:      00000001
[ INFO] [1560905617.622902627, 3.374000000]: VER: 1.1: VID/PID:             0000:0000
[ INFO] [1560905617.623050839, 3.374000000]: VER: 1.1: UID:                 4954414c44494e4f
pxh> INFO  [ecl/EKF] EKF GPS checks passed (WGS-84 origin set)
INFO  [ecl/EKF] EKF commencing GPS fusion
[ INFO] [1560905631.643141892, 17.366000000]: WP: mission received
pxh> commander takeoff
WARN  [commander] Preflight Fail: Compass #0 uncalibrated
ERROR [commander] arming failed
Command 'commander' failed, returned 1.

and I cannot do anything

  • Ubuntu 18.04
  • ROS Melodic
  • MAVROS built from source with the script provided in the documentation for toolchain installation
  • git checkout v1.9.0
  • Environment Variables set:
  1. GAZEBO_PLUGIN_PATH=~/src/Firmware/build/px4_sitl_default/build_gazebo
  2. GAZEBO_MODEL_PATH=~/src/Firmware/Tools/sitl_gazebo/models
  3. LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:~/src/Firmware/build/px4_sitl_default/build_gazebo
  5. ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/src/Firmware/Tools/sitl_gazebo

Any help will be greatly appreciated. I already tried reinstalling the Firmware and Mavros (from source).
And please let me know of editing errors and how I can improve my posts here, that would be a great help. I look forward to some good support messages.



try rm ~/.ros/eeprom/parameters and then launch again mavros_posix_sitl


Hi, I have the exact same problem when running make px4_sitl gazebo. I also tried to use jmavsim but the simulator won’t launch. Also using Ubuntu 18.04.

Somehow, due to unknown circumstances, we tried copying the Firmware folder to a temporary directory, tried to run it (it obviously failed), copied the folder back and it worked (like black magic…)
Thank you @mrivi for your tip, I tried that too afterwards and on the next start it also worked, seemingly rewriting some parameters. I will keep that in my if I ever come across the same error again.

I had the same issue - and your solution worked :+1:

mrivi’s solution: rm ~/.ros/eeprom/parameters