mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-12-01 21:52:12 +08:00
fix(vtol_att_control): correct tailsitter quadchute attitude frame (#27834)
* fix(vtol_att_control): correct tailsitter quadchute attitude frame * refactor(vtol_att_control): precompute tailsitter FW frame rotation
This commit is contained in:
1 parent
7b19bbf75f
commit
d60fea65d2
3 files changed
+50
-2
No files matched your search
@@ -56,6 +56,48 @@ Tailsitter::parameters_update()
|
||||
|
||||
}
|
||||
|
||||
Eulerf Tailsitter::getFixedWingAttitudeEuler() const
|
||||
{
|
||||
// Tailsitter attitude is estimated in MC frame; rotate it to FW frame before checking FW limits.
|
||||
return Eulerf(Quatf(_v_att->q) * _q_fw_to_mc);
|
||||
}
|
||||
|
||||
bool Tailsitter::isPitchExceeded()
|
||||
{
|
||||
if (_common_vtol_mode != mode::FIXED_WING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// fixed-wing maximum pitch angle
|
||||
if (_param_vt_fw_qc_p.get() > 0) {
|
||||
const Eulerf euler = getFixedWingAttitudeEuler();
|
||||
|
||||
if (fabsf(euler.theta()) > fabsf(math::radians(static_cast<float>(_param_vt_fw_qc_p.get())))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Tailsitter::isRollExceeded()
|
||||
{
|
||||
if (_common_vtol_mode != mode::FIXED_WING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// fixed-wing maximum roll angle
|
||||
if (_param_vt_fw_qc_r.get() > 0) {
|
||||
const Eulerf euler = getFixedWingAttitudeEuler();
|
||||
|
||||
if (fabsf(euler.phi()) > fabsf(math::radians(static_cast<float>(_param_vt_fw_qc_r.get())))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Tailsitter::update_vtol_state()
|
||||
{
|
||||
/* simple logic using a two way switch to perform transitions.
|
||||
|
||||
@@ -88,9 +88,15 @@ private:
|
||||
matrix::Quatf _q_trans_sp;
|
||||
matrix::Vector3f _trans_rot_axis;
|
||||
|
||||
inline static const matrix::Quatf _q_fw_to_mc{matrix::Eulerf{0.f, M_PI_2_F, 0.f}};
|
||||
|
||||
void parameters_update() override;
|
||||
|
||||
bool isFrontTransitionCompletedBase() override;
|
||||
bool isPitchExceeded() override;
|
||||
bool isRollExceeded() override;
|
||||
|
||||
matrix::Eulerf getFixedWingAttitudeEuler() const;
|
||||
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(VtolType,
|
||||
(ParamFloat<px4::params::FW_PSP_OFF>) _param_fw_psp_off
|
||||
|
||||
@@ -182,14 +182,14 @@ public:
|
||||
*
|
||||
* @return true if exeeded
|
||||
*/
|
||||
bool isPitchExceeded();
|
||||
virtual bool isPitchExceeded();
|
||||
|
||||
/**
|
||||
* @brief Indicates if the absolute value of the vehicle roll angle exceeds the threshold defined by VT_FW_QC_R
|
||||
*
|
||||
* @return true if exeeded
|
||||
*/
|
||||
bool isRollExceeded();
|
||||
virtual bool isRollExceeded();
|
||||
|
||||
/**
|
||||
* @brief Indicates if the front transition duration has exceeded the timeout definded by VT_TRANS_TIMEOUT
|
||||
|
||||
Reference in new issue
Block a user