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) {
133 if (bit_is_set(imcu_get_status(), AVERAGED_CHANNELS_SENT)) {
135 mode_changed |= pprz_mode_changed;
136 #if defined RADIO_CALIB && defined RADIO_CONTROL_SETTINGS
138 bool calib_mode_changed = RcSettingsModeUpdate(
fbw_state->channels);
140 rc_settings(calib_mode_changed || pprz_mode_changed);
141 mode_changed |= calib_mode_changed;
147 #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
157 #if H_CTL_YAW_LOOP && defined RADIO_YAW
171 #endif // RADIO_CONTROL
205 #ifdef FAILSAFE_DELAY_WITHOUT_GPS
206 #define GpsTimeoutError (sys_time.nb_sec - gps.last_3dfix_time > FAILSAFE_DELAY_WITHOUT_GPS)
214 #if defined FAILSAFE_DELAY_WITHOUT_GPS
221 if (GpsTimeoutError) {
250 #if DOWNLINK && !defined PERIOD_NAVIGATION_Ap_0 // If not sent periodically (in default 0 mode)
263 #ifdef H_CTL_RATE_LOOP
280 #if CTRL_VERTICAL_LANDING
293 #if CTRL_VERTICAL_LANDING
297 #if defined V_CTL_THROTTLE_IDLE
301 #ifdef V_CTL_POWER_CTL_BAT_NOMINAL
322 #if H_CTL_YAW_LOOP && defined COMMAND_YAW
323 ap_state->commands[COMMAND_YAW] = h_ctl_rudder_setpoint;
325 #if H_CTL_CL_LOOP && defined COMMAND_CL
326 ap_state->commands[COMMAND_CL] = h_ctl_flaps_setpoint;
330 #if defined MCU_SPI_LINK || defined MCU_UART_LINK || defined MCU_CAN_LINK
332 #elif defined INTER_MCU && defined SINGLE_MCU
343 #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
352 #ifndef RADIO_AUTO_MODE
355 INFO(
"Using RADIO_AUTO_MODE to switch between AUTO1 and AUTO2.")
370 #endif // RADIO_AUTO_MODE
375 #else // not RADIO_CONTROL
384 uint8_t new_status = imcu_get_status();
386 bool changed = ((
mcu1_status & MASK_FBW_CHANGED) != (new_status & MASK_FBW_CHANGED));
400 #ifdef SetAutoCommandsFromRC
402 #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)
void h_ctl_course_loop(void)
Communication between fbw and ap processes.
static uint8_t mcu1_status_update(void)
void h_ctl_attitude_loop(void)
pprz_t v_ctl_throttle_setpoint
int32_t current
Supply current in milliAmpere.
#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.
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.
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.
float energy
Energy consumption (mAh) This is the ap copy of the measurement from fbw FIXME use electrical module ...
#define LATERAL_MODE_COURSE
uint16_t vsupply
Supply voltage in deciVolt.
#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)
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)
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.
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
Fixedwing Navigation library.
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 V_CTL_MODE_LANDING
uint8_t autopilot_get_mode(void)
get autopilot mode
void v_ctl_altitude_loop(void)
outer loop