45 #if USE_STABILIZATION_RATE
51 #include "generated/settings.h"
56 #if NO_GPS_NEEDED_FOR_NAV
57 #define GpsIsLost() FALSE
59 #define GpsIsLost() TRUE
67 #ifndef FAILSAFE_MODE_TOO_FAR_FROM_HOME
68 #define FAILSAFE_MODE_TOO_FAR_FROM_HOME AP_MODE_FAILSAFE
73 #define MODE_STARTUP AP_MODE_KILL
77 #ifndef UNLOCKED_HOME_MODE
78 #if MODE_AUTO1 == AP_MODE_HOME
79 #define UNLOCKED_HOME_MODE TRUE
80 PRINT_CONFIG_MSG(
"Enabled UNLOCKED_HOME_MODE since MODE_AUTO1 is AP_MODE_HOME")
81 #elif MODE_AUTO2 == AP_MODE_HOME
82 #define UNLOCKED_HOME_MODE TRUE
83 PRINT_CONFIG_MSG(
"Enabled UNLOCKED_HOME_MODE since MODE_AUTO2 is AP_MODE_HOME")
85 #define UNLOCKED_HOME_MODE FALSE
89 #if MODE_MANUAL == AP_MODE_NAV
90 #error "MODE_MANUAL mustn't be AP_MODE_NAV"
110 #define NAV_PRESCALER (PERIODIC_FREQUENCY / NAVIGATION_FREQUENCY)
142 #if FAILSAFE_GROUND_DETECT
143 INFO(
"Using FAILSAFE_GROUND_DETECT: KILL")
196 switch (new_autopilot_mode) {
198 #ifndef KILL_AS_FAILSAFE
213 #if USE_STABILIZATION_RATE
241 #ifdef GUIDANCE_H_MODE_MODULE_SETTING
255 switch (new_autopilot_mode) {
257 #ifndef KILL_AS_FAILSAFE
293 #ifdef GUIDANCE_V_MODE_MODULE_SETTING
328 #ifdef RADIO_AUTO_MODE
329 INFO(
"Using RADIO_AUTO_MODE to switch between AUTO1 and AUTO2.")
330 uint8_t new_autopilot_mode = ap_mode_of_two_switches();
332 #ifdef RADIO_MODE_2x3
333 uint8_t new_autopilot_mode = ap_mode_of_3x2way_switch();
367 #ifdef SetAutoCommandsFromRC
372 #ifdef SetCommandsFromRC
386 #define RC_LOST_MODE AP_MODE_FAILSAFE
402 #if FAILSAFE_ON_BAT_CRITICAL
412 #
if NO_GPS_LOST_WITH_RC_VALID
415 #ifdef NO_GPS_LOST_WITH_DATALINK_TIME
bool autopilot_set_mode(uint8_t new_autopilot_mode)
set autopilot mode
uint8_t autopilot_get_mode(void)
get autopilot mode
void autopilot_set_in_flight(bool in_flight)
set in_flight flag
bool autopilot_set_motors_on(bool motors_on)
turn motors on/off, eventually depending of the current mode set kill_throttle accordingly FIXME is i...
struct pprz_autopilot autopilot
Global autopilot structure.
bool autopilot_get_motors_on(void)
get motors status
bool autopilot_in_flight(void)
get in_flight flag
Core autopilot interface common to all firmwares.
bool motors_on
motor status
bool ground_detected
automatic detection of landing
pprz_t throttle
throttle level as will be displayed in GCS
bool detect_ground_once
enable automatic detection of ground (one shot)
bool kill_throttle
allow autopilot to use throttle
uint8_t mode
current autopilot mode
bool in_flight
in flight status
Arming procedure for rotorcraft Several options can be selected:
static void autopilot_arming_set(bool motors_on)
static void autopilot_arming_check_motors_on(void)
State machine to check if motors should be turned ON or OFF using the kill switch.
static void autopilot_arming_init(void)
Autopilot guided mode interface.
const pprz_t commands_failsafe[COMMANDS_NB]
pprz_t commands[COMMANDS_NB]
Hardware independent code for commands handling.
#define GUIDANCE_V_MODE_MODULE_SETTING
#define GUIDANCE_H_MODE_MODULE_SETTING
uint16_t datalink_time
time in seconds since last datalink message was received
struct Electrical electrical
Interface for electrical status: supply voltage, current, battery status, etc.
bool bat_critical
battery critical status
void autopilot_static_init(void)
Static autopilot API.
void autopilot_static_periodic(void)
void autopilot_static_SetModeHandler(float new_autopilot_mode)
void autopilot_static_set_motors_on(bool motors_on)
void autopilot_failsafe_checks(void)
Failsafe checks.
void autopilot_static_on_rc_frame(void)
Function to be called when a message from FBW is available.
void autopilot_static_set_mode(uint8_t new_autopilot_mode)
Device independent GPS code (interface)
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
Hardware independent API for actuators (servos, motor controllers).
void nav_home(void)
Home mode navigation (circle around HOME)
void nav_periodic_task(void)
Navigation main: call to the code generated from the XML flight plan.
Optional exceptions triggeringg HOME_MODE 1) GEOFENCE_DATALINK_LOST_TIME: go to HOME mode if datalink...
static bool higher_than_max_altitude(void)
static bool datalink_lost(void)
struct RadioControl radio_control
Generic interface for radio control modules.
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
static bool kill_switch_is_on(void)
#define FAILSAFE_MODE_TOO_FAR_FROM_HOME
Mode that is set when the plane is really too far from home.
#define RC_LOST_MODE
mode to enter when RC is lost while using a mode with RC input (not AP_MODE_NAV)
#define UNLOCKED_HOME_MODE
#define AP_MODE_HOVER_DIRECT
#define AP_MODE_RATE_DIRECT
#define AP_MODE_RATE_RC_CLIMB
#define AP_MODE_HOVER_CLIMB
#define AP_MODE_HOVER_Z_HOLD
#define AP_MODE_RC_DIRECT
#define AP_MODE_ATTITUDE_DIRECT
#define AP_MODE_ATTITUDE_CLIMB
#define AP_MODE_ATTITUDE_Z_HOLD
#define MODE_MANUAL
Default RC mode.
#define AP_MODE_KILL
Static autopilot modes.
#define AP_MODE_ATTITUDE_RC_CLIMB
#define AP_MODE_RATE_Z_HOLD
#define AP_MODE_CARE_FREE_DIRECT
uint8_t ap_mode_of_3way_switch(void)
get autopilot mode as set by RADIO_MODE 3-way switch
#define SetRotorcraftCommands(_cmd, _in_flight, _motors_on)
#define FAILSAFE_DESCENT_SPEED
Set descent speed in failsafe mode.
void guidance_h_read_rc(bool in_flight)
void guidance_h_mode_changed(uint8_t new_mode)
void guidance_h_run(bool in_flight)
#define GUIDANCE_H_MODE_FORWARD
#define GUIDANCE_H_MODE_NAV
#define GUIDANCE_H_MODE_HOVER
#define GUIDANCE_H_MODE_ATTITUDE
#define GUIDANCE_H_MODE_GUIDED
#define GUIDANCE_H_MODE_RC_DIRECT
#define GUIDANCE_H_MODE_CARE_FREE
#define GUIDANCE_H_MODE_KILL
#define GUIDANCE_H_MODE_RATE
#define GUIDANCE_H_MODE_FLIP
void guidance_v_read_rc(void)
void guidance_v_set_vz(float vz)
Set z velocity setpoint.
void guidance_v_run(bool in_flight)
void guidance_v_mode_changed(uint8_t new_mode)
#define GUIDANCE_V_MODE_FLIP
#define GUIDANCE_V_MODE_CLIMB
#define GUIDANCE_V_MODE_RC_CLIMB
#define GUIDANCE_V_MODE_KILL
#define GUIDANCE_V_MODE_RC_DIRECT
#define GUIDANCE_V_MODE_NAV
#define GUIDANCE_V_MODE_HOVER
#define GUIDANCE_V_MODE_GUIDED
void compute_dist2_to_home(void)
Computes squared distance to the HOME waypoint potentially sets too_far_from_home.
struct RotorcraftNavigation nav
Rotorcraft navigation functions.
float dist2_to_home
squared distance to home waypoint
float failsafe_mode_dist2
maximum squared distance to home wp before going to failsafe mode
bool too_far_from_home
too_far flag
General attitude stabilization interface for rotorcrafts.
void stabilization_attitude_set_failsafe_setpoint(void)
Persistent settings interface.
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
General stabilization interface for rotorcrafts.
Dummy stabilization for rotorcrafts.
Rate stabilization for rotorcrafts.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.