PX4 Firmware
PX4 Autopilot Software http://px4.io
state_machine_helper.h File Reference

State machine helper functions definitions. More...

Include dependency graph for state_machine_helper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef enum LOW_BAT_ACTION low_battery_action_t
 

Enumerations

enum  transition_result_t { TRANSITION_DENIED = -1, TRANSITION_NOT_CHANGED = 0, TRANSITION_CHANGED }
 
enum  link_loss_actions_t {
  link_loss_actions_t::DISABLED = 0, link_loss_actions_t::AUTO_LOITER = 1, link_loss_actions_t::AUTO_RTL = 2, link_loss_actions_t::AUTO_LAND = 3,
  link_loss_actions_t::AUTO_RECOVER = 4, link_loss_actions_t::TERMINATE = 5, link_loss_actions_t::LOCKDOWN = 6
}
 
enum  offboard_loss_actions_t {
  offboard_loss_actions_t::DISABLED = -1, offboard_loss_actions_t::AUTO_LAND = 0, offboard_loss_actions_t::AUTO_LOITER = 1, offboard_loss_actions_t::AUTO_RTL = 2,
  offboard_loss_actions_t::TERMINATE = 3, offboard_loss_actions_t::LOCKDOWN = 4
}
 
enum  offboard_loss_rc_actions_t {
  offboard_loss_rc_actions_t::DISABLED = -1, offboard_loss_rc_actions_t::MANUAL_POSITION = 0, offboard_loss_rc_actions_t::MANUAL_ALTITUDE = 1, offboard_loss_rc_actions_t::MANUAL_ATTITUDE = 2,
  offboard_loss_rc_actions_t::AUTO_RTL = 3, offboard_loss_rc_actions_t::AUTO_LAND = 4, offboard_loss_rc_actions_t::AUTO_LOITER = 5, offboard_loss_rc_actions_t::TERMINATE = 6,
  offboard_loss_rc_actions_t::LOCKDOWN = 7
}
 
enum  position_nav_loss_actions_t { position_nav_loss_actions_t::ALTITUDE_MANUAL = 0, position_nav_loss_actions_t::LAND_TERMINATE = 1 }
 
enum  LOW_BAT_ACTION { WARNING = 0, RETURN = 1, LAND = 2, RETURN_OR_LAND = 3 }
 

Functions

bool is_safe (const safety_s &safety, const actuator_armed_s &armed)
 
transition_result_t arming_state_transition (vehicle_status_s *status, const safety_s &safety, const arming_state_t new_arming_state, actuator_armed_s *armed, const bool fRunPreArmChecks, orb_advert_t *mavlink_log_pub, vehicle_status_flags_s *status_flags, const uint8_t arm_requirements, const hrt_abstime &time_since_boot)
 
transition_result_t main_state_transition (const vehicle_status_s &status, const main_state_t new_main_state, const vehicle_status_flags_s &status_flags, commander_state_s *internal_state)
 
void enable_failsafe (vehicle_status_s *status, bool old_failsafe, orb_advert_t *mavlink_log_pub, const char *reason)
 Enable failsafe and report to user. More...
 
bool set_nav_state (vehicle_status_s *status, actuator_armed_s *armed, commander_state_s *internal_state, orb_advert_t *mavlink_log_pub, const link_loss_actions_t data_link_loss_act, const bool mission_finished, const bool stay_in_failsafe, const vehicle_status_flags_s &status_flags, bool landed, const link_loss_actions_t rc_loss_act, const offboard_loss_actions_t offb_loss_act, const offboard_loss_rc_actions_t offb_loss_rc_act, const position_nav_loss_actions_t posctl_nav_loss_act)
 Check failsafe and main status and set navigation status for navigator accordingly. More...
 
bool check_invalid_pos_nav_state (vehicle_status_s *status, bool old_failsafe, orb_advert_t *mavlink_log_pub, const vehicle_status_flags_s &status_flags, const bool use_rc, const bool using_global_pos)
 
void battery_failsafe (orb_advert_t *mavlink_log_pub, const vehicle_status_s &status, const vehicle_status_flags_s &status_flags, commander_state_s *internal_state, const uint8_t battery_warning, const low_battery_action_t low_bat_action)
 

Variables

const char *const arming_state_names []
 

Detailed Description

State machine helper functions definitions.

Author
Thomas Gubler thoma.nosp@m.sgub.nosp@m.ler@s.nosp@m.tude.nosp@m.nt.et.nosp@m.hz.c.nosp@m.h
Julian Oes julia.nosp@m.n@oe.nosp@m.s.ch

Definition in file state_machine_helper.h.

Typedef Documentation

◆ low_battery_action_t

Enumeration Type Documentation

◆ link_loss_actions_t

enum link_loss_actions_t
strong
Enumerator
DISABLED 
AUTO_LOITER 
AUTO_RTL 
AUTO_LAND 
AUTO_RECOVER 
TERMINATE 
LOCKDOWN 

