1
$\begingroup$

Hope you are all doing well. I am working on a navigation project right now. According to a starting and goal location, I use Open Route Service to create a GPS Route. I have the coordinates (lateral and longitudinal) of the route (it has around 50 waypoints). Is there any way for me to add those coordinates to Mission Planner (Ardupilot) one by one? I mean I do not want an autonomous navigation. I just want to have the route showing up on mission planner. I tried creating a mission, but the vehicle (ArduRover) moves autonomously and I do not see the route on Mission Planner - by the way vehicle just moves forward, not following my route. For an example I will show you my code:

import openrouteservice
import folium
from openrouteservice.directions import directions
import json
import itertools
import pickle
import numpy as np
import matplotlib.pyplot as plt
from geopy.geocoders import Nominatim
from dronekit import connect, VehicleMode, LocationGlobalRelative, Command, LocationGlobal
from pymavlink import mavutil

print('Connecting...')
vehicle = connect('tcp:127.0.0.1:5762')
vehicle.mode = VehicleMode("AUTO")

coords = ((vehicle.location.global_relative_frame.lon, vehicle.location.global_relative_frame.lat),(28.87180, 41.00560))
client = openrouteservice.Client(key='hidden for safety purposes') # Specify your personal API key

geometry = client.directions(coords)['routes'][0]['geometry']
decoded = openrouteservice.convert.decode_polyline(geometry)
coordsArray = np.zeros((len(decoded["coordinates"]), 2))
for i in range(len(decoded["coordinates"])):
    coordsArray[i][0] = decoded["coordinates"][i][1]
    coordsArray[i][1] = decoded["coordinates"][i][0]

cmds = vehicle.commands
cmds.download()
cmds.wait_ready()
# Save the vehicle commands to a list
missionlist=[]
# Modify the mission as needed. For example, here we change the
# first waypoint into a MAV_CMD_NAV_TAKEOFF command.

for i in range(len(coordsArray)):
    cmd = Command(0,0,0, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT,
    mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 0, 0, 0, 0, 0, 0,coordsArray[i, 1], coordsArray[i, 0], 100)

    missionlist.append(cmd)
# Araca yükleniyor...
missionlist[0].command=mavutil.mavlink.MAV_CMD_NAV_TAKEOFF
cmds.clear()
for cmd in missionlist:
    cmds.add(cmd)
cmds.upload()

This script results with the vehicle (rover) just going forward, without following a route. Also I cannot see the pre-calculated route on Mission Planner. Can you help me with that? The only thing I need is to show the route on Mission Planner.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.