[Solved] Can not switch flight mode to OFFBOARD in gazebo ('mode change failed')

Hi, I’m fresh man in px4, I have been trying for a while to change flight mode to OFFBOARD, but I am really hitting some problems.

  • Date: Feb.10 2017
  • System: Ubuntu 16.04
  • Platform: ROS Kinetic
  • Firmware: The latest version cloning from github.com
  • Default SITL config: posix-configs/SITL/init/lpe
uorb start
param load
param set MAV_TYPE 2
param set SYS_AUTOSTART 4010
param set SYS_RESTART_TYPE 2
dataman start
param set BAT_N_CELLS 3
param set CAL_GYRO0_ID 2293768
param set CAL_ACC0_ID 1376264
param set CAL_ACC1_ID 1310728
param set CAL_MAG0_ID 196616
param set CAL_GYRO0_XOFF 0.01
param set CAL_ACC0_XOFF 0.01
param set CAL_ACC0_YOFF -0.01
param set CAL_ACC0_ZOFF 0.01
param set CAL_ACC0_XSCALE 1.01
param set CAL_ACC0_YSCALE 1.01
param set CAL_ACC0_ZSCALE 1.01
param set CAL_ACC1_XOFF 0.01
param set CAL_MAG0_XOFF 0.01
param set SENS_BOARD_ROT 0
param set SENS_BOARD_X_OFF 0.000001
param set COM_RC_IN_MODE 1
param set NAV_DLL_ACT 2
param set COM_DISARM_LAND 3
param set NAV_ACC_RAD 2.0
param set COM_OF_LOSS_T 5
param set COM_OBL_ACT 2
param set COM_OBL_RC_ACT 0
param set RTL_RETURN_ALT 30.0
param set RTL_DESCEND_ALT 5.0
param set RTL_LAND_DELAY 5
param set MIS_TAKEOFF_ALT 2.5
param set MC_ROLLRATE_P 0.2
param set MC_PITCHRATE_P 0.2
param set MC_PITCH_P 6
param set MC_ROLL_P 6
param set MPC_HOLD_MAX_Z 2.0
param set MPC_HOLD_XY_DZ 0.1
param set MPC_Z_VEL_P 0.6
param set MPC_Z_VEL_I 0.15
param set EKF2_GBIAS_INIT 0.01
param set EKF2_ANGERR_INIT 0.01
replay tryapplyparams
simulator start -s
rgbledsim start
tone_alarm start
gyrosim start
accelsim start
barosim start
adcsim start
gpssim start
pwm_out_sim mode_pwm
sleep 1
sensors start
commander start
land_detector start multicopter
navigator start
attitude_estimator_q start
local_position_estimator start
mc_pos_control start
mc_att_control start
mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_w.main.mix
mavlink start -u 14556 -r 4000000
mavlink start -u 14557 -r 4000000 -m onboard -o 14540
mavlink stream -r 50 -s POSITION_TARGET_LOCAL_NED -u 14556
mavlink stream -r 50 -s LOCAL_POSITION_NED -u 14556
mavlink stream -r 50 -s GLOBAL_POSITION_INT -u 14556
mavlink stream -r 50 -s ATTITUDE -u 14556
mavlink stream -r 50 -s ATTITUDE_QUATERNION -u 14556
mavlink stream -r 50 -s ATTITUDE_TARGET -u 14556
mavlink stream -r 50 -s SERVO_OUTPUT_RAW_0 -u 14556
mavlink stream -r 20 -s RC_CHANNELS -u 14556
mavlink stream -r 250 -s HIGHRES_IMU -u 14556
mavlink stream -r 10 -s OPTICAL_FLOW_RAD -u 14556
logger start -e -t
mavlink boot_complete
replay trystart

I started Firmware, gazebo and mavros in this way:

export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:/home/ubuntu/Downloads/PX4-Firmware
cd /home/ubuntu/Downloads/PX4-Firmware
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build_posix_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo
roslaunch px4 mavros_posix_sitl.launch

commander takeoff, commander land and commander mode manual work correctly except commander mode offboard
Every thing is OK but I can not switch flight mode to OFFBOARD.
Terminal like this:

pxh>commander takeoff
[ INFO] [1486737584.605283303, 2258.312000000]: FCU: ARMED by command line
INFO  [commander] Taking off
INFO  [tone_alarm] positive
INFO  [commander] home: 47.3977413, 8.5455936, 0.64
INFO  [tone_alarm] arming
[ WARN] [1486737584.607384737, 2258.314000000]: CMD: Unexpected command 22, result 0
[ INFO] [1486737584.607449103, 2258.314000000]: FCU: Taking off
INFO  [logger] Start file log
INFO  [logger] Opened log file: rootfs/fs/microsd/log/2017-02-10/14_39_44.ulg
[ INFO] [1486737584.609439885, 2258.316000000]: FCU: [logger] file: rootfs/fs/microsd/log/2017-02-10/1
[ INFO] [1486737584.617750672, 2258.324000000]: FCU: Using minimum takeoff altitude: 2.50 m
INFO  [commander] Takeoff detected
[ INFO] [1486737584.969155916, 2258.676000000]: FCU: Takeoff detected
INFO  [local_position_estimator] [lpe] land timeout 
[ INFO] [1486737585.951655413, 2259.656000000]: FCU: [lpe] land timeout

pxh> commander check
WARN  [commander] Preflight check: OK
WARN  [commander] Prearm check: OK

pxh> commander mode offboard
WARN  [commander] mode change failed

pxh> commander land
pxh> INFO  [commander] Landing at current position
INFO  [tone_alarm] positive
[ INFO] [1486737778.533327217, 2452.058000000]: FCU: Landing at current position
INFO  [commander] Landing detected
[ INFO] [1486737786.548513226, 2460.066000000]: FCU: Landing detected
INFO  [local_position_estimator] [lpe] land init
[ INFO] [1486737786.673254725, 2460.190000000]: FCU: [lpe] land init
INFO  [tone_alarm] neutral
[ INFO] [1486737789.557662216, 2463.072000000]: FCU: DISARMED by auto disarm on land
INFO  [logger] closed logfile, bytes written: 1040913

Also I can not set mode to OFFBOARD by mavros_msgs/SetMode.

Anyhelp would be highly appreciated.

Did you solve this? I am unable to set OFFBOARD mode

Why is this marked Solved?

1 Like