Greetings, experts!
I want to fly a plane with Ardupilot in a mission where waypoints are located very close to each other. In this mission following crosstrack causes the plane to miss a waypoint because it reaches waypoint before getting on a crosstrack. Is there any way to use LUA script to set target heading for the airplane straight on a next waypoint, not a crosstrack? This is a specific case so I don’t care about wind drift. If the distance between waypoints is long enough I can make a decision between following crosstrack or not, but I need to understand basics first.
Can you post an example mission and .bin log file? Disabling crosstrack is unlikely to help as Ardupilot advances to the next waypoint preemptively.
This may be a good application of spline waypoints or loiters.
Not an expert myself but maybe you could come up with some logic involving crosstrack error, dist to next wp, and bearing to next wp?
local distance = vehicle:get_wp_distance_m()
local bearing = vehicle:get_wp_bearing_deg()
local error = vehicle:get_wp_crosstrack_error_m()
Here is a quick screenshot of what is happening. Made it in a SITL with basic airplane model and 3 waypoint mission. Decreased WP_RADIUS because I need to pass straight through the waypoints. As you see, while the plane has enough turn radius to get to waypoint, it follows the crosstrack and misses by 10-15 meters.
I would recommend resetting the WP_RADIUS to what is suitable for the plane and adding lead in and lead out waypoints to where you need tight lateral tolerance. WP_RADIUS doesn’t control how close the plane will try to fly through the gate. Then play with NAVL1_* parameters so the plane more precisely follows the path. In SITL I had to increase NAVL1_DAMPING outside recommended values to get precise trajectory following.
If you have corners you can use LOITER_TURNS to achieve smooth turns with by using entry waypoint and tangent exit.
Example of lead in and lead out waypoints as well as Loiter turn.
I was thinking about this, but din’t find any function that sets a heading or bearing that the airplane will follow. Any ideas?
The idea was to do that in mission instead of scripting. Logic to do that in scripting would be fairly complex if you want to handle wind effects.
Like Lupus mentioned, handling it by editing waypoints might be easier.
For example, a waypoint smoothing script could work where you read your .waypoints file, add more points to potentially smooth out the shape and then spit a new .waypoints file back out.
This topic is kind of relatable because I had many missions flying huge fixed wings on very small routes… xD