-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
[WIP] MC auto mode - Use L1-like logic for lateral line tracking #11841
Conversation
How does this method perform when the acceptance radius is small? (e.g in a survey when cutting corners is not desired) What happens when the acceptance radius is set unreasonably low? (just thinking about corner cases) |
@mhkabir The behavior is as good as before with the default radius but I have to check with an unreasonably small radius. |
@mhkabir And one with 0.1m: An other one with 10.0m acceptance and turnaround waypoints: |
limited-jerk model. A L1 distance of length MPC_L1_DISTANCE is used to compute the position of a virtual point to track on a line defined by two waypoints. The generated vector (limited-jerk model to virtual point) is used to generate the forward speed using MPC_L1_SPEED_P and its direction drives the model to the line asymptotically. Increasing the acceptance radius of the mission items produces a smooth auto-continue behavior, similar to a fixed-wing flight.
Lovely, looks great! |
14bf03d
to
4290254
Compare
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.
Some suggestions to improve. I can do some tests to make sure they work.
@@ -157,12 +157,32 @@ void FlightTaskAutoLineSmoothVel::_prepareSetpoints() | |||
Vector2f u_prev_to_dest = Vector2f(pos_sp_xy - Vector2f(_prev_wp)).unit_or_zero(); | |||
Vector2f prev_to_pos(pos_traj - Vector2f(_prev_wp)); | |||
Vector2f closest_pt = Vector2f(_prev_wp) + u_prev_to_dest * (prev_to_pos * u_prev_to_dest); | |||
Vector2f closest_pt_to_dest = pos_sp_xy - closest_pt; |
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.
Comments about the meaning of these individual results would highly speed up code readability.
} | ||
|
||
// Recompute new L1 length limited by the maximum alongtrack error | ||
l1 = sqrtf(crosstrack_error * crosstrack_error + alongtrack_error * alongtrack_error); |
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.
Could you not simplify to
l1 = math::max(l1, u_prev_to_dest.length());
alongtrack_error = sqrtf(l1 * l1 - crosstrack_error * crosstrack_error);
I can test and commit that if you want.
|
||
// Position of the point on the line where L1 intersect the line between the two waypoints | ||
Vector2f pos_crossing_point = closest_pt + alongtrack_error * u_pos_traj_to_dest_xy; | ||
Vector2f u_traj_to_crossing_point = (pos_crossing_point - pos_traj) / l1; |
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.
We should use unit_or_zero()
like above because otherwise your trajectory state could spoil to NAN when the l1 distance gets zero while you're passing the waypoint.
I did some SITL testing and noticed some points which probably require refinement:
I think it's a very good idea but not mergeable yet. |
I tested the new logic on a real flight and I provide you an extra feedback. |
I wasn't able to get a nice behavior with this method, the tracking was too sloppy for a multicopter. |
Context
Auto mode uses a model-following tracking approach where the model is composed of 3 integrators with limited outputs (limited jerk, acceleration and velocity). This virtual vehicle is driven from one waypoint to the other using a control loop that generates desired velocities in the local frame. This controller is basically a "virtual pilot" that moves the sticks of the remote.
Current state
So far, a simple 2D proportional controller in the local frame was used to drive the vehicle and gives acceptable results for a first iteration.
L1 approach
A second approach I am trying now is to use the same approach as the fixedwing L1 controller to drive the virtual model.
Basically, a L1 distance of length
MPC_L1_DISTANCE
is used to compute the position of a virtual point to track on a line defined by two waypoints. The generated vector (limited-jerk model to virtual point) is used to generate the forward speed usingMPC_L1_SPEED_P
and its direction drives the model to the line asymptotically.A nice side effect of this controller is that increasing the acceptance radius of the mission items produces a smooth "auto-continue behavior", similar to a fixed-wing flight.
Test data / coverage
I tested that controller extensively in SITL:
A log: https://logs.px4.io/plot_app?log=fa390045-c598-4800-b393-ac22c2cc0812
An other log of the F450:
https://logs.px4.io/plot_app?log=23542ad5-d204-40a3-8787-6b9c31c5756e
Todo
Check if the we can simplify the equations.