Following a line in guided mode

I would like to be able to dynamically update a planned mission from a companion computer while it is executing. I initially tried applying partial updates to an auto mode plan, but this tended to cause issues (its been a while since I tested this, but I think I remember that it sometimes wouldn’t use the updated plan immediately or it would turn around and return to an earlier waypoint).

To avoid these issues, I started using guided mode and managing the waypoint sequencing on the companion computer. This works, but unlike auto mode, guided mode doesn’t appear to support any kind of cross track error control. Instead, it just points at the target point, which causes the vehicle to follow a curved path if it is being pushed off course by wind or current.

Is it possible to get guided mode to follow a line between two points (like auto mode), or is there some way to get auto mode to work reliably?

@BenWolsieffer,

Rover/Boat should be trying to drive a straight line even in Guided mode. If you have an onboard log I can have a look.

I made a some bad assumptions and left out some key information in my original question. I am using a slightly modified recent version of master (based on the commit immediately before S-curves were merged, since I don’t want to introduce another variable into my testing right now) and my vehicle is a sailboat.

After a lot more testing and looking through the code, I now believe the behavior I observed is the result of two factors. The first is how the navigation origin point is calculated in guided mode: if a new waypoint is submitted less than 100 ms after the previous waypoint is reached, the previous waypoint is used as the origin. Otherwise, the stopping point (calculated using the maximum acceleration) is used as the origin. Depending on when I sent the new waypoint and the current speed, the stopping point (and therefore the origin) would end up in different places and caused the boat to not follow the path I wanted. Since sailboats don’t have speed control, the stopping point is kind of meaningless, so I set ATC_ACCEL_MAX to zero to at least remove the dependency on the the boat speed. I then added a hack to make the navigation controller use the previous waypoint as the origin even if it has not been reached yet. As long as I send the new waypoint before the boat enters WP_RADIUS, it will try to exactly follow the line between the two waypoints.

The second problem is sailboat specific: when the bearing to the waypoint is within 10 degrees of the no-go zone, the boat simply tries to point at the waypoint without taking into account cross-track error. This was causing the curved paths I observed. For now, I have simply reduced the size of the no-go zone, since my planner already takes it into account when generating paths.

I still wish there were a way to explicitly tell ArduPilot the previous waypoint, the current waypoint and the next waypoint. This would basically be a less stateful version of auto mode. The vehicle would try to follow the line between the previous and current waypoints. With S-curves, the next waypoint becomes important as well to plan the turning behavior.