mc_att_control: don't store full vehicle_land_detected copy

This commit is contained in:
Daniel Agar 2020-08-08 12:48:48 -04:00
parent 41a1675c53
commit 8c42c38650
2 changed files with 12 additions and 5 deletions

View File

@ -114,7 +114,6 @@ private:
struct manual_control_setpoint_s _manual_control_setpoint {}; /**< manual control setpoint */
struct vehicle_control_mode_s _v_control_mode {}; /**< vehicle control mode */
struct vehicle_status_s _vehicle_status {}; /**< vehicle status */
struct vehicle_land_detected_s _vehicle_land_detected {};
perf_counter_t _loop_perf; /**< loop duration performance counter */
@ -127,6 +126,7 @@ private:
hrt_abstime _last_run{0};
bool _landed{true};
bool _reset_yaw_sp{true};
uint8_t _quat_reset_counter{0};

View File

@ -104,7 +104,7 @@ MulticopterAttitudeControl::parameters_updated()
float
MulticopterAttitudeControl::throttle_curve(float throttle_stick_input)
{
const float throttle_min = _vehicle_land_detected.landed ? 0.0f : _param_mpc_manthr_min.get();
const float throttle_min = _landed ? 0.0f : _param_mpc_manthr_min.get();
// throttle_stick_input is in range [0, 1]
switch (_param_mpc_thr_curve.get()) {
@ -268,7 +268,15 @@ MulticopterAttitudeControl::Run()
/* check for updates in other topics */
_manual_control_setpoint_sub.update(&_manual_control_setpoint);
_v_control_mode_sub.update(&_v_control_mode);
_vehicle_land_detected_sub.update(&_vehicle_land_detected);
if (_vehicle_land_detected_sub.updated()) {
vehicle_land_detected_s vehicle_land_detected;
if (_vehicle_land_detected_sub.copy(&vehicle_land_detected)) {
_landed = vehicle_land_detected.landed;
}
}
_vehicle_status_sub.update(&_vehicle_status);
/* Check if we are in rattitude mode and the pilot is above the threshold on pitch
@ -334,8 +342,7 @@ MulticopterAttitudeControl::Run()
// reset yaw setpoint during transitions, tailsitter.cpp generates
// attitude setpoint for the transition
_reset_yaw_sp = (!attitude_setpoint_generated && !_v_control_mode.flag_control_rattitude_enabled) ||
_vehicle_land_detected.landed ||
(_vehicle_status.is_vtol && _vehicle_status.in_transition_mode);
_landed || (_vehicle_status.is_vtol && _vehicle_status.in_transition_mode);
}