Rover Can't Find Waypoints Easily- It Wanders Toward Each One

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?

Here’s the link to the bin log

Can you post a bin log showing this behaviour?

1 Like

From your log, you’ve disabled ARMING_CHECK. Set it back to 1 and work through any issues it detects.

Your steering tuning appears to be pretty bad:

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.

1 Like

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.

Ahh, ok. Are you able to provide the script(s) you’re using?

rpi_movement.txt (6.9 KB)
Here’s rpi_movement. In theory, it should just receive a waypoint and drive to it, while sending data back to Matlab.

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:

  1. The threshold distance dist for detecting if it had reached a waypoint was too small (0.5m). Try 1m instead
  2. 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.

Ok, thanks! I’ll give it a try first thing tomorrow.

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:

(I used MAVExplorer Using MAVExplorer for log analysis — Dev documentation, but the plot website is a little easier to use).

I’ll need to add some pre-canned graphs for the plot site, as there’s no pre-canned rover graphs yet :slight_smile:

1 Like

You and @Yuri_Rage - always teasing me with the good cush… Thanks - super useful. Already noticing some tuning errors on my rig!!

Spoke too soon - STER not showing. Wondering if I need to turn on some additional logging…hmmm

It is if you actually look in the .bin log Steering is logged by default.

Dave - apologies as I haven’t worked with many of the analytical tools - load the .bin into what? MP? One of the web tools? Struggling…cd

Ah OK, didn’t mean to sound like a jerk :slight_smile: @stephendade is using UAV Log Viewer and I am using Mission Planner

1 Like

Look at the LOG_BITMASK parameter and check the “Steering” is selected (Complete Parameter List — Rover documentation)

1 Like

Twas it. Just in time for some lightning in my area…sigh. Will test tomorrow, but the bitmask didn’t have STER selected. Have a great weekend…

And no jerk detected - always appreciate what ya’ll do - thanks for stepping in… (love the nod to the Space Family Robinson…)

Mowing like a beast now - thanks for all the support! Learning how/what to monitor/tune now - much more fun…

1 Like