Based on what I've discovered so far in my search for an answer (most pertinently here & here), it appears the only commands that can be scripted in python for Mission Planner to execute are:
- Script.ChangeParam(name, value)
- Script.ChangeMode(name) # i.e., mode = RTL
- Script.WaitFor(string, timeout) # unsure what this command does
- Script.RC(channel, PWM, sendnow) # automates emulated RC transmissions?
However, MAVProxy is written & executed in python and can accomplish a whole lot more... Also, if I understand correctly, during execution of an established flight plan, Mission Planner automates sending the next command to the UAV based on the telemetry received... (i.e., Mission Planner sends the next command in the established flight plan after the telemetry received indicates the UAV has completed the current command, e.g., it doesn't tell the UAV to go to waypoint 2 until it has reached waypoint 1).
So, my question is:
Is there a way to script a flight plan in Python that executes commands based on TIME instead of telemetry???
[i.e., What are the python scripting commands/functions to command the UAV "go to waypoint 1, sleep(30), go to waypoint 2, sleep(30), LOITER, sleep(30), go to waypoint 4, toggle servo 8, RTL" without caring if the UAV actually ever made it to the waypoint before following the next command]
(based on the comment from Mission Planner's creator here, I would think this is possible, but I need a list of all possible commands to send with the corresponding Python syntax.)
Sir, can you share the scripts for throttle raise, stabilizing, roll, pitch, yaw, land and disarm?
you can contact me on my email id
i'm doing my project on pixhawk and i need help to land my arduplane automatically.
VENKAT RAVI KISHORE said:
I have made progress on my project learning from your script. Thanks.
My challenge now is to over fly the waypoint without going into loiter or to begin loiter on the far side of the loiter radius allowing at least an initial overflight of the waypoint.
Today I tested it and got the positive result. I mounted APM2.5 on a quad-copter and I connected it with Mission Planner via telemetry link. Before flying I developed codes for Arming motors, throttle raise, stabilizing, roll, pitch, yaw, land and disarm. I successfully run all those developed scripts of python and I completed preliminary tests. My next target is to test it for RTL, loiter, Guided modes.
Thanks for your great support.
Does anyone know if it is possible to upload a whole mission through python (multiple waypoints). I was trying to use the code bellow to add multiple waypoints and do a AUTO mission. However it does not work.
Relative = MAV.MAV_FRAME.GLOBAL_RELATIVE_ALT
item = MissionPlanner.Utilities.Locationwp() # creating waypoint
MissionPlanner.Utilities.Locationwp.lat.SetValue(item,lat) # sets latitude
MissionPlanner.Utilities.Locationwp.lng.SetValue(item,lng) # sets longitude
MissionPlanner.Utilities.Locationwp.alt.SetValue(item,alt) # sets altitude
MAV.setWP(item, 2, Relative, 0) #add waypoint
Script.ChangeMode("Auto") #Change mode to AUTO
Thanks for the help,
Hey, I'm trying to do the same thing. Have you gotten it to work?
After a few weeks working on an other project, I'm back to this project. But I've a problem, I can't run any python script anymore. As I try to run on of my script, which was working a few weeks ago, apm just freeze. Have you ever heard a problem like that ? I see only one modification between now and late january : I've updated apm.
Actually I've dowloaded an old version of Mission Planner and my scripts work with it, so I guess a changed in the last version has caused the freeze.
Nevermind... thanks to JakobSt, I developed a working time-based script.
Here's the script that worked for me in using ArduPlane (which should work for ArduCopter too):
Note: this is a TIME-based script... it will guide the UAV to the next waypoint after waiting a specified amount of time. One would have to replace the "time.sleep(10)" lines with "Script.WaitFor('ARMING MOTORS',30000)" [and replace 'ARMING MOTORS' with whatever notification Mission Planner usually provides upon arriving to a waypoint] to replicate the mission plan creation (i.e., go to next waypoint after arriving at previous waypoint).