-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Tailsitter: remove thrust spikes around entering/leaving transition modes #23033
Open
sfuhrer
wants to merge
9
commits into
main
Choose a base branch
from
pr-tailsitter-remove-throttle-spikes-main
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+47
−3
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
eb8360b
VTOL tailsitter: fix motor spike to 0 when finishing front transition
sfuhrer 34d1e42
VTOL Tailsitter: add front transition throttle blending
sfuhrer 05a41cb
VTOL Tailsitter: fix motor spikes to 0 when starting back transition
sfuhrer 66d4436
VTOL Tailsitter: set differential thrust to 0 in first 50ms of front …
sfuhrer fa56602
VTOL Tailsitter: add back transition throttle blending
sfuhrer d4d2173
tailsitter: treat back transition abort like a front transition
sfuhrer 2c00ddc
tailsitter: remove throttle spike also for quad-chute
sfuhrer 651ae9c
VTOL: fix tailsitter quadchute throttle spike suppression
sfuhrer cc380d3
Tailsitter: add coment about throttle sign
sfuhrer File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -67,6 +67,10 @@ void Tailsitter::update_vtol_state() | |||||
|
||||||
if (_vtol_vehicle_status->fixed_wing_system_failure) { | ||||||
// Failsafe event, switch to MC mode immediately | ||||||
if (_vtol_mode != vtol_mode::MC_MODE) { | ||||||
_transition_start_timestamp = hrt_absolute_time(); | ||||||
} | ||||||
|
||||||
_vtol_mode = vtol_mode::MC_MODE; | ||||||
|
||||||
} else if (!_attc->is_fixed_wing_requested()) { | ||||||
|
@@ -121,6 +125,7 @@ void Tailsitter::update_vtol_state() | |||||
case vtol_mode::TRANSITION_BACK: | ||||||
// failsafe into fixed wing mode | ||||||
_vtol_mode = vtol_mode::FW_MODE; | ||||||
_trans_finished_ts = hrt_absolute_time(); | ||||||
break; | ||||||
} | ||||||
} | ||||||
|
@@ -225,6 +230,11 @@ void Tailsitter::update_transition_state() | |||||
|
||||||
_v_att_sp->thrust_body[2] = _mc_virtual_att_sp->thrust_body[2]; | ||||||
|
||||||
if (_vtol_mode == vtol_mode::TRANSITION_BACK) { | ||||||
const float progress = math::constrain(_time_since_trans_start / B_TRANS_THRUST_BLENDING_DURATION, 0.f, 1.f); | ||||||
blendThrottleBeginningBackTransition(progress); | ||||||
} | ||||||
|
||||||
_v_att_sp->timestamp = hrt_absolute_time(); | ||||||
|
||||||
const Eulerf euler_sp(_q_trans_sp); | ||||||
|
@@ -238,7 +248,7 @@ void Tailsitter::update_transition_state() | |||||
void Tailsitter::waiting_on_tecs() | ||||||
{ | ||||||
// copy the last trust value from the front transition | ||||||
_v_att_sp->thrust_body[0] = _thrust_transition; | ||||||
_v_att_sp->thrust_body[0] = -_last_thr_in_mc; | ||||||
} | ||||||
|
||||||
void Tailsitter::update_fw_state() | ||||||
|
@@ -294,12 +304,27 @@ void Tailsitter::fill_actuator_outputs() | |||||
_torque_setpoint_0->xyz[2] = _vehicle_torque_setpoint_virtual_fw->xyz[2] * _param_vt_fw_difthr_s_r.get(); | ||||||
} | ||||||
|
||||||
// for the short period after switching to FW where there is no thrust published yet from the FW controller, | ||||||
// keep publishing the last MC thrust to keep the motors running | ||||||
if (hrt_elapsed_time(&_trans_finished_ts) < 50_ms) { | ||||||
_thrust_setpoint_0->xyz[2] = _last_thr_in_mc; | ||||||
_torque_setpoint_0->xyz[0] = 0.f; | ||||||
_torque_setpoint_0->xyz[1] = 0.f; | ||||||
_torque_setpoint_0->xyz[2] = 0.f; | ||||||
} | ||||||
|
||||||
} else { | ||||||
_thrust_setpoint_0->xyz[2] = _vehicle_thrust_setpoint_virtual_mc->xyz[2]; | ||||||
|
||||||
// for the short period after starting the backtransition where there is no thrust published yet from the MC controller, | ||||||
// keep publishing the last FW thrust to keep the motors running | ||||||
if (_vtol_mode != vtol_mode::TRANSITION_FRONT_P1 && hrt_elapsed_time(&_transition_start_timestamp) < 50_ms) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I did that on purpose, to also catch the quad-chute case (where the state goes directly from FW to MC, skipping transition). |
||||||
_thrust_setpoint_0->xyz[2] = -_last_thr_in_fw_mode; | ||||||
} | ||||||
|
||||||
_torque_setpoint_0->xyz[0] = _vehicle_torque_setpoint_virtual_mc->xyz[0]; | ||||||
_torque_setpoint_0->xyz[1] = _vehicle_torque_setpoint_virtual_mc->xyz[1]; | ||||||
_torque_setpoint_0->xyz[2] = _vehicle_torque_setpoint_virtual_mc->xyz[2]; | ||||||
|
||||||
_thrust_setpoint_0->xyz[2] = _vehicle_thrust_setpoint_virtual_mc->xyz[2]; | ||||||
} | ||||||
|
||||||
// Control surfaces | ||||||
|
@@ -330,3 +355,14 @@ bool Tailsitter::isFrontTransitionCompletedBase() | |||||
|
||||||
return transition_to_fw; | ||||||
} | ||||||
|
||||||
void Tailsitter::blendThrottleAfterFrontTransition(float scale) | ||||||
{ | ||||||
// note: MC throttle is negative (as in negative z), while FW throttle is positive (positive x) | ||||||
_v_att_sp->thrust_body[0] = scale * _v_att_sp->thrust_body[0] + (1.f - scale) * (-_last_thr_in_mc); | ||||||
sfuhrer marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
|
||||||
void Tailsitter::blendThrottleBeginningBackTransition(float scale) | ||||||
{ | ||||||
_v_att_sp->thrust_body[2] = scale * _v_att_sp->thrust_body[2] + (1.f - scale) * (-_last_thr_in_fw_mode); | ||||||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Instead of hard coding these little magic timeouts everywhere what about checking against the actual FW controller publication (_fw_virtual_att_sp)?
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.
I didn't find a good way without the hard coded timeout.
_fw_virtual_att_sp
is constantly being published in the transition phase (with thrust=0), so barely looking at the timestamp doesn't help. We would need to do some isNone() checks._fw_virtual_att_sp
publication and the torque/thrust handling we do here, as one comes from the position controller while the other is the output from the FW rate controller.