Controlling Rover through APMrover2 MavProxy

I tried posting this in another board. It might have more luck here.

Hi!

So I’m working on a project with a rover that I have. My objective is to store multiple missions on a database. Basically having multiple separate lists of waypoints that I can treat as independent missions for the rover.

I have some experience working with Mavproxy and Ardupilot. Mostly with planes, but I haven’t really touched APMrover2 in the past. I’ve also done most of my waypoint uploads through Mission Planner. But I’m looking forward to doing this in python through my own code. In order to test this out I figured that the best thing to do would be to get SITL running with APMrover2 and crack open a python prompt on another terminal.

from pymavlink import mavutil
from pymavlink import mavwp

autopilot = mavutil.mavlink_connect(‘udpin:127.0.0.1’)
autopilot.wait_heartbeat()

autopilot connects properly to Mavproxy running with SITL. I am able to send basic commands that arm and disarm the rover as such

autopilot.mav.command_long_send( …numbers… )

However, what I want to do now is functionality needed to load waypoints into APMrover2 and execute the mission.

I have a feeling that I’m oversimplifying this. I’ve tried reading through pymavlink and Mission Planner’s code as well as APMrover’s code before coming here but I’m pretty stuck. If you can point me to code examples where such functionality is displayed (I know that there’s something I missed) I would greatly appreciate it.

I know that mission_items are sent using the MAV_CMD_NAV_WAYPOINT (16) command and I read up on this in the mavlink mission protocol documentation, but this doesn’t seem to give me the result I want. I would constantly get an APM upload terminated message in the mavlink console.

I would greatly appreciate anyone’s help in this matter. I’m using a Pixhawk 2.4.6 if anyone is interested about the hardware.