From 90940c36727d4251d262cca8d751877766e4f362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Thu, 9 Sep 2021 22:03:45 +0200 Subject: [PATCH] mc_pos_control: switch to events --- .../MulticopterPositionControl.cpp | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/modules/mc_pos_control/MulticopterPositionControl.cpp b/src/modules/mc_pos_control/MulticopterPositionControl.cpp index 5308c87f3e..4597ce8f8b 100644 --- a/src/modules/mc_pos_control/MulticopterPositionControl.cpp +++ b/src/modules/mc_pos_control/MulticopterPositionControl.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include "PositionControl/ControlMath.hpp" using namespace matrix; @@ -138,13 +139,23 @@ int MulticopterPositionControl::parameters_update(bool force) if (_param_mpc_tiltmax_air.get() > MAX_SAFE_TILT_DEG) { _param_mpc_tiltmax_air.set(MAX_SAFE_TILT_DEG); _param_mpc_tiltmax_air.commit(); - mavlink_log_critical(&_mavlink_log_pub, "Tilt constrained to safe value"); + mavlink_log_critical(&_mavlink_log_pub, "Tilt constrained to safe value\t"); + /* EVENT + * @description MPC_TILTMAX_AIR is set to {1:.0}. + */ + events::send(events::ID("mc_pos_ctrl_tilt_set"), events::Log::Warning, + "Maximum tilt limit has been constrained to a safe value", MAX_SAFE_TILT_DEG); } if (_param_mpc_tiltmax_lnd.get() > _param_mpc_tiltmax_air.get()) { _param_mpc_tiltmax_lnd.set(_param_mpc_tiltmax_air.get()); _param_mpc_tiltmax_lnd.commit(); - mavlink_log_critical(&_mavlink_log_pub, "Land tilt has been constrained by max tilt"); + mavlink_log_critical(&_mavlink_log_pub, "Land tilt has been constrained by max tilt\t"); + /* EVENT + * @description MPC_TILTMAX_LND is set to {1:.0}. + */ + events::send(events::ID("mc_pos_ctrl_land_tilt_set"), events::Log::Warning, + "Land tilt limit has been constrained by maximum tilt", _param_mpc_tiltmax_air.get()); } _control.setPositionGains(Vector3f(_param_mpc_xy_p.get(), _param_mpc_xy_p.get(), _param_mpc_z_p.get())); @@ -158,13 +169,23 @@ int MulticopterPositionControl::parameters_update(bool force) if (_param_mpc_xy_cruise.get() > _param_mpc_xy_vel_max.get()) { _param_mpc_xy_cruise.set(_param_mpc_xy_vel_max.get()); _param_mpc_xy_cruise.commit(); - mavlink_log_critical(&_mavlink_log_pub, "Cruise speed has been constrained by max speed"); + mavlink_log_critical(&_mavlink_log_pub, "Cruise speed has been constrained by max speed\t"); + /* EVENT + * @description MPC_XY_CRUISE is set to {1:.0}. + */ + events::send(events::ID("mc_pos_ctrl_cruise_set"), events::Log::Warning, + "Cruise speed has been constrained by maximum speed", _param_mpc_xy_vel_max.get()); } if (_param_mpc_vel_manual.get() > _param_mpc_xy_vel_max.get()) { _param_mpc_vel_manual.set(_param_mpc_xy_vel_max.get()); _param_mpc_vel_manual.commit(); - mavlink_log_critical(&_mavlink_log_pub, "Manual speed has been constrained by max speed"); + mavlink_log_critical(&_mavlink_log_pub, "Manual speed has been constrained by max speed\t"); + /* EVENT + * @description MPC_VEL_MANUAL is set to {1:.0}. + */ + events::send(events::ID("mc_pos_ctrl_man_vel_set"), events::Log::Warning, + "Manual speed has been constrained by maximum speed", _param_mpc_xy_vel_max.get()); } if (_param_mpc_thr_hover.get() > _param_mpc_thr_max.get() || @@ -172,7 +193,12 @@ int MulticopterPositionControl::parameters_update(bool force) _param_mpc_thr_hover.set(math::constrain(_param_mpc_thr_hover.get(), _param_mpc_thr_min.get(), _param_mpc_thr_max.get())); _param_mpc_thr_hover.commit(); - mavlink_log_critical(&_mavlink_log_pub, "Hover thrust has been constrained by min/max"); + mavlink_log_critical(&_mavlink_log_pub, "Hover thrust has been constrained by min/max\t"); + /* EVENT + * @description MPC_THR_HOVER is set to {1:.0}. + */ + events::send(events::ID("mc_pos_ctrl_hover_thrust_set"), events::Log::Warning, + "Hover thrust has been constrained by min/max thrust", _param_mpc_thr_hover.get()); } if (!_param_mpc_use_hte.get() || !_hover_thrust_initialized) {