Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard VTOL: fix pusher transition ramp up slew rate #23231

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/modules/vtol_att_control/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,11 @@ void Standard::update_transition_state()

} else if (_pusher_throttle <= _param_vt_f_trans_thr.get()) {
// ramp up throttle to the target throttle value
const float dt = math::min((now - _last_time_pusher_transition_update) / 1e6f, 0.05f);
_pusher_throttle = math::min(_pusher_throttle +
_param_vt_psher_slew.get() * _dt, _param_vt_f_trans_thr.get());
_param_vt_psher_slew.get() * dt, _param_vt_f_trans_thr.get());

_last_time_pusher_transition_update = now;
}

_airspeed_trans_blend_margin = getTransitionAirspeed() - getBlendAirspeed();
Expand Down
1 change: 1 addition & 0 deletions src/modules/vtol_att_control/standard.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Standard : public VtolType

float _pusher_throttle{0.0f};
float _airspeed_trans_blend_margin{0.0f};
hrt_abstime _last_time_pusher_transition_update{0};

void parameters_update() override;

Expand Down
9 changes: 2 additions & 7 deletions src/modules/vtol_att_control/vtol_att_control_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,17 @@ VtolAttitudeControl::Run()
return;
}

const hrt_abstime now = hrt_absolute_time();

#if !defined(ENABLE_LOCKSTEP_SCHEDULER)

const hrt_abstime now = hrt_absolute_time();

// prevent excessive scheduling (> 500 Hz)
if (now - _last_run_timestamp < 2_ms) {
return;
}

#endif // !ENABLE_LOCKSTEP_SCHEDULER

const float dt = math::min((now - _last_run_timestamp) / 1e6f, kMaxVTOLAttitudeControlTimeStep);
_last_run_timestamp = now;

if (!_initialized) {

if (_vtol_type->init()) {
Expand All @@ -309,8 +306,6 @@ VtolAttitudeControl::Run()
}
}

_vtol_type->setDt(dt);

perf_begin(_loop_perf);

bool updated_fw_in = _vehicle_torque_setpoint_virtual_fw_sub.update(&_vehicle_torque_setpoint_virtual_fw);
Expand Down
6 changes: 3 additions & 3 deletions src/modules/vtol_att_control/vtol_att_control_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ using namespace time_literals;

extern "C" __EXPORT int vtol_att_control_main(int argc, char *argv[]);

static constexpr float kMaxVTOLAttitudeControlTimeStep = 0.1f; // max time step [s]

class VtolAttitudeControl : public ModuleBase<VtolAttitudeControl>, public ModuleParams, public px4::WorkItem
{
public:
Expand Down Expand Up @@ -211,7 +209,9 @@ class VtolAttitudeControl : public ModuleBase<VtolAttitudeControl>, public Modul

float _air_density{atmosphere::kAirDensitySeaLevelStandardAtmos}; // [kg/m^3]

hrt_abstime _last_run_timestamp{0};
#if !defined(ENABLE_LOCKSTEP_SCHEDULER)
hrt_abstime _last_run_timestamp {0};
#endif // !ENABLE_LOCKSTEP_SCHEDULER

/* For multicopters it is usual to have a non-zero idle speed of the engines
* for fixed wings we want to have an idle speed of zero since we do not want
Expand Down
8 changes: 0 additions & 8 deletions src/modules/vtol_att_control/vtol_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,6 @@ class VtolType : public ModuleParams

virtual void parameters_update() = 0;

/**
* @brief Set current time delta
*
* @param dt Current time delta [s]
*/
void setDt(float dt) {_dt = dt; }

/**
* @brief Resets the transition timer states.
Expand Down Expand Up @@ -326,8 +320,6 @@ class VtolType : public ModuleParams
bool isFrontTransitionCompleted();
virtual bool isFrontTransitionCompletedBase();

float _dt{0.0025f}; // time step [s]

float _local_position_z_start_of_transition{0.f}; // altitude at start of transition

int _altitude_reset_counter{0};
Expand Down
Loading