mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 04:43:36 +08:00
delete control_state and cleanup vehicle_attitude (#7882)
This commit is contained in:
@@ -72,7 +72,7 @@ Standard::Standard(VtolAttitudeControl *attc) :
|
||||
_params_handles_standard.front_trans_time_min = param_find("VT_TRANS_MIN_TM");
|
||||
_params_handles_standard.down_pitch_max = param_find("VT_DWN_PITCH_MAX");
|
||||
_params_handles_standard.forward_thrust_scale = param_find("VT_FWD_THRUST_SC");
|
||||
_params_handles_standard.airspeed_mode = param_find("FW_ARSP_MODE");
|
||||
_params_handles_standard.airspeed_disabled = param_find("FW_ARSP_MODE");
|
||||
_params_handles_standard.pitch_setpoint_offset = param_find("FW_PSP_OFF");
|
||||
_params_handles_standard.reverse_output = param_find("VT_B_REV_OUT");
|
||||
_params_handles_standard.reverse_delay = param_find("VT_B_REV_DEL");
|
||||
@@ -131,8 +131,8 @@ Standard::parameters_update()
|
||||
param_get(_params_handles_standard.forward_thrust_scale, &_params_standard.forward_thrust_scale);
|
||||
|
||||
/* airspeed mode */
|
||||
param_get(_params_handles_standard.airspeed_mode, &i);
|
||||
_params_standard.airspeed_mode = math::constrain(i, 0, 2);
|
||||
param_get(_params_handles_standard.airspeed_disabled, &i);
|
||||
_params_standard.airspeed_disabled = math::constrain(i, 0, 1);
|
||||
|
||||
/* pitch setpoint offset */
|
||||
param_get(_params_handles_standard.pitch_setpoint_offset, &v);
|
||||
@@ -240,7 +240,7 @@ void Standard::update_vtol_state()
|
||||
|
||||
} else if (_vtol_schedule.flight_mode == TRANSITION_TO_FW) {
|
||||
// continue the transition to fw mode while monitoring airspeed for a final switch to fw mode
|
||||
if (((_params_standard.airspeed_mode == control_state_s::AIRSPD_MODE_DISABLED ||
|
||||
if (((_params_standard.airspeed_disabled == 1 ||
|
||||
_airspeed->indicated_airspeed_m_s >= _params_standard.airspeed_trans) &&
|
||||
(float)hrt_elapsed_time(&_vtol_schedule.transition_start)
|
||||
> (_params_standard.front_trans_time_min * 1000000.0f)) ||
|
||||
@@ -308,14 +308,13 @@ void Standard::update_transition_state()
|
||||
|
||||
// time based blending when no airspeed sensor is set
|
||||
|
||||
} else if (_params_standard.airspeed_mode == control_state_s::AIRSPD_MODE_DISABLED &&
|
||||
(float)hrt_elapsed_time(&_vtol_schedule.transition_start) < (_params_standard.front_trans_time_min * 1000000.0f) &&
|
||||
(float)hrt_elapsed_time(&_vtol_schedule.transition_start) > ((_params_standard.front_trans_time_min / 2.0f) *
|
||||
1000000.0f)
|
||||
} else if (_params_standard.airspeed_disabled &&
|
||||
hrt_elapsed_time(&_vtol_schedule.transition_start) < (_params_standard.front_trans_time_min * 1e6f) &&
|
||||
hrt_elapsed_time(&_vtol_schedule.transition_start) > ((_params_standard.front_trans_time_min / 2.0f) * 1e6f)
|
||||
) {
|
||||
float weight = 1.0f - ((float)(hrt_elapsed_time(&_vtol_schedule.transition_start) - ((
|
||||
_params_standard.front_trans_time_min / 2.0f) * 1000000.0f)) /
|
||||
((_params_standard.front_trans_time_min / 2.0f) * 1000000.0f));
|
||||
float weight = 1.0f - ((hrt_elapsed_time(&_vtol_schedule.transition_start) - ((
|
||||
_params_standard.front_trans_time_min / 2.0f) * 1e6f)) /
|
||||
((_params_standard.front_trans_time_min / 2.0f) * 1e6f));
|
||||
|
||||
weight = math::constrain(weight, 0.0f, 1.0f);
|
||||
|
||||
@@ -340,7 +339,7 @@ void Standard::update_transition_state()
|
||||
|
||||
// check front transition timeout
|
||||
if (_params_standard.front_trans_timeout > FLT_EPSILON) {
|
||||
if ((float)hrt_elapsed_time(&_vtol_schedule.transition_start) > (_params_standard.front_trans_timeout * 1000000.0f)) {
|
||||
if (hrt_elapsed_time(&_vtol_schedule.transition_start) > (_params_standard.front_trans_timeout * 1e6f)) {
|
||||
// transition timeout occured, abort transition
|
||||
_attc->abort_front_transition("Transition timeout");
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
float front_trans_time_min;
|
||||
float down_pitch_max;
|
||||
float forward_thrust_scale;
|
||||
int airspeed_mode;
|
||||
int32_t airspeed_disabled;
|
||||
float pitch_setpoint_offset;
|
||||
float reverse_output;
|
||||
float reverse_delay;
|
||||
@@ -96,7 +96,7 @@ private:
|
||||
param_t front_trans_time_min;
|
||||
param_t down_pitch_max;
|
||||
param_t forward_thrust_scale;
|
||||
param_t airspeed_mode;
|
||||
param_t airspeed_disabled;
|
||||
param_t pitch_setpoint_offset;
|
||||
param_t reverse_output;
|
||||
param_t reverse_delay;
|
||||
|
||||
@@ -69,7 +69,7 @@ Tiltrotor::Tiltrotor(VtolAttitudeControl *attc) :
|
||||
_params_handles_tiltrotor.elevons_mc_lock = param_find("VT_ELEV_MC_LOCK");
|
||||
_params_handles_tiltrotor.front_trans_dur_p2 = param_find("VT_TRANS_P2_DUR");
|
||||
_params_handles_tiltrotor.fw_motors_off = param_find("VT_FW_MOT_OFFID");
|
||||
_params_handles_tiltrotor.airspeed_mode = param_find("FW_ARSP_MODE");
|
||||
_params_handles_tiltrotor.airspeed_disabled = param_find("FW_ARSP_MODE");
|
||||
_params_handles_tiltrotor.diff_thrust = param_find("VT_FW_DIFTHR_EN");
|
||||
_params_handles_tiltrotor.diff_thrust_scale = param_find("VT_FW_DIFTHR_SC");
|
||||
}
|
||||
@@ -89,7 +89,6 @@ Tiltrotor::parameters_update()
|
||||
param_get(_params_handles_tiltrotor.fw_motors_off, &l);
|
||||
_params_tiltrotor.fw_motors_off = get_motor_off_channels(l);
|
||||
|
||||
|
||||
/* vtol duration of a front transition */
|
||||
param_get(_params_handles_tiltrotor.front_trans_dur, &v);
|
||||
_params_tiltrotor.front_trans_dur = math::constrain(v, 1.0f, 5.0f);
|
||||
@@ -134,8 +133,8 @@ Tiltrotor::parameters_update()
|
||||
}
|
||||
|
||||
/* airspeed mode */
|
||||
param_get(_params_handles_tiltrotor.airspeed_mode, &l);
|
||||
_params_tiltrotor.airspeed_mode = math::constrain(l, 0, 2);
|
||||
param_get(_params_handles_tiltrotor.airspeed_disabled, &l);
|
||||
_params_tiltrotor.airspeed_disabled = math::constrain(l, 0, 1);
|
||||
|
||||
param_get(_params_handles_tiltrotor.diff_thrust, &_params_tiltrotor.diff_thrust);
|
||||
|
||||
@@ -219,12 +218,12 @@ void Tiltrotor::update_vtol_state()
|
||||
bool transition_to_p2 = can_transition_on_ground();
|
||||
|
||||
// check if we have reached airspeed to switch to fw mode
|
||||
transition_to_p2 |= _params_tiltrotor.airspeed_mode != control_state_s::AIRSPD_MODE_DISABLED &&
|
||||
transition_to_p2 |= !_params_tiltrotor.airspeed_disabled &&
|
||||
_airspeed->indicated_airspeed_m_s >= _params_tiltrotor.airspeed_trans &&
|
||||
(float)hrt_elapsed_time(&_vtol_schedule.transition_start) > (_params->front_trans_time_min * 1e6f);
|
||||
|
||||
// check if airspeed is invalid and transition by time
|
||||
transition_to_p2 |= _params_tiltrotor.airspeed_mode == control_state_s::AIRSPD_MODE_DISABLED &&
|
||||
transition_to_p2 |= _params_tiltrotor.airspeed_disabled &&
|
||||
_tilt_control > _params_tiltrotor.tilt_transition &&
|
||||
(float)hrt_elapsed_time(&_vtol_schedule.transition_start) > (_params->front_trans_time_openloop * 1e6f);
|
||||
|
||||
@@ -334,7 +333,7 @@ void Tiltrotor::update_transition_state()
|
||||
&_vtol_schedule.transition_start) / (_params_tiltrotor.front_trans_dur * 1000000.0f);
|
||||
}
|
||||
|
||||
bool use_airspeed = _params_tiltrotor.airspeed_mode != control_state_s::AIRSPD_MODE_DISABLED;
|
||||
bool use_airspeed = !_params_tiltrotor.airspeed_disabled;
|
||||
|
||||
// at low speeds give full weight to MC
|
||||
_mc_roll_weight = 1.0f;
|
||||
|
||||
@@ -69,11 +69,11 @@ private:
|
||||
float tilt_fw; /**< actuator value corresponding to fw tilt */
|
||||
float airspeed_trans; /**< airspeed at which we switch to fw mode after transition */
|
||||
float airspeed_blend_start; /**< airspeed at which we start blending mc/fw controls */
|
||||
int elevons_mc_lock; /**< lock elevons in multicopter mode */
|
||||
int32_t elevons_mc_lock; /**< lock elevons in multicopter mode */
|
||||
float front_trans_dur_p2;
|
||||
int fw_motors_off; /**< bitmask of all motors that should be off in fixed wing mode */
|
||||
int airspeed_mode;
|
||||
int diff_thrust;
|
||||
int32_t fw_motors_off; /**< bitmask of all motors that should be off in fixed wing mode */
|
||||
int32_t airspeed_disabled;
|
||||
int32_t diff_thrust;
|
||||
float diff_thrust_scale;
|
||||
} _params_tiltrotor;
|
||||
|
||||
@@ -88,7 +88,7 @@ private:
|
||||
param_t elevons_mc_lock;
|
||||
param_t front_trans_dur_p2;
|
||||
param_t fw_motors_off;
|
||||
param_t airspeed_mode;
|
||||
param_t airspeed_disabled;
|
||||
param_t diff_thrust;
|
||||
param_t diff_thrust_scale;
|
||||
} _params_handles_tiltrotor;
|
||||
|
||||
@@ -67,7 +67,6 @@
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/airspeed.h>
|
||||
#include <uORB/topics/battery_status.h>
|
||||
#include <uORB/topics/control_state.h>
|
||||
#include <uORB/topics/manual_control_setpoint.h>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
#include <uORB/topics/tecs_status.h>
|
||||
|
||||
Reference in New Issue
Block a user