Flighttask land

I am trying to land in my own flight task. How can I switch to land mode or publish land message from flight task. Can you give basic code example please?

I’m going to tag @MaEtUgR. He can hopefully help here.

What problem exactly are you trying to solve? So how is your land different from an existing land mode? By knowing more about the context or your background, we can probably guide you better on where/how to add that.

I have followed this guide to create my own flight task: https://dev.px4.io/master/en/concept/flight_tasks.html
I have finished my task I can do what I want to do. There is just one step missing. I want to land the drone. But I do not want to do it with rc or qgc. The task should make the quad go in land mode.
I am using mpc_auto_mode parameter to start task, just like the guide.
I have tried to land with speed. But sometimes drone failed to detect land and I had to kill it.
I think there is 2 option for me.First I should change mode to land. Or I should publish land message.
This is the real problem for me. I dont know how to do that. I could not find any example for flight task in the web.
Sorry for the long answer I just want to make myself clear.
Thanks for the all help.

Ok, you can try to send a command with the Land mode as it is for instance done in the extract below.
It’s a bit hacky but it might work.

1 Like

Yes it is working.Drone goes into mode LAND.But not landing.And I figured out when I set MPC_AUTO_MODE back to default 1, it starts landing.I should not change parameter via QGC is there a way to change this parameter in flight task or should I use another parameter?
If so, which parameter is better to use in this application.Thanks for all the help.

I have tried to change parameter but it is not changing.
When I, _param_mpc_auto_mode.get() it gives me “2” which is my flight task case.
_param_mpc_auto_mode.set(_default_mpc_auto_mode); but this doesnt effect the parameter. @JulianOes could you help me one more step please?

Yeap!!
Same issue…
-created flight task with same link.
-got take off with qgc.
-then changed MPC_AUTO_MODE from 1 (default-JerkLimittedTrajectory) to my flightTask on qgc
-end of the task i tried to land with velocity setpoint but a little after touch down to ground (1-2 sec), tilted over. one side was still touching ground , not did take off, but other side is getting high and did a speedy loop.
-then i tried for landing part
“”""“void ObstacleAvoidance::_publishVehicleCmdDoLoiter(){
…
command.param3 = …_AUTO_LAND;
…publish…
}
“””""
but landing not detected while MPC_AUTO_MODE is my_flight_task.
-i pull the strings again and change MPC_AUTO_MODE to default manually on qgc. then suddenly landed.

-i want to do takeoff manually, assign mpc_auto_mode manually, then land auto.
-the problems are
->can’t make an auto_land while MPC_AUTO_MODE is my_flight_task.
->can’t change MPC_AUTO_MODE to default in my_flight_task.
Is there any solution ?

You can add the param set MPC_AUTO_MODE 1 in the settings/startup of your airframe.
E.g. for 4001 it would be here: https://github.com/PX4/Firmware/blob/master/ROMFS/px4fmu_common/init.d/airframes/4001_quad_x

But we are trigerring flighttask with mpc_auto_mode 2. It should change After flighttask. I applied your suggested land code in flighttask and I need to change parameter after that code. How can I switch to default flighttask? Or simply how can I change a parameter in flighttask?

Hello @iemre98 , Good luck on your code. Please let us know what you come up with.

and could you please upload your findings on GitHub, it will be very appreciated.

I couldnt find a way to change a parameter. I guess I have to look for an another method. If I will find any thing I will share of course

We have figured out @James thanks to @altug .You should use .commit() after you change the parameter.I hope it helps.