Definition at line 61 of file state_machine_helper.h.

◆ LOW_BAT_ACTION

Enumerator
WARNING 
RETURN 
LAND 
RETURN_OR_LAND 

Definition at line 128 of file state_machine_helper.h.

◆ offboard_loss_actions_t

Enumerator
DISABLED 
AUTO_LAND 
AUTO_LOITER 
AUTO_RTL 
TERMINATE 
LOCKDOWN 

Definition at line 71 of file state_machine_helper.h.

◆ offboard_loss_rc_actions_t

Enumerator
DISABLED 
MANUAL_POSITION 
MANUAL_ALTITUDE 
MANUAL_ATTITUDE 
AUTO_RTL 
AUTO_LAND 
AUTO_LOITER 
TERMINATE 
LOCKDOWN 

Definition at line 80 of file state_machine_helper.h.

◆ position_nav_loss_actions_t

Enumerator
ALTITUDE_MANUAL 
LAND_TERMINATE 

Definition at line 92 of file state_machine_helper.h.

◆ transition_result_t

Enumerator
TRANSITION_DENIED 
TRANSITION_NOT_CHANGED 
TRANSITION_CHANGED 

Definition at line 55 of file state_machine_helper.h.

Function Documentation

◆ arming_state_transition()

transition_result_t arming_state_transition ( vehicle_status_s status,
const safety_s safety,
const arming_state_t  new_arming_state,
actuator_armed_s armed,
const bool  fRunPreArmChecks,
orb_advert_t mavlink_log_pub,
vehicle_status_flags_s status_flags,
const uint8_t  arm_requirements,
const hrt_abstime time_since_boot 
)

◆ battery_failsafe()

void battery_failsafe ( orb_advert_t mavlink_log_pub,
const vehicle_status_s status,
const vehicle_status_flags_s status_flags,
commander_state_s internal_state,
const uint8_t  battery_warning,
const low_battery_action_t  low_bat_action 
)

Definition at line 1014 of file state_machine_helper.cpp.

References vehicle_status_flags_s::condition_global_position_valid, vehicle_status_flags_s::condition_home_position_valid, hrt_absolute_time(), LAND, commander_state_s::main_state, mavlink_log_critical, mavlink_log_emergency, RETURN, RETURN_OR_LAND, commander_state_s::timestamp, and WARNING.

Referenced by Commander::battery_status_check().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_invalid_pos_nav_state()

bool check_invalid_pos_nav_state ( vehicle_status_s status,
bool  old_failsafe,
orb_advert_t mavlink_log_pub,
const vehicle_status_flags_s status_flags,
const bool  use_rc,
const bool  using_global_pos 
)

Definition at line 724 of file state_machine_helper.cpp.

References vehicle_status_flags_s::condition_global_position_valid, vehicle_status_flags_s::condition_local_altitude_valid, vehicle_status_flags_s::condition_local_position_valid, vehicle_status_flags_s::condition_local_velocity_valid, enable_failsafe(), vehicle_status_s::nav_state, reason_no_global_position, reason_no_local_position, and vehicle_status_s::vehicle_type.

Referenced by set_nav_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enable_failsafe()

void enable_failsafe ( vehicle_status_s status,
bool  old_failsafe,
orb_advert_t mavlink_log_pub,
const char *  reason 
)

Enable failsafe and report to user.

Definition at line 391 of file state_machine_helper.cpp.

References vehicle_status_s::arming_state, vehicle_status_s::failsafe, and mavlink_log_critical.

Referenced by check_invalid_pos_nav_state(), and set_nav_state().

Here is the caller graph for this function:

◆ is_safe()

bool is_safe ( const safety_s safety,
const actuator_armed_s armed 
)

Definition at line 248 of file state_machine_helper.cpp.

References actuator_armed_s::armed, actuator_armed_s::lockdown, actuator_armed_s::manual_lockdown, safety_s::safety_off, and safety_s::safety_switch_available.

Referenced by commander_low_prio_loop(), and StateMachineHelperTest::isSafeTest().

Here is the caller graph for this function:

◆ main_state_transition()

◆ set_nav_state()

bool set_nav_state ( vehicle_status_s status,
actuator_armed_s armed,
commander_state_s internal_state,
orb_advert_t mavlink_log_pub,
const link_loss_actions_t  data_link_loss_act,
const bool  mission_finished,
const bool  stay_in_failsafe,
const vehicle_status_flags_s status_flags,
bool  landed,
const link_loss_actions_t  rc_loss_act,
const offboard_loss_actions_t  offb_loss_act,
const offboard_loss_rc_actions_t  offb_loss_rc_act,
const position_nav_loss_actions_t  posctl_nav_loss_act 
)

Variable Documentation

◆ arming_state_names

const char* const arming_state_names[]

Definition at line 77 of file state_machine_helper.cpp.

Referenced by arming_state_transition(), and print_status().