44 #if USE_STABILIZATION_RATE
50 #include "generated/settings.h"
55 #if NO_GPS_NEEDED_FOR_NAV
56 #define GpsIsLost() FALSE
58 #define GpsIsLost() TRUE
66 #ifndef FAILSAFE_MODE_TOO_FAR_FROM_HOME
67 #define FAILSAFE_MODE_TOO_FAR_FROM_HOME AP_MODE_FAILSAFE
72 #define MODE_STARTUP AP_MODE_KILL
76 #ifndef UNLOCKED_HOME_MODE
77 #if MODE_AUTO1 == AP_MODE_HOME
78 #define UNLOCKED_HOME_MODE TRUE
79 PRINT_CONFIG_MSG(
"Enabled UNLOCKED_HOME_MODE since MODE_AUTO1 is AP_MODE_HOME")
80 #elif MODE_AUTO2 == AP_MODE_HOME
81 #define UNLOCKED_HOME_MODE TRUE
82 PRINT_CONFIG_MSG(
"Enabled UNLOCKED_HOME_MODE since MODE_AUTO2 is AP_MODE_HOME")
84 #define UNLOCKED_HOME_MODE FALSE
88 #if MODE_MANUAL == AP_MODE_NAV
89 #error "MODE_MANUAL mustn't be AP_MODE_NAV"
109 #define NAV_PRESCALER (PERIODIC_FREQUENCY / NAVIGATION_FREQUENCY)
141 #if FAILSAFE_GROUND_DETECT
142 INFO(
"Using FAILSAFE_GROUND_DETECT: KILL")
164 #ifndef KILL_AS_FAILSAFE
186 #ifdef COMMAND_THRUST
216 switch (new_autopilot_mode) {
218 #ifndef KILL_AS_FAILSAFE
236 #if USE_STABILIZATION_RATE
283 switch (new_autopilot_mode) {
285 #ifndef KILL_AS_FAILSAFE
292 #ifdef COMMAND_THRUST
350 #ifdef RADIO_AUTO_MODE
351 INFO(
"Using RADIO_AUTO_MODE to switch between AUTO1 and AUTO2.")
352 uint8_t new_autopilot_mode = ap_mode_of_two_switches();
354 #ifdef RADIO_MODE_2x3
355 uint8_t new_autopilot_mode = ap_mode_of_3x2way_switch();
389 #ifdef SetAutoCommandsFromRC
394 #ifdef SetCommandsFromRC
405 #define RC_LOST_MODE AP_MODE_FAILSAFE
419 #if FAILSAFE_ON_BAT_CRITICAL
429 #
if NO_GPS_LOST_WITH_RC_VALID
432 #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.
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)
struct ThrustSetpoint thrust_sp
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_mode_changed(uint8_t new_mode)
struct HorizontalGuidance guidance_h
struct StabilizationSetpoint guidance_h_run(bool in_flight)
#define GUIDANCE_H_MODE_NAV
#define GUIDANCE_H_MODE_HOVER
#define GUIDANCE_H_MODE_NONE
#define GUIDANCE_H_MODE_GUIDED
void guidance_v_set_vz(float vz)
Set z velocity setpoint.
void guidance_v_mode_changed(uint8_t new_mode)
struct ThrustSetpoint guidance_v_run(bool in_flight)
Guidance vertical run functions.
#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.
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...
struct Stabilization stabilization
void stabilization_mode_changed(uint8_t new_mode, uint8_t submode)
Check mode change.
void stabilization_run(bool in_flight, struct StabilizationSetpoint *sp, struct ThrustSetpoint *thrust, int32_t *cmd)
Call default stabilization control.
struct StabilizationSetpoint stabilization_get_failsafe_sp(void)
Get stabilization setpoint for failsafe.
General stabilization interface for rotorcrafts.
#define STABILIZATION_ATT_SUBMODE_CARE_FREE
#define STABILIZATION_MODE_ATTITUDE
#define STABILIZATION_ATT_SUBMODE_HEADING
Stabilization sub-modes for attitude.
#define STABILIZATION_ATT_SUBMODE_FORWARD
struct StabilizationSetpoint rc_sp
Keep it ? FIXME.
int32_t cmd[COMMANDS_NB]
output command vector, range from [-MAX_PPRZ:MAX_PPRZ] (store for messages)
#define STABILIZATION_MODE_RATE
#define STABILIZATION_MODE_DIRECT
#define STABILIZATION_MODE_NONE
Stabilization modes.
Rate stabilization for rotorcrafts.
Thrust setpoint // TODO to a setpoint header Structure to store the desired thrust vector with differ...
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.