Motor output ramp consistent for higher than minimum initial motor command #21690
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solved Problem
When integrating a product with PWM ESCs I found that the current PWM ramp is suboptimal:
Excpected: When the mixed motor command is exactly the minimum during the ramp time it ramps from the disarmed PWM value to the minimum PWM value.
Unexpected: When the mixed motor command is even just slightly higher than the minimum the ramp jumps up to a higher value than the disarmed PWM value and then ramps from there to the commanded throttle scaled between minimum PWM and maximum PWM. Additionally the first time a vehicle is armed after boot there is a 50 millisecond delay until the ramp actually starts.
![ramp before](https://private-user-images.githubusercontent.com/4668506/243710632-b6493c74-3447-4296-9678-94bd505715ce.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3MDI1MzEsIm5iZiI6MTcyNDcwMjIzMSwicGF0aCI6Ii80NjY4NTA2LzI0MzcxMDYzMi1iNjQ5M2M3NC0zNDQ3LTQyOTYtOTY3OC05NGJkNTA1NzE1Y2UucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjZUMTk1NzExWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDdiN2E2NDVkMTllMjQ2ZjZiNmE2OThiZmY1YThhZjNkNWI0ZTFiNjg3NTMxZmJmMTdmMWQ2OGNiNGUxNzM3OCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.bgBJpVXXsAgBfDBmI6dFJhSfTdygO96AziuwI3D4d5o)
Solution
As a result the ramp always starts immediately after arming from the disarmed PWM value and ends at the commanded throttle scaled between minimum PWM and maximum PWM. If the commanded throttle changes during the ramp then the scale and hence also end value of the ramp changes.
![ramp after](https://private-user-images.githubusercontent.com/4668506/243711052-9c0f2b96-4117-4db0-a1b7-dd8a1ad08372.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3MDI1MzEsIm5iZiI6MTcyNDcwMjIzMSwicGF0aCI6Ii80NjY4NTA2LzI0MzcxMTA1Mi05YzBmMmI5Ni00MTE3LTRkYjAtYTFiNy1kZDhhMWFkMDgzNzIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjZUMTk1NzExWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9M2M2YTNjNTg5N2ZmMzU3MzUyNzM5OGVlNGVjNjdlYWY4YmYwYTQ1NTViZmExYTY0MWQ1NWY4ZTI5M2E0MGM5MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.pmU0zQ5l_d2Fa-72Ojf_b6X-dRVgGJTLH1F21xDtj84)
Changelog Entry
For release notes:
Alternatives
I'm thinking about removing the output ramp on arming completely but this will come as a separate pr and requires more testing.
Test coverage
Context
Since #20031 the throttle even with no roll and pitch torques is not necessarily zero when arming but directly starts at the configured minimum throttle in multicopter modes that have manual throttle control. Also #21010 can add additional non-zero motor commands while arming.