Takeoff / Landing Button

Hi everyone,

I am trying to make a small custom version of mission planner. I would like to make a button that launch a takeoff at 5 meters if the vehicle is landed and that sets mode land if the vehicle’s flying. Here’s what I have done so far :

private void But_TOL_Click(object sender, EventArgs e)
if (But_TOL.Text == “Décoller”)
//on va essayer de décoller
Settings.Instance[“takeoff_alt”] = “5”;


                MainV2.comPort.doCommand((byte)MainV2.comPort.sysidcurrent, (byte)MainV2.comPort.compidcurrent,
                        MAVLink.MAV_CMD.TAKEOFF, 0, 0, 0, 0, 0, 0, 5);

                But_TOL.Text = "Attérir";
                //on va essayer d'attérir 

                But_TOL.Text = "Décoller";
            CustomMessageBox.Show(Strings.CommandFailed, Strings.ERROR);


So I am using the text on the button to decide if I should takeoff or land, at the beginning we have “Décoller” which means takeoff, and once in the air “Attérir” means land. But I would like to find a parameter that knows if we are flying or not. I know Lua has “get_likely_flying” but I didn’t find something similar in MAV.cs. I first thought cs.landed was what I was looking for but returns 0 all the time so I don’t know.

Thank you for your help and for all this community that helped me a lot

1 Like

I have true or false when I call MainV2.comPort.MAV.cs.landed. Did you call it properly ?

1 Like

landed is true when the system_status in heartbeat is MAV_STATE.STANDBY. Which is sent if the system is NOT in failsafe or not armed. So it can be false on the ground in a failsafe state.

The best way to tell if a vehicle is flying is check if it is armed (MainV2.comPort.MAV.cs.armed)


Yes indeed thanks !
@Eosbandi Oh okay ! But the system could be armed while in the ground with the rotors not spinning right ? I was thinking 2 buttons, one to arm/disarm and the other to takeoff/land. What do you think about using the current, turnrate or even TimeinAir ?

Dont you mix safety with arm ? If you arm a copter the rotors will start spinning, if you disarm it motors will stop.
This is the TimeInAir logic

                       // throttle is up, or groundspeed is > 3 m/s
                        if ((ch3percent > 12 || _groundspeed > 3.0) && armed)

Oh yes obviously… But I can’t put my button as a landing button if I am not flying and just armed, it has to be a takeoff untill it is has left the floor. I thought it would have been easier ! I will try different methods on sitl.

Thank you for your help and for explaining the way it works backstage.