Gazebo SITL ROS of PX4 switching to OFFBOARD mode

Dear all,

I have been trying for a while now to make the SITL to run with in offboard mode, but I am hitting a wall at the moment.
I get the simulator for the iris with mavros up and running, I can see the topics OK, etc. But when I try the arm script, it doesn’t do it… or at least not for more than a few secs. My setup is the following:

  • Ubuntu 14.04
  • Ros Indigo
  • Gazebo 6 (and plugins)
  • Firmware tag 1.4.4

I start the simulator as per the instrucctions in the page http://dev.px4.io/simulation-ros-interface.html
Which runs without problems and start gazebo correctly.

Then, in a separate console I do:
rosrun mavros mavsafety arm.

which also seems to run without issues, but the arming, as said, last for a very short period and I get the following output in the simulator terminal:

[ WARN] [1474369104.164757665, 128.400000000]: CMD: Unexpected command 400, result 0
[ INFO] [1474369104.169157462, 128.402000000]: FCU: [cmd] ARMED by arm/disarm component command
[ERROR] [1474369104.220744497, 128.456000000]: FCU: failsafe mode on
[ERROR] [1474369104.271934291, 128.508000000]: FCU: Already landed, not executing RTL
[ INFO] [1474369104.323090877, 128.560000000]: FCU: RTL: completed, landed
[ INFO] [1474369104.374278747, 128.612000000]: FCU: [blackbox] rootfs/fs/microsd/log/sess001
[ INFO] [1474369104.425449299, 128.662000000]: FCU: [blackbox] recording: log001.px4log
[ INFO] [1474369107.202231222, 131.430000000]: FCU: [cmd] DISARMED by auto disarm on land
[ERROR] [1474369107.253864723, 131.482000000]: FCU: failsafe mode off
[ INFO] [1474369108.236144712, 132.462000000]: FCU: [blackbox] stopped (0 drops)

I also tried running the offboard Ros example in the page http://dev.px4.io/ros-mavros-offboard.html and it seems to be stuck trying to set the mode to offboard which never happens.

*** UPDATE 21.09.2016 ***
I have kept investigating and found the following things:

  1. If I change the rc files in the Tools gazebo to set the COM_DISARM_LAND to zero:
    grep -r “COM_DISARM_LAND” *
    posix-configs/SITL/init/rcS_gazebo_iris:param set COM_DISARM_LAND 3
    posix-configs/SITL/init/rcS_gazebo_iris_opt_flow:param set COM_DISARM_LAND 3
    posix-configs/SITL/init/rcS_gazebo_solo:param set COM_DISARM_LAND 3
    posix-configs/SITL/init/rcS_gazebo_standard_vtol:param set COM_DISARM_LAND 5
    posix-configs/SITL/init/rcS_gazebo_typhoon_h480:param set COM_DISARM_LAND 3
    posix-configs/SITL/init/rcS_jmavsim_iris:param set COM_DISARM_LAND 3
    posix-configs/SITL/init/rcS_lpe_gazebo_iris:param set COM_DISARM_LAND 3
    posix-configs/SITL/init/rcS_lpe_gazebo_iris_opt_flow:param set COM_DISARM_LAND 3
    posix-configs/SITL/init/rcS_lpe_jmavsim_iris:param set COM_DISARM_LAND 3

Then I don’t have the problem that disarming happens automatically anymore.

  1. Still, the firmware does not allow me to switch to offboard mode when in the RTL state NONE. So, what I did is run the following command:

rosrun mavros mavcmd takeoffcurr x x x x

This helps with the initial state not set to NONE

  1. However, I still can’t set the mode to OFFBOARD either programmically with the service call or with the script mavsys. I had to use this command that I saw in google:

rosrun mavros mavsetp x x x x

SUMMARY: Therefore I have a sequence of several commands that I have to perform in order to get the SITL armed in offboard mode, but it works. The sequence is now:

  • change the files as above explaned
  • build the firmware for gazebo
  • rosrun mavros mavcmd takeoffcurr x x x x
  • rosrun mavros mavsafety arm
  • rosrun mavros mavsetp x x x x

So the questions I have:

  • is there a better, less twisted way to get the SITL armed and offboard mode?
  • what I am doing wrong that I can’t set the offboard mode programtically?

*** END UPDATE ***

Anyhelp would be highly appreciated.

Thanks,

Dr. Pablo Ghiglino

Hey still need help?

Hi,

Thanks for the reply. I have it figured out. The problem is that the compilation as explained in the guide is not exactly as it has to be done: it is not either the gazebo only or the ros one. You have to run both.

Thanks,

Pablo.