Implementing custom Flight Task


I am trying to implement my custom flight mode for PX4. I am following the steps described in this slides, trying to create the example Continuous Yaw:

I made the steps written in there, but it was not working. Then I tried to understand the other example, Orbit from the source code, and do the same thing for Continuous Yaw. I modified src/modules/mavlink/mavlink_messages.cpp and write the same class for Cont. Yaw as for Orbit, when I’m building the command, I get this error message:

In file included from …/…/src/lib/systemlib/mavlink_log.h:45:0,
from …/…/src/modules/mavlink/mavlink_main.h:72,
from …/…/src/modules/mavlink/mavlink_messages.cpp:42:
…/…/src/modules/uORB/uORB.h:89:25: error: ‘__orb_contyaw_status’ was not declared in this scope
#define ORB_ID(_name) &_orb##_name
…/…/src/modules/mavlink/mavlink_messages.cpp:5165:41: note: in expansion of macro ‘ORB_ID’
uORB::Subscription _contyaw_status_sub{ORB_ID(contyaw_status)};

I could not find how to make the code define __orb_contyaw_status as it is defined when it is built, as I understand. (__orb_orbit_status is not defined in the source code)

If I don’t write this class, I can build and run the code with jmavsim simulator. When the simulator starts, it gives warnings:

WARN [mavlink] stream CONTYAW_EXECUTION_STATUS not found
ERROR [mavlink] configure_streams_to_default() failed

However I can switch mode to continuous yaw. The mode is activating (running the activate() function once) but then not running the update() function.

Can anyone help me with it, or maybe point to a better source to create my own flight task?

Thanks in advance.

@MaEtUgR Can you advise here?

Some update on the issue:
I was able to get rid of the error, now it builds fine. However, as I switch to the task, the same problem as before happens:
activate() function runs once, but the drone does not its commands. Then update() function is not running at all. I can check the current flight mode and the drone is my custom flight mode.

So I have two issues here, flight mode not sending the commands (or drone is not receiving them) and flight mode does not switch to update after activating.


I finally was able to solve it, so my Flight Task is working now in jMavSim. However a more up-to-date documentation or tutorial would be useful I think.

The main thing that was missing was the


function that is not in the presentation I linked earlier, but PX4 needs it to

return true

in order to send the commands (even if it does not do anything else). At least this is what I can say from my experience.

1 Like

Is there any news on this topic? (@MaEtUgR I suppose is the person to tag here.) Mostly the documentation on how these Tasks work exactly and how switching between them is implemented in the code would be really helpful for further Flight Task implementations.

Hi @Safranek42 I’m trying to add a custom task following the steps of the slides you linked here (something is changed in the firmware but not so much) I’m able to compile but i do not know how to trigger MyTask. Can you help me?

Hi @Safranek42 I’m trying to add new module in px4 and sucessfully added new and when i run that module am getting updated data from arduino, but i want to integrate that module with gcs ui. Please help me.

Hi @shiva
I did not integrate any module the the graphical UI.
However in QGroundControl you can use Mavlink shell to see the status of your module (just type <your-module-name> status), or listen to any UORB message it is publishing (listener name-of-uorb-message>).

Hi @Safranek42
Thank you for your response. What you said in mavlink shell it is working but i need to integrate that in graphical UI. Can you help me to that one.

@shiva no, unfortunately I cannot, I don’t know how the graphical UI works.

Hi @Safranek42
Ok Thank you.