-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
launch: add launch specific idle throttle param #9471
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1060,7 +1060,7 @@ FixedwingPositionControl::control_position(const Vector2f &curr_pos, const Vecto | |
/* making sure again that the correct thrust is used, | ||
* without depending on library calls for safety reasons. | ||
the pre-takeoff throttle and the idle throttle normally map to the same parameter. */ | ||
_att_sp.thrust = _parameters.throttle_idle; | ||
_att_sp.thrust = _launchDetector.getThrottleIdle(_parameters.throttle_idle); | ||
|
||
} else if (_control_mode_current == FW_POSCTRL_MODE_AUTO && | ||
pos_sp_curr.type == position_setpoint_s::SETPOINT_TYPE_TAKEOFF && | ||
|
@@ -1078,7 +1078,8 @@ FixedwingPositionControl::control_position(const Vector2f &curr_pos, const Vecto | |
|
||
} else { | ||
/* Copy thrust and pitch values from tecs */ | ||
if (_vehicle_land_detected.landed) { | ||
if (_vehicle_land_detected.landed && !(_launch_detection_state == LAUNCHDETECTION_RES_DETECTED_ENABLEMOTORS | ||
&& pos_sp_curr.type == position_setpoint_s::SETPOINT_TYPE_TAKEOFF)) { | ||
// when we are landed state we want the motor to spin at idle speed | ||
_att_sp.thrust = min(_parameters.throttle_idle, throttle_max); | ||
|
||
|
@@ -1231,7 +1232,7 @@ FixedwingPositionControl::control_takeoff(const Vector2f &curr_pos, const Vector | |
float takeoff_throttle = _parameters.throttle_max; | ||
|
||
if (_launch_detection_state != LAUNCHDETECTION_RES_DETECTED_ENABLEMOTORS) { | ||
takeoff_throttle = _parameters.throttle_idle; | ||
takeoff_throttle = _launchDetector.getThrottleIdle(_parameters.throttle_idle); | ||
} | ||
|
||
/* select maximum pitch: the launchdetector may impose another limit for the pitch | ||
|
@@ -1820,7 +1821,9 @@ FixedwingPositionControl::tecs_update_pitch_throttle(float alt_sp, float airspee | |
_last_tecs_update = hrt_absolute_time(); | ||
|
||
// do not run TECS if we are not in air | ||
bool run_tecs = !_vehicle_land_detected.landed; | ||
bool run_tecs = !_vehicle_land_detected.landed || (_launch_detection_state == LAUNCHDETECTION_RES_DETECTED_ENABLEMOTORS | ||
&& mode == tecs_status_s::TECS_MODE_TAKEOFF); | ||
// handles case of land detected / launch detected interference during take-off | ||
|
||
// do not run TECS if vehicle is a VTOL and we are in rotary wing mode or in transition | ||
// (it should also not run during VTOL blending because airspeed is too low still) | ||
|
@@ -1896,10 +1899,12 @@ FixedwingPositionControl::tecs_update_pitch_throttle(float alt_sp, float airspee | |
} | ||
|
||
/* tell TECS to update its state, but let it know when it cannot actually control the plane */ | ||
bool in_air_alt_control = (!_vehicle_land_detected.landed && | ||
(_control_mode.flag_control_auto_enabled || | ||
_control_mode.flag_control_velocity_enabled || | ||
_control_mode.flag_control_altitude_enabled)); | ||
bool in_air_alt_control = ((!_vehicle_land_detected.landed || | ||
(_launch_detection_state == LAUNCHDETECTION_RES_DETECTED_ENABLEMOTORS | ||
&& mode == tecs_status_s::TECS_MODE_TAKEOFF)) | ||
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. This is a mouthful, should we have a helper function? Same logic could be used for run_tecs above? 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. e.g. just an extra bool calculated directly above?
or do you mean an encapsulated function call?
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. The first one is good, I'd say. |
||
&& (_control_mode.flag_control_auto_enabled | ||
|| _control_mode.flag_control_velocity_enabled | ||
|| _control_mode.flag_control_altitude_enabled)); | ||
|
||
/* update TECS vehicle state estimates */ | ||
_tecs.update_vehicle_state_estimates(_airspeed, _R_nb, | ||
|
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.
Typically the pattern here is to pass the value you'd use in the non-launch detection case, and launch detector would return one or the other depending on if it's enabled.
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 believe this is what is happening. Or do I miss something? (at least this is what I intended)
LaunchDetector.cpp#L128
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.
My mistake, that looks correct.