Is it possible to switch MISSION mode to OFFBOARD mode while executing mission?

Hello,
I’m using ROS and I’d like to know is it possible to switch AUTO.MISSION mode to OFFBOARD mode while the drone is in mission mode and still executing mission? How to implement it?

1 Like

It is possible to switch to offboard, but by the definition of
offboard mode it will stop the execution of the mission

Could you explain why you would want to do that?

I am using v1.8.2 now and the parameter COM_OBS_AVOID can only be found in v1.9, which hasn’t been released yet.

Actually I git the master and tried to do the SITL simulation using make px4_sitl_defalut gazebo and roslaunch mavros px4.launch, but QGroundControl showed ARMING DENIED: Avoidance system not ready. and the vehile could not be armed. Did I miss something in the simulation?

And I thought maybe I can use v1.8.2 and switch the mode between AUTO.MISSION and OFFBOARD so that I can change the vehicle’s trajectory while mission is in execution.

I will go on with the COM_OBS_AVOID way to change vehicle’s trajectory during mission if I can successfully do the SITL simulation. Would you like to give me some instructions?

Thanks in advance.

@Kumaron All the instructions are provided in the px4/avoidance repo

I tried to build it but there was error: error: ‘struct mavlink::common::msg::ODOMETRY’ has no member named ‘velocity_covariance’. How can I solve this?

@Kumaron I assume that the error is coming from building mavros. Probably you have a mismatch between the mavros and mavlink releases. Please update both to the latest releases. You can follow the instructions here https://dev.px4.io/en/ros/mavros_installation.html#source-installation

1 Like

@sudo Please do not hijack the topic of this thread. Open a new topic if you have a off-topic question

1 Like

Thank you for your help! It was successfully built after updating mavros and mavlink to the latest. But when I tried to do the SITL simulation using commands like roslaunch local_planner local_planner_sitl_3cam.launch, everything was okay but it stuck in activating Gazebo. Is it caused by my laptop’s poor performance?

1 Like

@Kumaron what do you mean by stuck? The gazebo gui is disabled by default so when the simulation starts correctly you will see the vehicle and the world in rviz

1 Like

@mrivi Sorry I didn’t mention that I changed <arg name = "gui" default = "false"/> to <arg name = "gui" default = "true"/> in loca_planner_sitl_mavros.launch.

