Pixhawk - Safe offboard

What is the recommended way to control a quadcopter using offboard mode?
I am looking for takeoff, travel for 5 meters in the X direction and land.
This is a nice example for simulation but it keeps turning the offboard mode on and that does not look very safe if we need to take manual controls back in case of an emergency.
This is a nice example:

but it does not include arming and switching to offboard, so it looks like is meant only for simulation.
It would be nice to share dos and don’ts for flying in offboard mode, controlled by a companion computer.

Maybe this could help. PX4 should have a pretty good estimation of local position if you’re planning to use the node outside of a simulation. Assigning an offboard switch to on of the RC transmitter’s switches is a suggestible failsafe since it enables switching back to the previous flight mode.

I would also recommend setting offboard parameters
to some functions that meet the needs of the user. I think these parameters are important in terms of improving the ability to take over in case of an emergency condition.


Thanks. We have good position control based on px4flow and lidar lite 3 (no gps). We do have the rc confgured to go from manul to pos control to offboard. I looked on the link you posted but I am concerned about the loop trying to turn on the offboard if it is off. I feel like we might loose control because of that. Did anybody actually used this code for a real flight?

Try this, I tried and works great:


But the thing is, where will you send the offboard messages from? A companion computer or RF link? If you will use RF link (from GCS), any timeout in the offboard will make the drone switch to the previous state. You should be careful, and also configure RC commander’s switch to flight modes and have the modes set for that switch positions. Otherwise it will be dangerous.

1 Like

@metinburak, did you try to switch to “manual” mode in mid flight using the code above? Maybe I am missing something but the loop (while(ros::ok())) will switch back to offboard, so we may end up switching back and forth between manual and offboard in an infinite loop unless the RC overwrites all other controls received from mavlink (mavros). Can somebody confirm that?
We are using a single board computer, on-board, connected thru USB. Commands are sent over mavros from the computer to pixhawk. One channel on the RC can switch between “manual”, “position control” and “offboard” modes. Another RC channel is configured as a kill switch (I hope we will never have to use this). I am so surprised that there is no documentation and clear guide lines on that and we have to guess and try on safety.

I commented out the mode changing lines, i takeoff manually or via qgc, then switch to offboard by the rc switch IN THE AIR. you should never switch to offboard in ground.

Ok, that makes sense! Why we should never switch offboard on the ground? Why is a bad idea to switch to offboard manually, wait for few seconds (for safety) and takeoff in offboard mode by sending a position (0,0,2) to reach a 2 meter altitude?

I’ve been playing with Offboard control also but not using mavros and what I found works best is to use an RC switch to get into alt-hold mode, then use software to start and run offboard control. Now if user doesn’t like what is happening a mode switch using RC will bump it out of offboard control (back to position-hold is the safest). Then the software driving offboard needs to monitor for this mode switch and STOP sending offboard messages as soon as this happens, this is what I do in AirSim and it seems to work well.

Oh, and this was just accepted Merged #7170, so with that you can set COM_OBJ_RC_ACT to Loiter, which can make for a nicer transition between different offboard sessions.

Hi !
I’m having trouble switching to offboard mode.

(Does the gps signal need to be active?)