Skip to content
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

AutoSmoothVel - Compute desired speed at target based on path curvature #12505

Merged
merged 11 commits into from
Aug 9, 2019

Conversation

bresch
Copy link
Member

@bresch bresch commented Jul 17, 2019

Describe problem solved by the proposed pull request
Currently, the drone does waypoint navigation while almost stopping at each waypoint. When the waypoints are aligned or that the heading change is small, we should not completely stop the drone but rather decelerate to make a nice turn and continue.

Describe your preferred solution
The solution implemented in that PR assumes that the drone will fly an arc between the two lines connecting to a waypoint and that we want to fly this arc with some desired centripetal acceleration. Given the acceptance radius r, the desired centripetal acceleration ac and the angle between the two lines α, we can easily compute the desired waypoint speed:

waypoint_circle

Also, to avoid entering too fast into the waypoint if the next waypoint is really close, the maximum speed between current and next is computed to constrain the waypoint speed.

You can interactively estimate the waypoint speed by clicking on the following link:
https://www.desmos.com/calculator/rvx6uybeo8

Tests
I tested quite extensively in SITL and on a F550.
Here an example of a log:
https://logs.px4.io/plot_app?log=2ab24653-a229-4e81-8295-ee7c58c8a373

Related
Fixes #11827

@bresch bresch requested a review from Stifael July 17, 2019 15:54
@bresch bresch self-assigned this Jul 17, 2019
@bresch bresch requested a review from MaEtUgR July 17, 2019 15:58
@bresch
Copy link
Member Author

bresch commented Jul 17, 2019

@PX4/testflights Can you test this PR in mission (survey and random mission) please? The drone should slow down but not stop if the turn is not too sharp.

@@ -177,6 +177,50 @@ void FlightTaskAutoLineSmoothVel::_checkEkfResetCounters()
}
}

float FlightTaskAutoLineSmoothVel::_getSpeedAtTarget()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move the two new methods into a UtilityClass/Function with more general names? then we can reuse it in other tasks as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it would be great to use the _getMaxSpeedFromDistance in the collision prevention as well, instead of using just the velocity controller P gain.

@Stifael
Copy link
Contributor

Stifael commented Jul 17, 2019

looks great. will try to test it tomorrow on H520

@hamishwillee
Copy link
Contributor

What if the angle is really acute?

@bresch
Copy link
Member Author

bresch commented Jul 18, 2019

@hamishwillee The circle with radius R gets smaller and when the angle is 0, the radius is 0 and the desired entrance speed is 0.

@bresch bresch force-pushed the dev-autocontinue branch from cc64cfb to 11e39c2 Compare July 18, 2019 08:05
@Stifael
Copy link
Contributor

Stifael commented Jul 18, 2019

I tested it on the H520 and seems to work well. I think it is a bit too conservative at corners and approaches the waypoints a bit too slow. Can that be changed via tuning?

During one particular survey, the vehicle also experienced an abrupt stop at one of the waypoints (see below), where the drone first accelerated before it stopped abruptly.
6_7_survey_point.
It also has sometimes difficulty to follow the line, but I think that is independent of this PR.

The flight log:
https://review.px4.io/plot_app?log=18956ebf-a86d-4c72-a786-1f97ca318130

In addition, to prevent the vehicle from passing a waypoint if the altitude has not been reached yet, I created this PR.

@jorge789
Copy link

jorge789 commented Jul 18, 2019

Tested on PixRacer V4:

Flight Card 2

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Takeoff in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint see landing behavior.

Note:
The flight was good the vehicle followed the points marked in the mission, @Stifael the same behavior as you mentioned. The vehicle slowed down but without stopping. We didn't notice any visual stoppage of the vehicle. Overall no issues were noted, good flight in general.

Logs:
https://review.px4.io/plot_app?log=d1f4a5f9-5c98-4ea2-9e48-12555472fbb4

