PX4 Firmware
PX4 Autopilot Software http://px4.io
|
State machine helper functions definitions. More...
#include <drivers/drv_hrt.h>
#include <uORB/uORB.h>
#include <uORB/topics/vehicle_status.h>
#include <uORB/topics/battery_status.h>
#include <uORB/topics/actuator_armed.h>
#include <uORB/topics/safety.h>
#include <uORB/topics/commander_state.h>
#include <uORB/topics/vehicle_status_flags.h>
Go to the source code of this file.
Typedefs | |
typedef enum LOW_BAT_ACTION | low_battery_action_t |
Variables | |
const char *const | arming_state_names [] |
State machine helper functions definitions.
Definition in file state_machine_helper.h.
typedef enum LOW_BAT_ACTION low_battery_action_t |
|
strong |
Enumerator | |
---|---|
DISABLED | |
AUTO_LOITER | |
AUTO_RTL | |
AUTO_LAND | |
AUTO_RECOVER | |
TERMINATE | |
LOCKDOWN |
Definition at line 61 of file state_machine_helper.h.
enum LOW_BAT_ACTION |
Enumerator | |
---|---|
WARNING | |
RETURN | |
LAND | |
RETURN_OR_LAND |
Definition at line 128 of file state_machine_helper.h.
|
strong |
Enumerator | |
---|---|
DISABLED | |
AUTO_LAND | |
AUTO_LOITER | |
AUTO_RTL | |
TERMINATE | |
LOCKDOWN |
Definition at line 71 of file state_machine_helper.h.
|
strong |
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.
|
strong |
Enumerator | |
---|---|
ALTITUDE_MANUAL | |
LAND_TERMINATE |
Definition at line 92 of file state_machine_helper.h.
enum transition_result_t |
Enumerator | |
---|---|
TRANSITION_DENIED | |
TRANSITION_NOT_CHANGED | |
TRANSITION_CHANGED |
Definition at line 55 of file state_machine_helper.h.
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 | ||
) |
Definition at line 106 of file state_machine_helper.cpp.
References PreFlightCheck::ARM_REQ_GPS_BIT, actuator_armed_s::armed, actuator_armed_s::armed_time_ms, vehicle_status_s::arming_state, arming_state_names, arming_transitions, vehicle_status_flags_s::condition_system_sensors_initialized, vehicle_status_s::hil_state, hrt_absolute_time(), hrt_elapsed_time(), last_preflight_check, actuator_armed_s::lockdown, mavlink_log_critical, PreFlightCheck::preArmCheck(), PreFlightCheck::preflightCheck(), actuator_armed_s::ready_to_arm, TRANSITION_CHANGED, TRANSITION_DENIED, and TRANSITION_NOT_CHANGED.
Referenced by arm_disarm(), StateMachineHelperTest::armingStateTransitionTest(), commander_low_prio_loop(), Commander::run(), and shutdown_if_allowed().
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().
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().
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().
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().
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 | ||
) |
Definition at line 260 of file state_machine_helper.cpp.
References vehicle_status_flags_s::condition_auto_mission_available, vehicle_status_flags_s::condition_global_position_valid, vehicle_status_flags_s::condition_home_position_valid, vehicle_status_flags_s::condition_local_altitude_valid, vehicle_status_flags_s::condition_local_position_valid, hrt_absolute_time(), commander_state_s::main_state, vehicle_status_flags_s::offboard_control_signal_lost, commander_state_s::timestamp, TRANSITION_CHANGED, TRANSITION_DENIED, TRANSITION_NOT_CHANGED, and vehicle_status_s::vehicle_type.
Referenced by commander_main(), Commander::handle_command(), StateMachineHelperTest::mainStateTransitionTest(), Commander::run(), set_link_loss_nav_state(), Commander::set_main_state_override_on(), and Commander::set_main_state_rc().
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.
Definition at line 403 of file state_machine_helper.cpp.
References vehicle_status_s::arming_state, check_invalid_pos_nav_state(), vehicle_status_s::data_link_lost, DISABLED, enable_failsafe(), vehicle_status_s::engine_failure, vehicle_status_s::failsafe, LAND_TERMINATE, commander_state_s::main_state, vehicle_status_s::mission_failure, vehicle_status_s::nav_state, vehicle_status_flags_s::offboard_control_loss_timeout, vehicle_status_flags_s::offboard_control_signal_lost, vehicle_status_s::rc_signal_lost, reason_no_datalink, reason_no_offboard, reason_no_rc, reason_no_rc_and_no_offboard, reset_link_loss_globals(), reset_offboard_loss_globals(), set_link_loss_nav_state(), set_offboard_loss_nav_state(), set_offboard_loss_rc_nav_state(), vehicle_status_s::vehicle_type, VEHICLE_TYPE_FIXED_WING, and vehicle_status_flags_s::vtol_transition_failure.
Referenced by Commander::run().
const char* const arming_state_names[] |
Definition at line 77 of file state_machine_helper.cpp.
Referenced by arming_state_transition(), and print_status().