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

AP_TECS: scale velRateMin correctly with airspeed #25411

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

coleschon
Copy link
Contributor

@coleschon coleschon commented Oct 31, 2023

This PR improves TECS deceleration rates by allowing to decrease speed more rapidly, the faster a plane is going.

Description

The current calculation for velRateMin scales incorrectly with airspeed, where currently, the max allowable velocity rate decreases as velocity increases. i.e. the faster an aircraft is going, the less-quickly it's able to slow down. This is particularly problematic on aircraft which operate over a wide range of speeds or which have a large difference between TECS_SINK_MIN and TECS_SINK_MAX, since they are empirically determined.

This change introduces discrete calculations for:

  • _STEdot_neg_max — Specific total energy rate at max speed (using TECS_SINK_MAX)
  • velRateNegCruise — Velocity rate at cruise speed (existing velocity rate calc at TRIM_ARSPD_CM)
  • velRateNegMax — Velocity rate at max speed (existing velocity rate calc at ARSPD_FBW_MAX)

The change then replaces the velRateMin calculation with a linear interpolation between the velocity rates at cruise and max speed, which is capped at those values outside the bounds of cruise and max speed. The deceleration margin is also decreased from 50% to 10% to improve deceleration rate performance.

Testing

This change was tested in ArduPilot SITL (Plane-4.3.3) with the following sequence:

  1. Takeoff the plane
  2. Send guided mode command to a distant point or for a large loiter
  3. Issue MAV_CMD_DO_CHANGE_SPEED commands to increase and decrease speed setpoint
  4. Issue MAV_CMD_DO_CHANGE_ALTITUDE commands to increase and decrease altitude setpoint

Before

Notice the blue at line at the top of graph (behind the green) representing TECS.sp, this is the plane's airspeed. Before this change, it required just over 6 minutes for the plane to decelerate from 75 m/s to 40 m/s. Extremely slow, and not by limitation of the aircraft — throttle is being modulated to maintain a gradual deceleration.

Current TECS example

After

Notice again the blue line representing TECS.sp. After this change, the plane requires only 40 seconds to decelerate from 75 m/s to 40 m/s.

Updated TECS example

Note: all TECS parameters are identical between runs.

Summary

Here we can see the rates produced from our capped linear interpolation between velocity rate at cruise and max speeds compared against what currently exists.

velocity vs airspeed

X 40 m/s = TRIM_ARSPD_CM (cruise airspeed)
X 80 m/s = ARSPD_FBW_MAX (max airspeed)

@coleschon coleschon marked this pull request as ready for review October 31, 2023 07:13
@coleschon coleschon force-pushed the coleschon/tecs-vel-rate branch 3 times, most recently from 0f5e800 to 35d9de4 Compare October 31, 2023 16:40
@coleschon
Copy link
Contributor Author

What is the repo's guidance for backporting improvements like this? My team is currently running Plane-4.3.3 — would we have to own a fork with the changes applied on top of this branch? I'd love to get this merged into master in either case.

@IamPete1
Copy link
Member

@coleschon You explain the testing that was done, but not issue that this fixes. What are the symptoms and how does the fix improve those?

RE backporting, we would get it into master first. I don't think this is a critical fix it would not be back-ported but it would be included in the next stable release, 4.5. If you need it on 4.3 you would have to maintain your own branch.

Copy link
Collaborator

@Hwurzburg Hwurzburg left a comment

Choose a reason for hiding this comment

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

squash and proper commit message needed

@tridge tridge added the Plane label Oct 31, 2023
@tridge
Copy link
Contributor

tridge commented Oct 31, 2023

@priseborough can you check this?

@coleschon coleschon force-pushed the coleschon/tecs-vel-rate branch from 482d5e8 to 3a9bf05 Compare November 1, 2023 03:41
@coleschon
Copy link
Contributor Author

@IamPete1 I agree that this should use the built-in linear_interpolate() function and am testing now to verify it behaves as expected. Also, I added a before/after example in Testing to illustrate the issues with the current deceleration rates. Please let me know if you think this is sufficient.

@Hwurzburg squashed commits and corrected message.

@coleschon coleschon force-pushed the coleschon/tecs-vel-rate branch 10 times, most recently from 018e865 to 8ff1746 Compare November 8, 2023 17:05
@coleschon coleschon force-pushed the coleschon/tecs-vel-rate branch 2 times, most recently from f65f838 to ae6d8d2 Compare November 9, 2023 07:53
@coleschon coleschon force-pushed the coleschon/tecs-vel-rate branch 5 times, most recently from 8945ece to 935284e Compare December 20, 2023 21:50
@coleschon coleschon force-pushed the coleschon/tecs-vel-rate branch 3 times, most recently from 7a046c1 to 1be5e35 Compare December 27, 2023 20:09
@coleschon coleschon force-pushed the coleschon/tecs-vel-rate branch 6 times, most recently from 7699bdb to bac37b1 Compare January 3, 2024 22:49
@IamPete1
Copy link
Member

IamPete1 commented Jan 4, 2024

@priseborough Can you take a look at this please, Thanks.

@coleschon coleschon force-pushed the coleschon/tecs-vel-rate branch 5 times, most recently from 032059d to f0bfda7 Compare January 6, 2024 02:43
@coleschon coleschon force-pushed the coleschon/tecs-vel-rate branch from f0bfda7 to 5d7e49f Compare January 6, 2024 22:00
@coleschon coleschon force-pushed the coleschon/tecs-vel-rate branch from 5d7e49f to d422abc Compare January 8, 2024 02:40
@tridge tridge merged commit af89822 into ArduPilot:master Jan 8, 2024
90 checks passed
@IamPete1
Copy link
Member

IamPete1 commented Jan 8, 2024

@coleschon Sorry we were so slow getting this in, Thanks for sticking with us.

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

Successfully merging this pull request may close these issues.

5 participants