mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 04:03:34 +08:00
Refactor: Name manual_control_setpoint the same way everywhere
This commit is contained in:
committed by
Daniel Agar
parent
c6dd8bfcd6
commit
e9eae1bd76
@@ -141,11 +141,12 @@ FixedwingAttitudeControl::vehicle_manual_poll()
|
||||
if (_vcontrol_mode.flag_control_manual_enabled && (!is_tailsitter_transition || is_fixed_wing)) {
|
||||
|
||||
// Always copy the new manual setpoint, even if it wasn't updated, to fill the _actuators with valid values
|
||||
if (_manual_sub.copy(&_manual)) {
|
||||
if (_manual_control_setpoint_sub.copy(&_manual_control_setpoint)) {
|
||||
|
||||
// Check if we are in rattitude mode and the pilot is above the threshold on pitch
|
||||
if (_vcontrol_mode.flag_control_rattitude_enabled) {
|
||||
if (fabsf(_manual.y) > _param_fw_ratt_th.get() || fabsf(_manual.x) > _param_fw_ratt_th.get()) {
|
||||
if (fabsf(_manual_control_setpoint.y) > _param_fw_ratt_th.get()
|
||||
|| fabsf(_manual_control_setpoint.x) > _param_fw_ratt_th.get()) {
|
||||
_vcontrol_mode.flag_control_attitude_enabled = false;
|
||||
}
|
||||
}
|
||||
@@ -156,16 +157,17 @@ FixedwingAttitudeControl::vehicle_manual_poll()
|
||||
if (_vcontrol_mode.flag_control_attitude_enabled) {
|
||||
// STABILIZED mode generate the attitude setpoint from manual user inputs
|
||||
|
||||
_att_sp.roll_body = _manual.y * radians(_param_fw_man_r_max.get()) + radians(_param_fw_rsp_off.get());
|
||||
_att_sp.roll_body = _manual_control_setpoint.y * radians(_param_fw_man_r_max.get()) + radians(_param_fw_rsp_off.get());
|
||||
_att_sp.roll_body = constrain(_att_sp.roll_body,
|
||||
-radians(_param_fw_man_r_max.get()), radians(_param_fw_man_r_max.get()));
|
||||
|
||||
_att_sp.pitch_body = -_manual.x * radians(_param_fw_man_p_max.get()) + radians(_param_fw_psp_off.get());
|
||||
_att_sp.pitch_body = -_manual_control_setpoint.x * radians(_param_fw_man_p_max.get())
|
||||
+ radians(_param_fw_psp_off.get());
|
||||
_att_sp.pitch_body = constrain(_att_sp.pitch_body,
|
||||
-radians(_param_fw_man_p_max.get()), radians(_param_fw_man_p_max.get()));
|
||||
|
||||
_att_sp.yaw_body = 0.0f;
|
||||
_att_sp.thrust_body[0] = _manual.z;
|
||||
_att_sp.thrust_body[0] = _manual_control_setpoint.z;
|
||||
|
||||
Quatf q(Eulerf(_att_sp.roll_body, _att_sp.pitch_body, _att_sp.yaw_body));
|
||||
q.copyTo(_att_sp.q_d);
|
||||
@@ -179,19 +181,22 @@ FixedwingAttitudeControl::vehicle_manual_poll()
|
||||
|
||||
// RATE mode we need to generate the rate setpoint from manual user inputs
|
||||
_rates_sp.timestamp = hrt_absolute_time();
|
||||
_rates_sp.roll = _manual.y * radians(_param_fw_acro_x_max.get());
|
||||
_rates_sp.pitch = -_manual.x * radians(_param_fw_acro_y_max.get());
|
||||
_rates_sp.yaw = _manual.r * radians(_param_fw_acro_z_max.get());
|
||||
_rates_sp.thrust_body[0] = _manual.z;
|
||||
_rates_sp.roll = _manual_control_setpoint.y * radians(_param_fw_acro_x_max.get());
|
||||
_rates_sp.pitch = -_manual_control_setpoint.x * radians(_param_fw_acro_y_max.get());
|
||||
_rates_sp.yaw = _manual_control_setpoint.r * radians(_param_fw_acro_z_max.get());
|
||||
_rates_sp.thrust_body[0] = _manual_control_setpoint.z;
|
||||
|
||||
_rate_sp_pub.publish(_rates_sp);
|
||||
|
||||
} else {
|
||||
/* manual/direct control */
|
||||
_actuators.control[actuator_controls_s::INDEX_ROLL] = _manual.y * _param_fw_man_r_sc.get() + _param_trim_roll.get();
|
||||
_actuators.control[actuator_controls_s::INDEX_PITCH] = -_manual.x * _param_fw_man_p_sc.get() + _param_trim_pitch.get();
|
||||
_actuators.control[actuator_controls_s::INDEX_YAW] = _manual.r * _param_fw_man_y_sc.get() + _param_trim_yaw.get();
|
||||
_actuators.control[actuator_controls_s::INDEX_THROTTLE] = _manual.z;
|
||||
_actuators.control[actuator_controls_s::INDEX_ROLL] =
|
||||
_manual_control_setpoint.y * _param_fw_man_r_sc.get() + _param_trim_roll.get();
|
||||
_actuators.control[actuator_controls_s::INDEX_PITCH] =
|
||||
-_manual_control_setpoint.x * _param_fw_man_p_sc.get() + _param_trim_pitch.get();
|
||||
_actuators.control[actuator_controls_s::INDEX_YAW] =
|
||||
_manual_control_setpoint.r * _param_fw_man_y_sc.get() + _param_trim_yaw.get();
|
||||
_actuators.control[actuator_controls_s::INDEX_THROTTLE] = _manual_control_setpoint.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,7 +548,7 @@ void FixedwingAttitudeControl::Run()
|
||||
|
||||
/* add in manual rudder control in manual modes */
|
||||
if (_vcontrol_mode.flag_control_manual_enabled) {
|
||||
_actuators.control[actuator_controls_s::INDEX_YAW] += _manual.r;
|
||||
_actuators.control[actuator_controls_s::INDEX_YAW] += _manual_control_setpoint.r;
|
||||
}
|
||||
|
||||
if (!PX4_ISFINITE(yaw_u)) {
|
||||
@@ -626,10 +631,10 @@ void FixedwingAttitudeControl::Run()
|
||||
* constrain(_actuators.control[actuator_controls_s::INDEX_ROLL], -1.0f, 1.0f);
|
||||
|
||||
_actuators.control[actuator_controls_s::INDEX_FLAPS] = _flaps_applied;
|
||||
_actuators.control[5] = _manual.aux1;
|
||||
_actuators.control[5] = _manual_control_setpoint.aux1;
|
||||
_actuators.control[actuator_controls_s::INDEX_AIRBRAKES] = _flaperons_applied;
|
||||
// FIXME: this should use _vcontrol_mode.landing_gear_pos in the future
|
||||
_actuators.control[7] = _manual.aux3;
|
||||
_actuators.control[7] = _manual_control_setpoint.aux3;
|
||||
|
||||
/* lazily publish the setpoint only once available */
|
||||
_actuators.timestamp = hrt_absolute_time();
|
||||
@@ -652,9 +657,9 @@ void FixedwingAttitudeControl::control_flaps(const float dt)
|
||||
float flap_control = 0.0f;
|
||||
|
||||
/* map flaps by default to manual if valid */
|
||||
if (PX4_ISFINITE(_manual.flaps) && _vcontrol_mode.flag_control_manual_enabled
|
||||
if (PX4_ISFINITE(_manual_control_setpoint.flaps) && _vcontrol_mode.flag_control_manual_enabled
|
||||
&& fabsf(_param_fw_flaps_scl.get()) > 0.01f) {
|
||||
flap_control = 0.5f * (_manual.flaps + 1.0f) * _param_fw_flaps_scl.get();
|
||||
flap_control = 0.5f * (_manual_control_setpoint.flaps + 1.0f) * _param_fw_flaps_scl.get();
|
||||
|
||||
} else if (_vcontrol_mode.flag_control_auto_enabled
|
||||
&& fabsf(_param_fw_flaps_scl.get()) > 0.01f) {
|
||||
@@ -686,10 +691,10 @@ void FixedwingAttitudeControl::control_flaps(const float dt)
|
||||
float flaperon_control = 0.0f;
|
||||
|
||||
/* map flaperons by default to manual if valid */
|
||||
if (PX4_ISFINITE(_manual.aux2) && _vcontrol_mode.flag_control_manual_enabled
|
||||
if (PX4_ISFINITE(_manual_control_setpoint.aux2) && _vcontrol_mode.flag_control_manual_enabled
|
||||
&& fabsf(_param_fw_flaperon_scl.get()) > 0.01f) {
|
||||
|
||||
flaperon_control = 0.5f * (_manual.aux2 + 1.0f) * _param_fw_flaperon_scl.get();
|
||||
flaperon_control = 0.5f * (_manual_control_setpoint.aux2 + 1.0f) * _param_fw_flaperon_scl.get();
|
||||
|
||||
} else if (_vcontrol_mode.flag_control_auto_enabled
|
||||
&& fabsf(_param_fw_flaperon_scl.get()) > 0.01f) {
|
||||
|
||||
@@ -98,7 +98,7 @@ private:
|
||||
uORB::Subscription _att_sp_sub{ORB_ID(vehicle_attitude_setpoint)}; /**< vehicle attitude setpoint */
|
||||
uORB::Subscription _battery_status_sub{ORB_ID(battery_status)}; /**< battery status subscription */
|
||||
uORB::Subscription _local_pos_sub{ORB_ID(vehicle_local_position)}; /**< local position subscription */
|
||||
uORB::Subscription _manual_sub{ORB_ID(manual_control_setpoint)}; /**< notification of manual control updates */
|
||||
uORB::Subscription _manual_control_setpoint_sub{ORB_ID(manual_control_setpoint)}; /**< notification of manual control updates */
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)}; /**< notification of parameter updates */
|
||||
uORB::Subscription _rates_sp_sub{ORB_ID(vehicle_rates_setpoint)}; /**< vehicle rates setpoint */
|
||||
uORB::Subscription _vcontrol_mode_sub{ORB_ID(vehicle_control_mode)}; /**< vehicle status subscription */
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
uORB::PublicationMulti<rate_ctrl_status_s> _rate_ctrl_status_pub{ORB_ID(rate_ctrl_status)};
|
||||
|
||||
actuator_controls_s _actuators {}; /**< actuator control inputs */
|
||||
manual_control_setpoint_s _manual {}; /**< r/c channel data */
|
||||
manual_control_setpoint_s _manual_control_setpoint {}; /**< r/c channel data */
|
||||
vehicle_attitude_s _att {}; /**< vehicle attitude setpoint */
|
||||
vehicle_attitude_setpoint_s _att_sp {}; /**< vehicle attitude setpoint */
|
||||
vehicle_control_mode_s _vcontrol_mode {}; /**< vehicle control mode */
|
||||
|
||||
Reference in New Issue
Block a user