Cap the tilt thrust_command_from_acceleration asks for - #348
Open
naseem173 wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #293.
A position loop with a distant setpoint, or one that has wound up, can ask
thrust_command_from_accelerationfor a lateral acceleration large enough to tip the body past where its vertical thrust still holds it up, so it descends while accelerating sideways instead of climbing or holding height.This adds
thrust_command_from_acceleration_with_tilt_limit, which behaves the same asthrust_command_from_accelerationbut caps how far from level the attitude is allowed to lean (an angle in(0, pi/2)measured from +z). When the wanted acceleration would tip the body past that cap, the sideways part of the push is scaled down to fit while the vertical part is left exactly as it was, so the requested climb or descent rate is preserved. A newThrustCommand::tilt_bound()accessor reports whether the cap was hit, following the same pattern asRotorCommands::saturated()elsewhere in the crate.Changes:
ControlError::InvalidTiltLimitfor amax_tiltthat isn't strictly positive or reaches/exceeds a quarter turn.thrust_command_from_acceleration_with_tilt_limitincontrol/thrust_command.rs, with a doctest.ThrustCommand::tilt_bound()accessor.control/mod.rsandlib.rs.Verified locally:
cargo test -p multicalc,cargo test -p multicalc --features alloc,cargo test -p multicalc --all-features --doc,cargo fmt --all --check,cargo clippy -p multicalc --all-targets --features alloc -- -D warnings, andcargo doc -p multicalc --no-deps --all-featuresall pass.cargo test+cargo clippy --all-targetscleancargo fmtcargo test --doc)