https://review.px4.io/plot_app?log=8e5b032a-ec31-48e4-9ec6-9ae59b0ded49

https://review.px4.io/plot_app?log=293a137f-56b3-47d0-9a00-46760d04b4e2

@Junkim3DR
Copy link

Tested on Pixhawk 4 mini v5:

Flight Card 2

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint see landing behavior.

Note:
Vehicle flew as expected, slowed down instead of stoping at the waypoints.

Logs:

Tested on Pixhawk Pro v4:

Flight Card 2

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint see landing behavior.

Note:
Vehicle flew as expected, slowed down instead of stoping at the waypoints.

Logs:

Tested on NXP FMUK66 v3:

Flight Card 2

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint see landing behavior.

Note:
Vehicle flew as expected, slowed down instead of stoping at the waypoints.

Logs:

bresch and others added 4 commits July 30, 2019 13:31
…n previous-current and current-next waypoints

Also remove crosstrack P controller that produces overshoots when the
acceptance radius is large (crosstrack error is suddenly large at
waypoint switch).
…utation of the maximum waypoint entrance speed
@bresch bresch force-pushed the dev-autocontinue branch from 06a0bf9 to 4b43089 Compare July 30, 2019 13:17
@bresch
Copy link
Member Author

bresch commented Jul 30, 2019

@Stifael I moved the computation in static functions inside the VelocitySmoothing class that contains the jerk-limited optimizer. Is that enough or do you want them in an other file (header library? what would be the scope of the library? name? ...)

@Stifael
Copy link
Contributor

Stifael commented Jul 30, 2019

Is that enough or do you want them in an other file (header library? what would be the scope of the library? name? ...)

Do you think it makes sense to have computeMaxSpeedFromBrakingDistance and the other function in VelocitySmoothing?

I think if the function has a general implementation and is not necessarily FlightTasks related, then it could be put into the math-library similar to other functions (https://github.com/PX4/Firmware/blob/master/src/lib/mathlib/math/Functions.hpp#L48-L208). If it will anyway just be used by FlightTasks, then I would put it in a file such that it can easily be found. For instance, computeMaxSpeedFromBrakingDistance is kind of smooth-independent and can also be used in FlightTaskAutoLine.
However, I don't want to block you, so sure we can do that in another PR, given that I anyway want to revisit the structure.

@bresch bresch force-pushed the dev-autocontinue branch from 4b43089 to 15dbed2 Compare August 6, 2019 13:33
@bresch
Copy link
Member Author

bresch commented Aug 6, 2019

@Stifael I moved the functions into a TrajMath.hpp header library. It's true it's much cleaner and reusable. Can you review again?

* @return maximum speed
*/
template<typename T>
const T computeMaxSpeedFromBrakingDistance(T jerk, T accel, T braking_distance)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I'll try to get this into the collision prevention as well.

@bresch
Copy link
Member Author

bresch commented Aug 7, 2019

@PX4/testflights Can you test that again please?

@dannyfpv
Copy link

dannyfpv commented Aug 8, 2019

Tested on Pixhawk4 v5 f-450

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Takeoff in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint see landing behavior.

Pr log:
https://review.px4.io/plot_app?log=421760b0-a1cb-4e00-836d-ca085d17b475

https://review.px4.io/plot_app?log=d3b10670-b737-4657-9ea8-9484d79ecbdf

@bresch
Copy link
Member Author

bresch commented Aug 8, 2019

@dannyfpv Thanks a lot! Ready to be merged once we have a bit more space on the omnibus target :|

@Junkim3DR
Copy link

Tested on PixRacer v4:

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Takeoff in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint see landing behavior.

Note:
No issue noted, good flight in general.

Logs:

Tested on Pixhawk Pro v4Pro:

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Takeoff in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint see landing behavior.

Note:
No issue noted, good flight in general.

Logs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trajectory mission slow final waypoint approach
7 participants