FlightTask{Altitude+Orbit}: use getter for specific stick value instead of entire array

This commit is contained in:
Matthias Grob
2025-09-18 15:50:10 +02:00
committed by Silvan Fuhrer
parent 2bf9fce577
commit 2e910fe185
2 changed files with 8 additions and 8 deletions
@@ -91,8 +91,8 @@ void FlightTaskManualAltitude::_scaleSticks()
// Use sticks input with deadzone and exponential curve for vertical velocity
const float vel_max_up = fminf(_param_mpc_z_vel_max_up.get(), _velocity_constraint_up);
const float vel_max_down = fminf(_param_mpc_z_vel_max_dn.get(), _velocity_constraint_down);
const float vel_max_z = (_sticks.getPosition()(2) > 0.0f) ? vel_max_down : vel_max_up;
_velocity_setpoint(2) = vel_max_z * _sticks.getPositionExpo()(2);
const float vel_max_z = (_sticks.getThrottleZeroCentered() < 0.f) ? vel_max_down : vel_max_up;
_velocity_setpoint(2) = vel_max_z * -_sticks.getThrottleZeroCenteredExpo();
}
void FlightTaskManualAltitude::_updateAltitudeLock()
@@ -101,7 +101,7 @@ void FlightTaskManualAltitude::_updateAltitudeLock()
// If not locked, altitude setpoint is set to NAN.
// Check if user wants to break
const bool apply_brake = fabsf(_sticks.getPositionExpo()(2)) <= FLT_EPSILON;
const bool apply_brake = fabsf(_sticks.getThrottleZeroCenteredExpo()) <= FLT_EPSILON;
// Check if vehicle has stopped
const bool stopped = (_param_mpc_hold_max_z.get() < FLT_EPSILON || fabsf(_velocity(2)) < _param_mpc_hold_max_z.get());
@@ -284,7 +284,7 @@ void FlightTaskManualAltitude::_updateSetpoints()
bool FlightTaskManualAltitude::_checkTakeoff()
{
// stick is deflected above 65% throttle (throttle stick is in the range [-1,1])
return _sticks.getPosition()(2) < -0.3f;
return _sticks.getThrottleZeroCentered() > 0.3f;
}
bool FlightTaskManualAltitude::update()
@@ -292,8 +292,8 @@ void FlightTaskOrbit::_adjustParametersByStick()
switch (_yaw_behaviour) {
case orbit_status_s::ORBIT_YAW_BEHAVIOUR_HOLD_FRONT_TANGENT_TO_CIRCLE:
radius -= signFromBool(_started_clockwise) * _sticks.getPositionExpo()(1) * _deltatime * _param_mpc_xy_cruise.get();
velocity += signFromBool(_started_clockwise) * _sticks.getPositionExpo()(0) * _deltatime * _param_mpc_acc_hor.get();
radius -= signFromBool(_started_clockwise) * _sticks.getRollExpo() * _deltatime * _param_mpc_xy_cruise.get();
velocity += signFromBool(_started_clockwise) * _sticks.getPitchExpo() * _deltatime * _param_mpc_acc_hor.get();
break;
case orbit_status_s::ORBIT_YAW_BEHAVIOUR_HOLD_INITIAL_HEADING:
@@ -302,8 +302,8 @@ void FlightTaskOrbit::_adjustParametersByStick()
case orbit_status_s::ORBIT_YAW_BEHAVIOUR_HOLD_FRONT_TO_CIRCLE_CENTER:
default:
// stick input adjusts parameters within a fixed time frame
radius -= _sticks.getPositionExpo()(0) * _deltatime * _param_mpc_xy_cruise.get();
velocity -= _sticks.getPositionExpo()(1) * _deltatime * _param_mpc_acc_hor.get();
radius -= _sticks.getPitchExpo() * _deltatime * _param_mpc_xy_cruise.get();
velocity -= _sticks.getRollExpo() * _deltatime * _param_mpc_acc_hor.get();
break;
}