|
|
@ -43,20 +43,18 @@ |
|
|
|
|
|
|
|
|
|
|
|
WeatherVane::WeatherVane() : |
|
|
|
WeatherVane::WeatherVane() : |
|
|
|
ModuleParams(nullptr) |
|
|
|
ModuleParams(nullptr) |
|
|
|
{ |
|
|
|
{ } |
|
|
|
_R_sp_prev = matrix::Dcmf(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WeatherVane::update(const matrix::Quatf &q_sp_prev, float yaw) |
|
|
|
void WeatherVane::update(const matrix::Vector3f &dcm_z_sp_prev, float yaw) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_R_sp_prev = matrix::Dcmf(q_sp_prev); |
|
|
|
_dcm_z_sp_prev = dcm_z_sp_prev; |
|
|
|
_yaw = yaw; |
|
|
|
_yaw = yaw; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
float WeatherVane::get_weathervane_yawrate() |
|
|
|
float WeatherVane::get_weathervane_yawrate() |
|
|
|
{ |
|
|
|
{ |
|
|
|
// direction of desired body z axis represented in earth frame
|
|
|
|
// direction of desired body z axis represented in earth frame
|
|
|
|
matrix::Vector3f body_z_sp(_R_sp_prev(0, 2), _R_sp_prev(1, 2), _R_sp_prev(2, 2)); |
|
|
|
matrix::Vector3f body_z_sp(_dcm_z_sp_prev); |
|
|
|
|
|
|
|
|
|
|
|
// rotate desired body z axis into new frame which is rotated in z by the current
|
|
|
|
// rotate desired body z axis into new frame which is rotated in z by the current
|
|
|
|
// heading of the vehicle. we refer to this as the heading frame.
|
|
|
|
// heading of the vehicle. we refer to this as the heading frame.
|
|
|
@ -74,7 +72,6 @@ float WeatherVane::get_weathervane_yawrate() |
|
|
|
|
|
|
|
|
|
|
|
} else if (roll_sp < -min_roll_rad) { |
|
|
|
} else if (roll_sp < -min_roll_rad) { |
|
|
|
roll_exceeding_treshold = roll_sp + min_roll_rad; |
|
|
|
roll_exceeding_treshold = roll_sp + min_roll_rad; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return math::constrain(roll_exceeding_treshold * _param_wv_gain.get(), -math::radians(_param_wv_yrate_max.get()), |
|
|
|
return math::constrain(roll_exceeding_treshold * _param_wv_gain.get(), -math::radians(_param_wv_yrate_max.get()), |
|
|
|