Hi, I’ve been following this forum and using Ardurover on boats for a while now. Been a quiet observer but it seems like I finally have a reason to post! I believe I found a bug in the steering code for pivot turns, and have a fix for it that works in simulation and that I’ll probably test out on a boat over the weekend.
I was tuning one of my boats to follow this series of waypoints:
I had set PIVOT_TURN_ANGLE to 135, so I was expecting to not get pivot turns on 90 degree turns. Oddly, I was getting a pivot on turn 3. My other 90 degree turn (turn 2), I was not getting a pivot. I guess turn 7 is just shy of 135, so no pivot there either.
In this youtube video, you can see the boat executing a pivot turn at turn 3 at 25 seconds
I was able to reproduce this problem in simulation. It seems that if you have a turn that is less than PIVOT_TURN_ANGLE, but the following turn is greater than PIVOT_TURN_ANGLE, you might erroneously get a pivot turn. In the case of the path above, the sharp turn at waypoint 4 was causing me to also pivot at waypoint 3.
The reason this happens is, while passing waypoint 3, ardupilot calculates what the final speed at waypoint 4 should be. Part of that process involves calling the rover.use_pivot_steering function, which can set pivot_steering_active to true, causing the rover to pivot at the current waypoint while calculating the final speed for the following waypoint.
Here’s the specific line of code that’s causing the issue
One way to fix this is to make a separate function for figuring out if the rover should pivot at the next waypoint. Here’s my solution:
This solves the problem in simulation. Happy to follow up with plots and logs. Plan on testing it out on the same path above over the weekend.