Running a new onboard application in flight

Following the steps here, I have written an application (for real-time motion planning). I can run the app via the system console, and I seem to be able to subscribe and publish data.

What I need to do now is implement the app in such a way that it can be triggered in flight via my RC transmitter. Subscribing to the transmitter data isn’t a problem. I also know I can go into ROMFS/px4fmu_common/init.d and start the app on boot. What I am having trouble with is the restructuring of my app such that the main function in the app (the real-time motion planning algorithm) will wait for the proper manual command to execute. Basically, when I flip a certain switch on the RC transmitter, I want the algorithm to run - along with the state estimator (ekf2) and my custom version of a pos/att controller - until completion. The algorithm should be available to run again if the switched is flipped off and on again, but this is a detail…

I am trying to copy the framework of other modules, such as fw_att_control, but that’s a big leap from the end of the app writing tutorial, and there isn’t really a way to take baby steps and debug along the way.

Any insight into this problem, conceptually or practically, would be greatly appreciated. Thanks!

I would have the app run at start up and in the app’s main loop monitor the rc data to check for the switch you are interested in. If the switch is on then do your planning computations. I.e. you have a loop running at a certain rate (whatever rate you need your planner to run) and at the beginning of the loop check that the RC conditions are met.