34 #ifndef COMMANDER_HPP_ 35 #define COMMANDER_HPP_ 42 #include <px4_platform_common/module.h> 43 #include <px4_platform_common/module_params.h> 76 class Commander :
public ModuleBase<Commander>,
public ModuleParams
82 static int task_spawn(
int argc,
char *argv[]);
85 static Commander *instantiate(
int argc,
char *argv[]);
88 static int custom_command(
int argc,
char *argv[]);
91 static int print_usage(
const char *reason =
nullptr);
99 static bool preflight_check(
bool report);
101 void get_circuit_breaker_params();
107 (ParamInt<px4::params::NAV_DLL_ACT>) _param_nav_dll_act,
108 (ParamInt<px4::params::COM_DL_LOSS_T>) _param_com_dl_loss_t,
110 (ParamInt<px4::params::COM_HLDL_LOSS_T>) _param_com_hldl_loss_t,
111 (ParamInt<px4::params::COM_HLDL_REG_T>) _param_com_hldl_reg_t,
113 (ParamInt<px4::params::NAV_RCL_ACT>) _param_nav_rcl_act,
114 (ParamFloat<px4::params::COM_RC_LOSS_T>) _param_com_rc_loss_t,
116 (ParamFloat<px4::params::COM_HOME_H_T>) _param_com_home_h_t,
117 (ParamFloat<px4::params::COM_HOME_V_T>) _param_com_home_v_t,
119 (ParamFloat<px4::params::COM_POS_FS_EPH>) _param_com_pos_fs_eph,
120 (ParamFloat<px4::params::COM_POS_FS_EPV>) _param_com_pos_fs_epv,
121 (ParamFloat<px4::params::COM_VEL_FS_EVH>) _param_com_vel_fs_evh,
122 (ParamInt<px4::params::COM_POSCTL_NAVL>) _param_com_posctl_navl,
124 (ParamInt<px4::params::COM_POS_FS_DELAY>) _param_com_pos_fs_delay,
125 (ParamInt<px4::params::COM_POS_FS_PROB>) _param_com_pos_fs_prob,
126 (ParamInt<px4::params::COM_POS_FS_GAIN>) _param_com_pos_fs_gain,
128 (ParamInt<px4::params::COM_LOW_BAT_ACT>) _param_com_low_bat_act,
129 (ParamFloat<px4::params::COM_DISARM_LAND>) _param_com_disarm_land,
130 (ParamFloat<px4::params::COM_DISARM_PRFLT>) _param_com_disarm_preflight,
132 (ParamInt<px4::params::COM_OBS_AVOID>) _param_com_obs_avoid,
133 (ParamInt<px4::params::COM_OA_BOOT_T>) _param_com_oa_boot_t,
135 (ParamInt<px4::params::COM_FLT_PROFILE>) _param_com_flt_profile,
138 (ParamFloat<px4::params::COM_OF_LOSS_T>) _param_com_of_loss_t,
139 (ParamInt<px4::params::COM_OBL_ACT>) _param_com_obl_act,
140 (ParamInt<px4::params::COM_OBL_RC_ACT>) _param_com_obl_rc_act,
142 (ParamInt<px4::params::COM_PREARM_MODE>) _param_com_prearm_mode,
143 (ParamInt<px4::params::COM_MOT_TEST_EN>) _param_com_mot_test_en,
145 (ParamFloat<px4::params::COM_KILL_DISARM>) _param_com_kill_disarm,
147 (ParamInt<px4::params::CBRK_SUPPLY_CHK>) _param_cbrk_supply_chk,
148 (ParamInt<px4::params::CBRK_USB_CHK>) _param_cbrk_usb_chk,
149 (ParamInt<px4::params::CBRK_AIRSPD_CHK>) _param_cbrk_airspd_chk,
150 (ParamInt<px4::params::CBRK_ENGINEFAIL>) _param_cbrk_enginefail,
151 (ParamInt<px4::params::CBRK_GPSFAIL>) _param_cbrk_gpsfail,
152 (ParamInt<px4::params::CBRK_FLIGHTTERM>) _param_cbrk_flightterm,
153 (ParamInt<px4::params::CBRK_VELPOSERR>) _param_cbrk_velposerr
156 enum class PrearmedMode {
162 const int64_t POSVEL_PROBATION_MIN = 1_s;
163 const int64_t POSVEL_PROBATION_MAX = 100_s;
177 bool _nav_test_passed{
false};
178 bool _nav_test_failed{
false};
180 bool _geofence_loiter_on{
false};
181 bool _geofence_rtl_on{
false};
182 bool _geofence_warning_action_on{
false};
183 bool _geofence_violated_prev{
false};
186 bool _flight_termination_triggered{
false};
193 bool set_home_position();
194 bool set_home_position_alt_only();
205 void update_control_mode();
207 void check_valid(
const hrt_abstime ×tamp,
const hrt_abstime &timeout,
const bool valid_in,
bool *valid_out,
210 bool check_posvel_validity(
const bool data_valid,
const float data_accuracy,
const float required_accuracy,
212 bool *validity_changed);
214 void reset_posvel_validity(
bool *changed);
218 void estimator_check(
bool *status_changed);
220 void offboard_control_update(
bool &status_changed);
222 void battery_status_check();
229 void data_link_check(
bool &status_changed);
236 bool _onboard_controller_lost{
false};
239 bool _avoidance_system_lost{
false};
241 bool _avoidance_system_status_change{
false};
242 uint8_t _datalink_last_status_avoidance_system{telemetry_status_s::MAV_STATE_UNINIT};
249 int _last_esc_online_flags{-1};
252 uint8_t _battery_warning{battery_status_s::BATTERY_WARNING_NONE};
253 float _battery_current{0.0f};
258 bool _print_avoidance_msg_once{
false};
constexpr _Tp constrain(_Tp val, _Tp min_val, _Tp max_val)
FailureDetector _failure_detector
Base class for failure detection logic based on vehicle states for failsafe triggering.
static struct vehicle_status_s status
State machine helper functions definitions.
static void print_usage()
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
static struct actuator_armed_s armed
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
Hysteresis of a boolean value.
DEFINE_PARAMETERS((ParamInt< px4::params::NAV_DLL_ACT >) _param_nav_dll_act,(ParamInt< px4::params::COM_DL_LOSS_T >) _param_com_dl_loss_t,(ParamInt< px4::params::COM_HLDL_LOSS_T >) _param_com_hldl_loss_t,(ParamInt< px4::params::COM_HLDL_REG_T >) _param_com_hldl_reg_t,(ParamInt< px4::params::NAV_RCL_ACT >) _param_nav_rcl_act,(ParamFloat< px4::params::COM_RC_LOSS_T >) _param_com_rc_loss_t,(ParamFloat< px4::params::COM_HOME_H_T >) _param_com_home_h_t,(ParamFloat< px4::params::COM_HOME_V_T >) _param_com_home_v_t,(ParamFloat< px4::params::COM_POS_FS_EPH >) _param_com_pos_fs_eph,(ParamFloat< px4::params::COM_POS_FS_EPV >) _param_com_pos_fs_epv,(ParamFloat< px4::params::COM_VEL_FS_EVH >) _param_com_vel_fs_evh,(ParamInt< px4::params::COM_POSCTL_NAVL >) _param_com_posctl_navl,(ParamInt< px4::params::COM_POS_FS_DELAY >) _param_com_pos_fs_delay,(ParamInt< px4::params::COM_POS_FS_PROB >) _param_com_pos_fs_prob,(ParamInt< px4::params::COM_POS_FS_GAIN >) _param_com_pos_fs_gain,(ParamInt< px4::params::COM_LOW_BAT_ACT >) _param_com_low_bat_act,(ParamFloat< px4::params::COM_DISARM_LAND >) _param_com_disarm_land,(ParamFloat< px4::params::COM_DISARM_PRFLT >) _param_com_disarm_preflight,(ParamInt< px4::params::COM_OBS_AVOID >) _param_com_obs_avoid,(ParamInt< px4::params::COM_OA_BOOT_T >) _param_com_oa_boot_t,(ParamInt< px4::params::COM_FLT_PROFILE >) _param_com_flt_profile,(ParamFloat< px4::params::COM_OF_LOSS_T >) _param_com_of_loss_t,(ParamInt< px4::params::COM_OBL_ACT >) _param_com_obl_act,(ParamInt< px4::params::COM_OBL_RC_ACT >) _param_com_obl_rc_act,(ParamInt< px4::params::COM_PREARM_MODE >) _param_com_prearm_mode,(ParamInt< px4::params::COM_MOT_TEST_EN >) _param_com_mot_test_en,(ParamFloat< px4::params::COM_KILL_DISARM >) _param_com_kill_disarm,(ParamInt< px4::params::CBRK_SUPPLY_CHK >) _param_cbrk_supply_chk,(ParamInt< px4::params::CBRK_USB_CHK >) _param_cbrk_usb_chk,(ParamInt< px4::params::CBRK_AIRSPD_CHK >) _param_cbrk_airspd_chk,(ParamInt< px4::params::CBRK_ENGINEFAIL >) _param_cbrk_enginefail,(ParamInt< px4::params::CBRK_GPSFAIL >) _param_cbrk_gpsfail,(ParamInt< px4::params::CBRK_FLIGHTTERM >) _param_cbrk_flightterm,(ParamInt< px4::params::CBRK_VELPOSERR >) _param_cbrk_velposerr) enum class PrearmedMode