I set this argument to false and tried again. Error occurred: Error [parser.cc:689] Unable to find uri[model://vrc_driving_terrain].

Then I used ctrl + c to stop it and the terminal showed ERROR [px4] Startup script returned with return value: 2 and [sitl_0-6] escalating to SIGTERM.

1 Like

@mrivi
Logs:

kumaron@ubuntu:~$ roslaunch local_planner local_planner_sitl_3cam.launch
... logging to /home/kumaron/.ros/log/659853fa-5b81-11e9-a9cd-843a4b933d20/roslaunch-ubuntu-628.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ubuntu:39187/

SUMMARY
========

CLEAR PARAMETERS
 * /mavros/

PARAMETERS
 * /local_planner_node/goal_x_param: 17
 * /local_planner_node/goal_y_param: 15
 * /local_planner_node/goal_z_param: 3
 * /local_planner_node/pointcloud_topics: ['/camera_front/d...
 * /local_planner_node/world_name: /home/kumaron/cat...
 * /mavros/cmd/use_comp_id_system_control: False
 * /mavros/conn/heartbeat_rate: 1.0
 * /mavros/conn/system_time_rate: 1.0
 * /mavros/conn/timeout: 10.0
 * /mavros/conn/timesync_rate: 10.0
 * /mavros/distance_sensor/hrlv_ez4_pub/field_of_view: 0.0
 * /mavros/distance_sensor/hrlv_ez4_pub/frame_id: hrlv_ez4_sonar
 * /mavros/distance_sensor/hrlv_ez4_pub/id: 0
 * /mavros/distance_sensor/hrlv_ez4_pub/orientation: ROLL_180
 * /mavros/distance_sensor/hrlv_ez4_pub/send_tf: True
 * /mavros/distance_sensor/hrlv_ez4_pub/sensor_position/x: 0.0
 * /mavros/distance_sensor/hrlv_ez4_pub/sensor_position/y: 0.0
 * /mavros/distance_sensor/hrlv_ez4_pub/sensor_position/z: -0.1
 * /mavros/distance_sensor/laser_1_sub/id: 3
 * /mavros/distance_sensor/laser_1_sub/orientation: ROLL_180
 * /mavros/distance_sensor/laser_1_sub/subscriber: True
 * /mavros/distance_sensor/lidarlite_pub/field_of_view: 0.0
 * /mavros/distance_sensor/lidarlite_pub/frame_id: lidarlite_laser
 * /mavros/distance_sensor/lidarlite_pub/id: 1
 * /mavros/distance_sensor/lidarlite_pub/orientation: ROLL_180
 * /mavros/distance_sensor/lidarlite_pub/send_tf: True
 * /mavros/distance_sensor/lidarlite_pub/sensor_position/x: 0.0
 * /mavros/distance_sensor/lidarlite_pub/sensor_position/y: 0.0
 * /mavros/distance_sensor/lidarlite_pub/sensor_position/z: -0.1
 * /mavros/distance_sensor/sonar_1_sub/id: 2
 * /mavros/distance_sensor/sonar_1_sub/orientation: ROLL_180
 * /mavros/distance_sensor/sonar_1_sub/subscriber: True
 * /mavros/fcu_protocol: v2.0
 * /mavros/fcu_url: udp://:14540@loca...
 * /mavros/gcs_url: 
 * /mavros/global_position/frame_id: fcu
 * /mavros/global_position/rot_covariance: 99999.0
 * /mavros/global_position/tf/child_frame_id: fcu_utm
 * /mavros/global_position/tf/frame_id: local_origin
 * /mavros/global_position/tf/send: False
 * /mavros/image/frame_id: px4flow
 * /mavros/imu/angular_velocity_stdev: 0.000349065850399
 * /mavros/imu/frame_id: fcu
 * /mavros/imu/linear_acceleration_stdev: 0.0003
 * /mavros/imu/magnetic_stdev: 0.0
 * /mavros/imu/orientation_stdev: 1.0
 * /mavros/local_position/frame_id: local_origin
 * /mavros/local_position/tf/child_frame_id: fcu
 * /mavros/local_position/tf/frame_id: local_origin
 * /mavros/local_position/tf/send: True
 * /mavros/local_position/tf/send_fcu: False
 * /mavros/mission/pull_after_gcs: True
 * /mavros/mocap/use_pose: False
 * /mavros/mocap/use_tf: True
 * /mavros/plugin_blacklist: ['safety_area', '...
 * /mavros/plugin_whitelist: []
 * /mavros/px4flow/frame_id: px4flow
 * /mavros/px4flow/ranger_fov: 0.0
 * /mavros/px4flow/ranger_max_range: 5.0
 * /mavros/px4flow/ranger_min_range: 0.3
 * /mavros/safety_area/p1/x: 1.0
 * /mavros/safety_area/p1/y: 1.0
 * /mavros/safety_area/p1/z: 1.0
 * /mavros/safety_area/p2/x: -1.0
 * /mavros/safety_area/p2/y: -1.0
 * /mavros/safety_area/p2/z: -1.0
 * /mavros/setpoint_accel/send_force: False
 * /mavros/setpoint_attitude/reverse_throttle: False
 * /mavros/setpoint_attitude/tf/child_frame_id: attitude
 * /mavros/setpoint_attitude/tf/frame_id: local_origin
 * /mavros/setpoint_attitude/tf/listen: False
 * /mavros/setpoint_attitude/tf/rate_limit: 10.0
 * /mavros/setpoint_position/tf/child_frame_id: setpoint
 * /mavros/setpoint_position/tf/frame_id: local_origin
 * /mavros/setpoint_position/tf/listen: False
 * /mavros/setpoint_position/tf/rate_limit: 50.0
 * /mavros/startup_px4_usb_quirk: True
 * /mavros/sys/disable_diag: False
 * /mavros/sys/min_voltage: 10.0
 * /mavros/target_component_id: 1
 * /mavros/target_system_id: 1
 * /mavros/tdr_radio/low_rssi: 40
 * /mavros/time/time_ref_source: fcu
 * /mavros/time/timesync_avg_alpha: 0.6
 * /mavros/vibration/frame_id: vibration
 * /mavros/vision_pose/tf/child_frame_id: vision
 * /mavros/vision_pose/tf/frame_id: local_origin
 * /mavros/vision_pose/tf/listen: False
 * /mavros/vision_pose/tf/rate_limit: 10.0
 * /mavros/vision_speed/listen_twist: False
 * /rosdistro: kinetic
 * /rosversion: 1.12.14
 * /use_sim_time: True

NODES
  /
    gazebo (gazebo_ros/gzserver)
    local_planner_node (local_planner/local_planner_node)
    mavros (mavros/mavros_node)
    rqt_reconfigure (rqt_reconfigure/rqt_reconfigure)
    rviz (rviz/rviz)
    sitl_0 (px4/px4)
    spawn_model (gazebo_ros/spawn_model)
    tf_front_camera (tf/static_transform_publisher)
    tf_left_camera (tf/static_transform_publisher)
    tf_right_camera (tf/static_transform_publisher)

auto-starting new master
process[master]: started with pid [638]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 659853fa-5b81-11e9-a9cd-843a4b933d20
process[rosout-1]: started with pid [652]
started core service [/rosout]
process[tf_front_camera-2]: started with pid [679]
process[tf_right_camera-3]: started with pid [680]
process[tf_left_camera-4]: started with pid [690]
process[rqt_reconfigure-5]: started with pid [699]
process[sitl_0-6]: started with pid [740]
INFO  [px4] Creating symlink /home/kumaron/px4/master/Firmware/ROMFS/px4fmu_common -> /home/kumaron/.ros/etc
0 WARNING: setRealtimeSched failed (not run as root?)

______  __   __    ___ 
| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/

px4 starting.

INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
process[mavros-7]: started with pid [757]
process[gazebo-8]: started with pid [770]
process[spawn_model-9]: started with pid [779]
+ SYS_AUTOSTART: curr: 10016 -> new: 1015
process[local_planner_node-10]: started with pid [784]
process[rviz-11]: started with pid [800]
  MPC_XY_P: curr: 0.9500 -> new: 0.8000
  MPC_XY_VEL_P: curr: 0.0900 -> new: 0.2000
  MPC_XY_VEL_D: curr: 0.0100 -> new: 0.0160
  MPC_JERK_MIN: curr: 8.0000 -> new: 10.0000
  MPC_ACC_HOR_MAX: curr: 10.0000 -> new: 3.0000
+ RTL_DESCEND_ALT: curr: 10.0000 -> new: 5.0000
+ RTL_LAND_DELAY: curr: 0.0000 -> new: 5.0000
  SDLOG_MODE: curr: 0 -> new: 1
  SDLOG_PROFILE: curr: 3 -> new: 131
* RTL_DESCEND_ALT: curr: 5.0000 -> new: 10.0000
* RTL_LAND_DELAY: curr: 5.0000 -> new: 0.0000
  COM_OBS_AVOID: curr: 0 -> new: 1
[ INFO] [1554894694.694186724]: FCU URL: udp://:14540@localhost:14557
[ INFO] [1554894694.704437918]: udp0: Bind address: 0.0.0.0:14540
[ INFO] [1554894694.705595481]: udp0: Remote address: 127.0.0.1:14557
[ INFO] [1554894694.707381907]: GCS bridge disabled
INFO  [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes
INFO  [simulator] Waiting for simulator to connect on TCP port 4560
[ INFO] [1554894694.766106847]: Plugin 3dr_radio loaded
[ INFO] [1554894694.775915111]: rviz version 1.12.16
[ INFO] [1554894694.776217125]: compiled against Qt version 5.5.1
[ INFO] [1554894694.776311883]: compiled against OGRE version 1.9.0 (Ghadamon)
[ INFO] [1554894694.786430742]: Plugin 3dr_radio initialized
[ INFO] [1554894694.787926433]: Plugin actuator_control loaded
[ INFO] [1554894694.841410015]: Plugin actuator_control initialized
[ INFO] [1554894694.846713349]: Plugin adsb loaded
[ INFO] [1554894694.874875684]: Plugin adsb initialized
[ INFO] [1554894694.875265815]: Plugin altitude loaded
[ INFO] [1554894694.880130432]: Plugin altitude initialized
[ INFO] [1554894694.880495065]: Plugin cam_imu_sync loaded
[ INFO] [1554894694.882158646]: Plugin cam_imu_sync initialized
[ INFO] [1554894694.882595749]: Plugin command loaded
[ INFO] [1554894694.926178144]: Plugin command initialized
[ INFO] [1554894694.926632067]: Plugin debug_value loaded
[ INFO] [1554894694.979871543]: Plugin debug_value initialized
[ INFO] [1554894694.979940017]: Plugin distance_sensor blacklisted
[ INFO] [1554894694.980237157]: Plugin fake_gps loaded
[ INFO] [1554894695.080003507]: Plugin fake_gps initialized
[ INFO] [1554894695.080554787]: Plugin ftp loaded
[ INFO] [1554894695.131782279]: Plugin ftp initialized
[ INFO] [1554894695.132057833]: Plugin global_position loaded
[ INFO] [1554894695.250382625]: Plugin global_position initialized
[ INFO] [1554894695.250609706]: Plugin gps_rtk loaded
[ INFO] [1554894695.260343507]: Plugin gps_rtk initialized
[ INFO] [1554894695.260629443]: Plugin hil loaded
[ INFO] [1554894695.320630817]: Plugin hil initialized
[ INFO] [1554894695.320913795]: Plugin home_position loaded
SpawnModel script started
[ INFO] [1554894695.330823235]: Plugin home_position initialized
[ INFO] [1554894695.331197199]: Plugin imu loaded
libGL error: failed to create drawable
[ INFO] [1554894695.370808104]: Plugin imu initialized
[ INFO] [1554894695.371090794]: Plugin local_position loaded
[ INFO] [1554894695.373180142]: Stereo is NOT SUPPORTED
[ INFO] [1554894695.373407113]: OpenGl version: 3 (GLSL 1.3).
[ INFO] [1554894695.391249637]: Plugin local_position initialized
[ INFO] [1554894695.391623069]: Plugin log_transfer loaded
[ INFO] [1554894695.400634622]: Plugin log_transfer initialized
[ INFO] [1554894695.401068265]: Plugin manual_control loaded
[ INFO] [1554894695.415663370]: Plugin manual_control initialized
[ INFO] [1554894695.415972356]: Plugin mocap_pose_estimate loaded
[ INFO] [1554894695.437199609]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1554894695.439839619]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[ INFO] [1554894695.440689243]: Plugin mocap_pose_estimate initialized
[ INFO] [1554894695.440928742]: Plugin obstacle_distance loaded
[ INFO] [1554894695.454684967]: Plugin obstacle_distance initialized
[ INFO] [1554894695.454995346]: Plugin odom loaded
[ INFO] [1554894695.472219079]: Plugin odom initialized
[ INFO] [1554894695.472713311]: Plugin param loaded
[ INFO] [1554894695.481351704]: Plugin param initialized
[ INFO] [1554894695.481679363]: Plugin px4flow loaded
[ INFO] [1554894695.494114740]: Plugin px4flow initialized
[ INFO] [1554894695.494166495]: Plugin rangefinder blacklisted
[ INFO] [1554894695.494464101]: Plugin rc_io loaded
[ INFO] [1554894695.502356471]: Plugin rc_io initialized
[ INFO] [1554894695.502417897]: Plugin safety_area blacklisted
[ INFO] [1554894695.502684808]: Plugin setpoint_accel loaded
[INFO] [1554894695.514686, 0.000000]: Loading model XML from Gazebo Model Database
[INFO] [1554894695.515080, 0.000000]: Waiting for service /gazebo/spawn_sdf_model
[ INFO] [1554894695.517096823]: Plugin setpoint_accel initialized
[ INFO] [1554894695.517550018]: Plugin setpoint_attitude loaded
[ INFO] [1554894695.539484882]: Plugin setpoint_attitude initialized
[ INFO] [1554894695.539857590]: Plugin setpoint_position loaded
[ INFO] [1554894695.566879585]: Plugin setpoint_position initialized
[ INFO] [1554894695.567095106]: Plugin setpoint_raw loaded
[ INFO] [1554894695.579881103]: Plugin setpoint_raw initialized
[ INFO] [1554894695.580121508]: Plugin setpoint_velocity loaded
[ INFO] [1554894695.588274423]: Plugin setpoint_velocity initialized
[ INFO] [1554894695.588652148]: Plugin sys_status loaded
[ INFO] [1554894695.601534236]: Plugin sys_status initialized
[ INFO] [1554894695.601747269]: Plugin sys_time loaded
[ INFO] [1554894695.611972191]: TM: Timesync mode: MAVLINK
[ INFO] [1554894695.613984484]: Plugin sys_time initialized
[ INFO] [1554894695.614255353]: Plugin trajectory loaded
[ INFO] [1554894695.626104132]: Plugin trajectory initialized
[ INFO] [1554894695.626459471]: Plugin vfr_hud loaded
[ INFO] [1554894695.627851097]: Plugin vfr_hud initialized
[ INFO] [1554894695.627900545]: Plugin vibration blacklisted
[ INFO] [1554894695.628140249]: Plugin vision_pose_estimate loaded
[ INFO] [1554894695.650155976]: Plugin vision_pose_estimate initialized
[ INFO] [1554894695.650448368]: Plugin vision_speed_estimate loaded
[ INFO] [1554894695.658406148]: Plugin vision_speed_estimate initialized
[ INFO] [1554894695.658820755]: Plugin waypoint loaded
[ INFO] [1554894695.668895196]: Plugin waypoint initialized
[ INFO] [1554894695.669237366]: Plugin wind_estimation loaded
[ INFO] [1554894695.671453089]: Plugin wind_estimation initialized
[ INFO] [1554894695.671576533]: Autostarting mavlink via USB on PX4
[ INFO] [1554894695.671841006]: Built-in SIMD instructions: SSE, SSE2
[ INFO] [1554894695.671931934]: Built-in MAVLink package version: 2018.10.10
[ INFO] [1554894695.671985918]: Known MAVLink dialects: common ardupilotmega ASLUAV autoquad icarous matrixpilot paparazzi slugs standard uAvionix ualberta
[ INFO] [1554894695.672053373]: MAVROS started. MY ID 1.240, TARGET ID 1.1
Error [parser.cc:689] Unable to find uri[model://vrc_driving_terrain]
[rqt_reconfigure-5] process has finished cleanly
log file: /home/kumaron/.ros/log/659853fa-5b81-11e9-a9cd-843a4b933d20/rqt_reconfigure-5*.log
^C[rviz-11] killing on exit
[local_planner_node-10] killing on exit
[spawn_model-9] killing on exit
[gazebo-8] killing on exit
[mavros-7] killing on exit
[sitl_0-6] killing on exit
[tf_left_camera-4] killing on exit
[tf_right_camera-3] killing on exit
[tf_front_camera-2] killing on exit
ERROR [px4] Startup script returned with return value: 2
Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/gazebo_ros/spawn_model", line 313, in <module>
    sm.callSpawnService()
  File "/opt/ros/kinetic/lib/gazebo_ros/spawn_model", line 274, in callSpawnService
    initial_pose, self.reference_frame, self.gazebo_namespace)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/gazebo_ros/gazebo_interface.py", line 16, in spawn_sdf_model_client
    rospy.wait_for_service(gazebo_namespace+'/spawn_sdf_model')
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 159, in wait_for_service
    raise ROSInterruptException("rospy shutdown")
rospy.exceptions.ROSInterruptException: rospy shutdown
[sitl_0-6] escalating to SIGTERM
[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done

The output of echo ${GAZEBO_MODEL_PATH} is:
:/home/kumaron/px4/master/Firmware/Tools/sitl_gazebo/models:/home/kumaron/catkin_ws/src/avoidance/sim/models

1 Like

@Kumaron you need to download the gazebo model database http://gazebosim.org/tutorials?tut=model_structure&cat=build_robot

1 Like

@mrivi It worked. I really appreciate your help. Thank you very much!

1 Like