37 #include "generated/flight_plan.h"
49 #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
59 #define RC_LOST_MODE AP_MODE_HOME
64 #ifdef AHRS_TRIGGERED_ATTITUDE_LOOP
68 static void new_att_cb(
uint8_t sender_id __attribute__((unused)),
69 uint32_t stamp __attribute__((unused)),
70 struct Int32Rates *gyro __attribute__((unused)))
98 #ifdef AHRS_TRIGGERED_ATTITUDE_LOOP
99 AbiBindMsgIMU_GYRO_INT32(
ABI_BROADCAST, &new_att_ev, &new_att_cb);
118 uint8_t rc_lost_while_in_use = bit_is_set(imcu_get_status(), STATUS_RADIO_REALLY_LOST) &&
122 if (rc_lost_while_in_use) {
126 #ifdef RADIO_KILL_SWITCH
139 if (bit_is_set(imcu_get_status(), AVERAGED_CHANNELS_SENT)) {
141 mode_changed |= pprz_mode_changed;
142 #if defined RADIO_CALIB && defined RADIO_CONTROL_SETTINGS
144 bool calib_mode_changed = RcSettingsModeUpdate(
fbw_state->channels);
146 rc_settings(calib_mode_changed || pprz_mode_changed);
147 mode_changed |= calib_mode_changed;
153 #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
163 #if H_CTL_YAW_LOOP && defined RADIO_YAW
177 #endif // RADIO_CONTROL
214 #ifdef FAILSAFE_DELAY_WITHOUT_GPS
215 #define GpsTimeoutError (sys_time.nb_sec - gps.last_3dfix_time > FAILSAFE_DELAY_WITHOUT_GPS)
223 #if defined FAILSAFE_DELAY_WITHOUT_GPS
230 if (GpsTimeoutError) {
259 #if DOWNLINK && !defined PERIOD_NAVIGATION_Ap_0 // If not sent periodically (in default 0 mode)
272 #ifdef H_CTL_RATE_LOOP
289 #if CTRL_VERTICAL_LANDING
302 #if CTRL_VERTICAL_LANDING
306 #if defined V_CTL_THROTTLE_IDLE
310 #ifdef V_CTL_POWER_CTL_BAT_NOMINAL
335 #if defined MCU_SPI_LINK || defined MCU_UART_LINK || defined MCU_CAN_LINK
337 #elif defined INTER_MCU && defined SINGLE_MCU
348 #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
357 #ifndef RADIO_AUTO_MODE
360 INFO(
"Using RADIO_AUTO_MODE to switch between AUTO1 and AUTO2.")
375 #endif // RADIO_AUTO_MODE
380 #else // not RADIO_CONTROL
389 uint8_t new_status = imcu_get_status();
391 bool changed = ((
mcu1_status & MASK_FBW_CHANGED) != (new_status & MASK_FBW_CHANGED));
405 #ifdef SetAutoCommandsFromRC
407 #elif defined RADIO_YAW && defined COMMAND_YAW
static void copy_from_to_fbw(void)
Send back uncontrolled channels.
Event structure to store callbacks in a linked list.
bool launch
request launch
uint8_t mcu1_status
Second MCU status (FBW part)
#define AP_COMMAND_SET_PITCH(_pitch)
void h_ctl_course_loop(void)
Communication between fbw and ap processes.
#define AP_COMMAND_SET_CL(_cl)
static uint8_t mcu1_status_update(void)
void h_ctl_attitude_loop(void)
pprz_t v_ctl_throttle_setpoint
#define RC_LOST_MODE
mode to enter when RC is lost in AP_MODE_MANUAL or AP_MODE_AUTO1
#define THROTTLE_THRESHOLD_TAKEOFF
Takeoff detection threshold from throttle.
Main include for ABI (AirBorneInterface).
#define PPRZ_MUTEX_LOCK(_mtx)
uint16_t flight_time
flight time in seconds
void nav_home(void)
Home mode navigation (circle around HOME)
void autopilot_static_SetModeHandler(float new_autopilot_mode)
void navigation_task(void)
Compute desired_course.
float vsupply
supply voltage in V
volatile bool inter_mcu_received_ap
#define V_CTL_MODE_AUTO_THROTTLE
bool autopilot_set_mode(uint8_t new_autopilot_mode)
set autopilot mode
pprz_t h_ctl_elevator_setpoint
pprz_t h_ctl_aileron_setpoint
void v_ctl_throttle_slew(void)
Computes slewed throttle from throttle setpoint called at 20Hz.
void v_ctl_climb_loop(void)
Auto-throttle inner loop.
#define AP_COMMAND_SET_ROLL(_roll)
AP command setter macros for usual commands.
struct fbw_state * fbw_state
struct pprz_autopilot autopilot
Global autopilot structure.
float v_ctl_pitch_setpoint
struct ap_state * ap_state
void autopilot_static_set_mode(uint8_t new_autopilot_mode)
Fixed wing horizontal control.
#define LATERAL_MODE_COURSE
#define AP_MODE_MANUAL
AP modes.
#define UNLOCKED_HOME_MODE
static uint8_t mcu1_ppm_cpt
void WEAK autopilot_send_mode(void)
send autopilot mode actual implementation is firmware dependent
void common_nav_periodic_task_4Hz()
#define V_CTL_MODE_AUTO_ALT
void autopilot_static_on_rc_frame(void)
Function to be called when a message from FBW is available.
Common transport functions for the communication between FBW and AP.
void autopilot_static_periodic(void)
void rc_settings(bool mode_changed)
Includes generated code from tuning_rc.xml.
static bool higher_than_max_altitude(void)
Device independent GPS code (interface)
void autopilot_set_kill_throttle(bool kill)
set kill throttle
static bool datalink_lost(void)
static uint8_t pprz_mode_update(void)
Update paparazzi mode.
#define FLOAT_OF_PPRZ(pprz, center, travel)
pprz_t to float with saturation
#define LATERAL_MODE_MANUAL
void WEAK autopilot_event(void)
AP event call.
Optional exceptions triggeringg HOME_MODE 1) GEOFENCE_DATALINK_LOST_TIME: go to HOME mode if datalink...
#define V_CTL_MODE_AUTO_CLIMB
void autopilot_static_init(void)
Static autopilot API.
void v_ctl_landing_loop(void)
Core autopilot interface common to all firmwares.
float h_ctl_pitch_setpoint
#define SEND_NAVIGATION(_trans, _dev)
bool motors_on
motor status
void autopilot_static_set_motors_on(bool motors_on)
API to get/set the generic vehicle states.
volatile uint8_t new_ins_attitude
float h_ctl_roll_setpoint
float nav_pitch
with INT32_ANGLE_FRAC
void nav_without_gps(void)
Failsafe navigation without position estimation.
#define AP_MODE_GPS_OUT_OF_ORDER
#define AP_MODE_OF_PULSE(pprz)
Get mode from pulse.
Common code for AP and FBW telemetry.
#define ABI_BROADCAST
Broadcast address.
#define AP_COMMAND_SET_THROTTLE(_throttle)
void nav_periodic_task(void)
Navigation main: call to the code generated from the XML flight plan.
bool kill_throttle
allow autopilot to use throttle
#define RADIO_KILL_SWITCH
Fixedwing Navigation library.
struct Electrical ap_electrical
pprz_t v_ctl_throttle_slewed
Fixedwing autopilot modes (static implementation).
#define PPRZ_MUTEX_UNLOCK(_mtx)
uint8_t mode
current autopilot mode
pprz_t nav_throttle_setpoint
#define AP_COMMAND_SET_YAW(_yaw)
#define V_CTL_MODE_LANDING
uint8_t autopilot_get_mode(void)
get autopilot mode
void v_ctl_altitude_loop(void)
outer loop