From ad88ef14e1745f04af27ecd7ad48ed62f491a0ea Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 18 Sep 2018 20:24:02 +0200 Subject: [PATCH] weathervane: use a single parameter to enable - in auto mode we always run weather vane - in manual model we just use it in position control mode Signed-off-by: Roman --- src/lib/WeatherVane/WeatherVane.hpp | 7 ++----- src/lib/WeatherVane/weathervane_params.c | 12 ++---------- src/modules/mc_pos_control/mc_pos_control_main.cpp | 7 +++---- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/lib/WeatherVane/WeatherVane.hpp b/src/lib/WeatherVane/WeatherVane.hpp index dfa49e6850..c96bbb6392 100644 --- a/src/lib/WeatherVane/WeatherVane.hpp +++ b/src/lib/WeatherVane/WeatherVane.hpp @@ -58,9 +58,7 @@ public: bool is_active() {return _is_active;} - bool manual_enabled() { return _wv_manual_enabled.get(); } - - bool auto_enabled() { return _wv_auto_enabled.get(); } + bool weathervane_enabled() { return _wv_enabled.get(); } void update(const matrix::Quatf &q_sp_prev, float yaw); @@ -75,8 +73,7 @@ private: bool _is_active = true; DEFINE_PARAMETERS( - (ParamBool) _wv_manual_enabled, - (ParamBool) _wv_auto_enabled, + (ParamBool) _wv_enabled, (ParamFloat) _wv_min_roll, (ParamFloat) _wv_gain, (ParamFloat) _wv_max_yaw_rate diff --git a/src/lib/WeatherVane/weathervane_params.c b/src/lib/WeatherVane/weathervane_params.c index c6b76fd284..80905ff36e 100644 --- a/src/lib/WeatherVane/weathervane_params.c +++ b/src/lib/WeatherVane/weathervane_params.c @@ -40,20 +40,12 @@ */ /** - * Enable weathervane for manual position control mode. + * Enable weathervane. * * @boolean * @group Multicopter Position Control */ -PARAM_DEFINE_INT32(WV_MAN_EN, 0); - -/** - * Enable weathervane for auto. - * - * @boolean - * @group Multicopter Position Control - */ -PARAM_DEFINE_INT32(WV_AUTO_EN, 0); +PARAM_DEFINE_INT32(WV_EN, 0); /** * Weather-vane roll angle to yawrate. diff --git a/src/modules/mc_pos_control/mc_pos_control_main.cpp b/src/modules/mc_pos_control/mc_pos_control_main.cpp index c633d574b9..ecefbd49e4 100644 --- a/src/modules/mc_pos_control/mc_pos_control_main.cpp +++ b/src/modules/mc_pos_control/mc_pos_control_main.cpp @@ -606,11 +606,10 @@ MulticopterPositionControl::task_main() // activate the weathervane controller if required. If activated a flighttask can use it to implement a yaw-rate control strategy // that turns the nose of the vehicle into the wind if (_wv_controller != nullptr) { - if (_control_mode.flag_control_manual_enabled && _control_mode.flag_control_attitude_enabled - && _wv_controller->manual_enabled()) { - _wv_controller->activate(); - } else if (_control_mode.flag_control_auto_enabled && _wv_controller->auto_enabled()) { + // in manual mode we just want to use weathervane if position is controlled as well + if (_wv_controller->weathervane_enabled() && !(_control_mode.flag_control_manual_enabled + && !_control_mode.flag_control_position_enabled)) { _wv_controller->activate(); } else {