mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 17:48:53 +08:00
fw position controller: logic cleanup
cleaned up logic when not to use pitch setpoint from TECS Signed-off-by: tumbili <roman@px4.io>
This commit is contained in:
@@ -2065,15 +2065,24 @@ FixedwingPositionControl::control_position(const math::Vector<2> ¤t_positi
|
||||
|
||||
}
|
||||
|
||||
/* During a takeoff waypoint while waiting for launch the pitch sp is set
|
||||
* already (not by tecs) */
|
||||
if (!(_control_mode_current == FW_POSCTRL_MODE_AUTO && (
|
||||
(pos_sp_triplet.current.type == position_setpoint_s::SETPOINT_TYPE_TAKEOFF &&
|
||||
(_launch_detection_state == LAUNCHDETECTION_RES_NONE ||
|
||||
_runway_takeoff.runwayTakeoffEnabled())) ||
|
||||
(pos_sp_triplet.current.type == position_setpoint_s::SETPOINT_TYPE_LAND &&
|
||||
_land_noreturn_vertical))
|
||||
)) {
|
||||
// decide when to use pitch setpoint from TECS because in some cases pitch
|
||||
// setpoint is generated by other means
|
||||
bool use_tecs_pitch = true;
|
||||
|
||||
// auto runway takeoff
|
||||
use_tecs_pitch &= !(_control_mode_current == FW_POSCTRL_MODE_AUTO &&
|
||||
pos_sp_triplet.current.type == position_setpoint_s::SETPOINT_TYPE_TAKEOFF &&
|
||||
(_launch_detection_state == LAUNCHDETECTION_RES_NONE || _runway_takeoff.runwayTakeoffEnabled()));
|
||||
|
||||
|
||||
// flaring during landing
|
||||
use_tecs_pitch &= !(pos_sp_triplet.current.type == position_setpoint_s::SETPOINT_TYPE_LAND &&
|
||||
_land_noreturn_vertical);
|
||||
|
||||
// manual attitude control
|
||||
use_tecs_pitch &= !(_control_mode_current == FW_POSCTRL_MODE_OTHER);
|
||||
|
||||
if (use_tecs_pitch) {
|
||||
_att_sp.pitch_body = get_tecs_pitch();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user