Running a mission planner script on startup

Hi,

I am currently using the ADC port on the px4 to arm/disarm the system with a button that will live on our rover. I wrote a simple script that monitors the voltage of the “sonar sensor” that the button is, and disarms the system if the button is pressed. I would like to have this code running continuously either when mission planner starts up, or when connection between the px4 and the GCS is established. It is not ideal to have to go in and select/run the script manually.

There are some command line options to run scripts at startup. It will be /script thenAname.py

3 Likes

Thanks so much Michael! This is exactly what I was looking for. The only problem that I am running into is that when I run the script before establishing mavlink connection, cs.variable has a static value of whatever it was before the connection, and this value does not change in the script even if it does in the status tab. Any thoughts?

Thanks again

How are you referencing cs? Try MAV.cs

I was just using cs.???. So not using anything to reference cs, which may have contributed to my problem. However, I took the button in a different direction, editing the pixhawk firmware. Thanks for your input!

Agh i missed a MAV
should be
MAV.MAV.cs

the reason behind this is cs, is referenced to a non changing drone at script start time. this is so you can connect other drones, and it wont flick to another drone while the script is running.

MAV.MAV.cs should dynamically change based on the current target drone.

another options is
Ports[0].MAV.cs

Thanks for the great info!