Servers by jDrones

Mission Planner example python scripts not working in 1.3.70

Hello all,

Quick system set info. I am testing all this on Sitl using Sim_Vehicle.py configured for ArduPlane, connected to Mission Planner as the GCS and X-Plane10 as the physics backend. I am primarily running and testing the TAKEOFF.py script provided found in Mission Planner/Scripts folder.

I am new too scripting with Mission Planner here, and I have been trying to use the included example scripts as a guide. However I am running into a few issues. The first problem is that any script that has to write way points to a vehicle crashes on the setWPCurrent() command. After Troubleshooting the problem, and finally finding the source code, 1.3.70 has included the requirement for sysid and compid to be included in the setWPCurrent command. This requirement has not been updated in any of the example scripts (they are all 5 years old or so). So the question here would be how do you determine the correct sysid and compid for a single vehicle sitl setup?

I have tried fixing this with (I hope) the correct sysid (1), and compid (1), and, viola, the script thinks it ran fine. However the next problem I run into is that the waypoints the script generates will load onto the Flight Data view, but does not show up as a list in the Flight Plan view. Furthermore I get the error: “mission upload timeout”, displaying in the Flight Data view hud section.

I don’t know enough about the code as to why the MAV.setWPack, MAV.setWP, and MAV.setWPCurrent commands no longer work properly. I would greatly appreciate some help with this. Also posting this to flag that the included example scripts are no longer working properly.

EDIT: After testing and cross checking, fixing setWPCurrent and removing MAV.setWP(MAV.getWP(0),0, …) fixes the communication problem and the crashing. This doesn’t explain why the MAV.getWP(0) doesn’t work with the code. Will continue Testing.

Further testing has ensued. Found the problem, but not sure why it is a problem. MAV.setWP() doesn’t like having MAV.getWP(0) as an input. If you create a variable that is allocated MAV.getWP(), it will work fine. It seems that after MAV.setWPTotal() command is issued, MAV.getWP() runs exceedingly slowly, which causes Set to malfunction, causing all the other set commands and packWP command to not work.

tldr:
Changes are:
MAV.setWPCurrent(YourSysid [default = 1], YourCompid [default =1], waypoint)
and create varname before MAV.setWPTotal
varname = MAV.getWP(0)
change first .setWP to
MAV.setWP(varname,0, MAVLink.MAV_FRAME.GLOBAL_RELATIVE_ALT)

Servers by jDrones