44 #if USE_STABILIZATION_RATE
51 #include "generated/settings.h"
56 #if NO_GPS_NEEDED_FOR_NAV
57 #define GpsIsLost() FALSE
59 #define GpsIsLost() TRUE
63 #if USE_KILL_SWITCH_FOR_MOTOR_ARMING
66 #elif USE_THROTTLE_FOR_MOTOR_ARMING
78 #ifndef FAILSAFE_MODE_TOO_FAR_FROM_HOME
79 #define FAILSAFE_MODE_TOO_FAR_FROM_HOME AP_MODE_FAILSAFE
84 #define MODE_STARTUP AP_MODE_KILL
88 #ifndef UNLOCKED_HOME_MODE
89 #if MODE_AUTO1 == AP_MODE_HOME
90 #define UNLOCKED_HOME_MODE TRUE
91 PRINT_CONFIG_MSG(
"Enabled UNLOCKED_HOME_MODE since MODE_AUTO1 is AP_MODE_HOME")
92 #elif MODE_AUTO2 == AP_MODE_HOME
93 #define UNLOCKED_HOME_MODE TRUE
94 PRINT_CONFIG_MSG(
"Enabled UNLOCKED_HOME_MODE since MODE_AUTO2 is AP_MODE_HOME")
96 #define UNLOCKED_HOME_MODE FALSE
100 #if MODE_MANUAL == AP_MODE_NAV
101 #error "MODE_MANUAL mustn't be AP_MODE_NAV"
121 #define NAV_PRESCALER (PERIODIC_FREQUENCY / NAV_FREQ)
153 #if FAILSAFE_GROUND_DETECT
154 INFO(
"Using FAILSAFE_GROUND_DETECT: KILL")
212 switch (new_autopilot_mode) {
214 #ifndef KILL_AS_FAILSAFE
229 #if USE_STABILIZATION_RATE
257 #ifdef GUIDANCE_H_MODE_MODULE_SETTING
271 switch (new_autopilot_mode) {
273 #ifndef KILL_AS_FAILSAFE
309 #ifdef GUIDANCE_V_MODE_MODULE_SETTING
344 #ifdef RADIO_AUTO_MODE
345 INFO(
"Using RADIO_AUTO_MODE to switch between AUTO1 and AUTO2.")
346 uint8_t new_autopilot_mode = ap_mode_of_two_switches();
348 #ifdef RADIO_MODE_2x3
349 uint8_t new_autopilot_mode = ap_mode_of_3x2way_switch();
385 #ifdef SetAutoCommandsFromRC
390 #ifdef SetCommandsFromRC
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.
#define GUIDANCE_H_MODE_GUIDED
#define GUIDANCE_V_MODE_NAV
void guidance_h_read_rc(bool in_flight)
#define GUIDANCE_H_MODE_CARE_FREE
#define AP_MODE_RATE_DIRECT
Rotorcraft navigation functions.
#define AP_MODE_KILL
Static autopilot modes.
float failsafe_mode_dist2
maximum squared distance to home wp before going to failsafe mode
uint8_t ap_mode_of_3way_switch(void)
get autopilot mode as set by RADIO_MODE 3-way switch
Dummy stabilization for rotorcrafts.
General attitude stabilization interface for rotorcrafts.
void guidance_h_run(bool in_flight)
#define AP_MODE_HOVER_DIRECT
#define AP_MODE_RATE_Z_HOLD
#define FAILSAFE_DESCENT_SPEED
Set descent speed in failsafe mode.
bool in_flight
in flight status
float dist2_to_home
squared distance to home waypoint
#define GUIDANCE_H_MODE_HOVER
void guidance_v_mode_changed(uint8_t new_mode)
void nav_home(void)
Home mode navigation (circle around HOME)
void autopilot_static_SetModeHandler(float new_autopilot_mode)
#define AP_MODE_RATE_RC_CLIMB
Autopilot guided mode interface.
void guidance_v_run(bool in_flight)
static bool kill_switch_is_on(void)
#define GUIDANCE_H_MODE_ATTITUDE
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define GUIDANCE_V_MODE_KILL
struct pprz_autopilot autopilot
Global autopilot structure.
const pprz_t commands_failsafe[COMMANDS_NB]
#define GUIDANCE_H_MODE_FLIP
void autopilot_static_set_mode(uint8_t new_autopilot_mode)
Rate stabilization for rotorcrafts.
#define AP_MODE_ATTITUDE_RC_CLIMB
bool ap_ahrs_is_aligned(void)
Display descent speed in failsafe mode if needed.
Automatically arm the motors when applying throttle.
#define MODE_MANUAL
Default RC mode.
Hardware independent API for actuators (servos, motor controllers).
#define AP_MODE_ATTITUDE_CLIMB
#define UNLOCKED_HOME_MODE
bool detect_ground_once
enable automatic detection of ground (one shot)
Some helper functions to check RC sticks.
Arm the motors using a switch.
void autopilot_static_on_rc_frame(void)
Function to be called when a message from FBW is available.
Interface for electrical status: supply voltage, current, battery status, etc.
void autopilot_static_periodic(void)
bool autopilot_in_flight(void)
get in_flight flag
static bool higher_than_max_altitude(void)
Device independent GPS code (interface)
void compute_dist2_to_home(void)
Computes squared distance to the HOME waypoint potentially sets too_far_from_home.
#define AP_MODE_HOVER_Z_HOLD
#define GUIDANCE_V_MODE_CLIMB
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
void stabilization_attitude_set_failsafe_setpoint(void)
static void autopilot_arming_init(void)
static bool datalink_lost(void)
#define AP_MODE_RC_DIRECT
#define GUIDANCE_V_MODE_HOVER
Hardware independent code for commands handling.
struct RadioControl radio_control
void guidance_h_mode_changed(uint8_t new_mode)
#define GUIDANCE_H_MODE_MODULE_SETTING
#define GUIDANCE_H_MODE_FORWARD
Optional exceptions triggeringg HOME_MODE 1) GEOFENCE_DATALINK_LOST_TIME: go to HOME mode if datalink...
Arm the motors by with max yaw stick.
void autopilot_static_init(void)
Static autopilot API.
Core autopilot interface common to all firmwares.
bool motors_on
motor status
pprz_t commands[COMMANDS_NB]
Storage of intermediate command values.
void autopilot_static_set_motors_on(bool motors_on)
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...
#define AP_MODE_HOVER_CLIMB
#define GUIDANCE_H_MODE_NAV
General stabilization interface for rotorcrafts.
void guidance_v_read_rc(void)
#define FAILSAFE_MODE_TOO_FAR_FROM_HOME
Mode that is set when the plane is really too far from home.
void autopilot_set_motors_on(bool motors_on)
turn motors on/off, eventually depending of the current mode set kill_throttle accordingly FIXME is i...
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
#define GUIDANCE_V_MODE_FLIP
int32_t guidance_v_zd_sp
vertical speed setpoint in meter/s (input).
#define SPEED_BFP_OF_REAL(_af)
#define AP_MODE_ATTITUDE_DIRECT
#define GUIDANCE_V_MODE_RC_CLIMB
void nav_periodic_task(void)
Navigation main: call to the code generated from the XML flight plan.
void autopilot_set_in_flight(bool in_flight)
set in_flight flag
bool kill_throttle
allow autopilot to use throttle
#define GUIDANCE_V_MODE_RC_DIRECT
bool ground_detected
automatic detection of landing
#define AP_MODE_CARE_FREE_DIRECT
#define GUIDANCE_H_MODE_RATE
#define AP_MODE_ATTITUDE_Z_HOLD
#define GUIDANCE_V_MODE_MODULE_SETTING
#define GUIDANCE_V_MODE_GUIDED
uint8_t mode
current autopilot mode
#define SetRotorcraftCommands(_cmd, _in_flight, _motors_on)
#define GUIDANCE_H_MODE_KILL
#define GUIDANCE_H_MODE_RC_DIRECT