My rover has some trouble finding waypoints in Guided mode, and often makes several turns before getting within the threshold of arrival. Does anyone have any ideas on how I can get clean, straightforward waypoint missions?
The difference between the red (desired) and green (actual) turn rates show that a) There’s a lot of lag in the steering system and b) The maximum turn rate of the vehicle is around 30 degrees/sec, which is far less than the 120 degrees/sec you specified in ATC_STR_RAT_MAX.
Thanks for all the help Stephen, I’m definitely no pro when it comes to this sort of thing. However, when I run Guided and Auto missions in Mission Planner, the Rover roughly follows the correct path and waypoints, but when I implement an autonomous script I’m troubleshooting in Guided mode, it starts having the problems I listed before, and sometimes will just drive in a straight line forever. I’m using a raspberry pi as a companion computer on the rover, which I connect to Matlab on my laptop, which does all the computation for my specific project, via TCP/IP. Matlab sends next waypoint commands to the raspberry pi, and I’m trying to get the rover to correctly follow those commands. Any ideas? If you want, I can provide the rpi_movement script as well.
I re-did your example in SITL to be more basic for testing:
#!/usr/bin/env python3
import argparse, json, socket, time, glob, serial, threading
from datetime import datetime
from dronekit import connect, VehicleMode, LocationGlobalRelative
import math
# Utility: compute equirectangular distance
def get_distance_meters(a, b):
dlat = math.radians(b.lat - a.lat)
dlon = math.radians(b.lon - a.lon)
avg_lat = math.radians((a.lat + b.lat) / 2.0)
R = 6371000.0
x = dlon * math.cos(avg_lat)
y = dlat
return R * math.hypot(x, y)
# Setup Dronekit to connect on udp 127.0.0.1:14552
print(f"[Pi] Connecting to Pixhawk on")
vehicle = connect("tcp:127.0.0.1:5762", baud=57600, wait_ready=False)
print("[Pi] Waiting for armable, EKF & GPS fix…")
while not (vehicle.is_armable and vehicle.ekf_ok and vehicle.gps_0.fix_type >= 3):
print(f" armable={vehicle.is_armable}, ekf_ok={vehicle.ekf_ok}, gps_fix={vehicle.gps_0.fix_type}")
time.sleep(1)
print("[Pi] Setting mode GUIDED and arming…")
vehicle.mode = VehicleMode('GUIDED')
while vehicle.mode.name != 'GUIDED':
time.sleep(0.5)
vehicle.armed = True
while not vehicle.armed:
time.sleep(0.5)
print("[Pi] Vehicle is GUIDED and armed.")
tgt = None
#-35.35920299 149.16463151
nextLat = -35.35920299
nextLon = 149.16463151
tgt_alt = 100
tgt = LocationGlobalRelative(nextLat, nextLon, tgt_alt)
while True:
# send the goto command regardless of duplication
vehicle.simple_goto(tgt)
# 3) Arrival detection (non-blocking)
# 3) Arrival detection (non‑blocking)
if tgt:
dist = get_distance_meters(vehicle.location.global_relative_frame, tgt)
print(f"[Pi] Current dist to target: {dist:.2f} m")
if dist <= 0.5:
print("[Pi] reached waypoint")
break
#else:
# # STILL OUTSIDE THRESHOLD → keep re‐issuing the goto
# vehicle.simple_goto(tgt)
# print(f"[Pi] Reissuing simple_goto; remaining {dist:.2f} m")
time.sleep(0.1)
print("Exited")
I did get some odd behavior as the vehicle kept circling around and trying to reach the waypoint multiple times, similar to what I saw in your logs.
This was due to 2 reasons:
The threshold distance dist for detecting if it had reached a waypoint was too small (0.5m). Try 1m instead
Don’t spam ArduPilot with the simple_goto() at 10 Hz with the same location. You only need to call it once at the start and then wait for target distance to be met.
I increased the waypoint radius, removed the reissue command, and also sped up the rover’s speed from 0.5 m/s to 1.5 m/s, and that combo fixed my issue. Thank you for your advice!
Trying to recreate that chart - can you give me some tips? Where do I start - Data Logs, web tools? Thx in advance…hoping some “canned” charts make their way into the arduniverse…
That was from the binlog. You can use plot.ardupilot.org and plot the STER.TurnRate and STER.DesTurnRate fields to plot the actual vs desired turn rate: