-
Notifications
You must be signed in to change notification settings - Fork 13.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
L1: remove check for tangent_vel direction for nicer loiter entry behavior #15847
Conversation
FYI @Antiheavy |
@bresch ping |
I'm also unsure about the reasoning behind the original logic, although I'm curious to find out. I do know that PX4 fixed wing often has poor loiter entry performance and I suspect the original "only turn one way" logic is the main culprit. For example, if a strong wind is coming from the wrong direction it is possible for a vehicle to get stuck in an infinite loop (pun applies) as it tries to turn only one way to enter the circle, but the wind accelerates the turn so much that the aircraft gets blown off course and has to loop around and try again, and again, and again. I suspect removing the only turn one way logic might help. |
This makes a lot of sense to me, trying to be too strict means the possible behavior gets boxed into a very narrow band of possibilities, which ends up not being optimal. Would it also make sense to increase the threshold where the loiter starts to ~2x loiter radius, so it enters the loiter with a nice arc of the same radius as the loiter? |
This may be nice for smaller loiters, but for large loiters (e.g. 1 km radius, I've seen it done) it might be less desired to come off the flight line to start heading to tangent so far away from the circle. |
I guess that additional distance would need to be calculated based on minimum turn radius then (speed + max bank angle), not the loiter radius. But it would clean up the loiter entrance a lot. |
Also valid point about optimizing the loiter entry point @jkflying , but let's first focus on removing these unnecessary flights through the center point - The entry looks also particularly bad in the screenshot above because the loiter radii are really small, it gets better when that's increased. Plus I've actually made some unfavorable changes to that logic, with default master it looks better. That's unrelated to the direction/fly-through-center issue though. |
The original concern was that of the vehicle was entering the loiter in reverse direction, it would turn the wrong way initially. It is interesting that this check is still used here https://github.com/ArduPilot/ardupilot/blob/02daa4c3ecbe6f94e92d6dfb14b6deda24f4c8f9/libraries/AP_L1_Control/AP_L1_Control.cpp#L415 Testing should include a reversal of the loiter direction, ie transitioning from a RH loiter to a LH loiter WP at the same location, or by changing the parameter that sets the direction. I would also evaluate the effectiveness of only running the check when _circle_mode = true rather than removing it. |
@@ -264,11 +264,6 @@ ECL_L1_Pos_Controller::navigate_loiter(const Vector2f &vector_A, const Vector2f | |||
/* calculate velocity on circle / along tangent */ | |||
float tangent_vel = xtrack_vel_center * loiter_direction; | |||
|
|||
/* prevent PD output from turning the wrong way */ | |||
if (tangent_vel < 0.0f) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative to removing this code block that should be evaluated is replacing this line with
if (tangent_vel < 0.0f && _circle_mode) {
So that the protection against getting trapped in a reverse direction loiter is preserved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something else I've realized though and is related: It always switches from
|
3c1672b
to
7409fe2
Compare
7409fe2
to
488af25
Compare
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
488af25
to
7681439
Compare
Based on discussion in slack.
Describe problem solved by this pull request
The current L1 logic often makes the vehicle first fly through center of loiter waypoint, instead of tracking the loiter circle as soon as it is close to it (or after already being inside the circle).
Describe your solution
Remove check for the tangential velocity to "prevent PD output from turning the wrong way". AFAIK this causes the vehicle to fly straight to the loiter center if the tangential velocity is only slightly in the wrong direction (e.g. because it's hitting the loiter circle at a 91° angle).
Describe possible alternatives
Instead of removing check completely, allow small tangential velocities in the wrong direction, e.g. tangent_vel < 1.0f.
Test data / coverage
Basic SITL testing.
Additional context
Before:
With this PR:
@priseborough can you shed some light why it is there? What are the conditions where it could turn the wrong way?