Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
main_ap.c File Reference

AP ( AutoPilot ) tasks. More...

#include <math.h>
#include "firmwares/fixedwing/main_ap.h"
#include "mcu.h"
#include "mcu_periph/sys_time.h"
#include "link_mcu.h"
#include "firmwares/fixedwing/autopilot.h"
#include "estimator.h"
#include "firmwares/fixedwing/stabilization/stabilization_attitude.h"
#include "firmwares/fixedwing/guidance/guidance_v.h"
#include "subsystems/nav.h"
#include "generated/flight_plan.h"
#include "subsystems/datalink/datalink.h"
#include "subsystems/settings.h"
#include "subsystems/datalink/xbee.h"
#include "firmwares/fixedwing/ap_downlink.h"
#include "generated/modules.h"
#include "generated/settings.h"
#include "gpio.h"
#include "led.h"
+ Include dependency graph for main_ap.c:

Go to the source code of this file.

Macros

#define MODULES_C
 
#define CONTROL_FREQUENCY   20
 
#define NAVIGATION_FREQUENCY   4
 
#define MODULES_FREQUENCY   60
 
#define RC_LOST_MODE   PPRZ_MODE_HOME
 mode to enter when RC is lost in PPRZ_MODE_MANUAL or PPRZ_MODE_AUTO1 More...
 
#define LOW_BATTERY_DELAY   5
 Maximum time allowed for low battery level before going into kill mode. More...
 
#define KILL_MODE_DISTANCE   (1.5*MAX_DIST_FROM_HOME)
 Maximum distance from HOME waypoint before going into kill mode. More...
 
#define MIN_SPEED_FOR_TAKEOFF   5.
 Define minimal speed for takeoff in m/s. More...
 

Functions

void init_ap (void)
 
void handle_periodic_tasks_ap (void)
 
static uint8_t pprz_mode_update (void)
 Update paparazzi mode. More...
 
static uint8_t mcu1_status_update (void)
 
static void copy_from_to_fbw (void)
 Send back uncontrolled channels. More...
 
static void telecommand_task (void)
 Function to be called when a message from FBW is available. More...
 
void reporting_task (void)
 Send a series of initialisation messages followed by a stream of periodic ones. More...
 
void navigation_task (void)
 Compute desired_course. More...
 
void attitude_loop (void)
 
void sensors_task (void)
 Run at PERIODIC_FREQUENCY (60Hz if not defined) More...
 
void monitor_task (void)
 monitor stuff run at 1Hz More...
 
void event_task_ap (void)
 

Variables

bool_t power_switch
 
static const uint16_t version = 1
 
uint8_t pprz_mode = PPRZ_MODE_AUTO2
 
uint8_t lateral_mode = LATERAL_MODE_MANUAL
 
static uint8_t mcu1_status
 
bool_t kill_throttle = FALSE
 
bool_t launch = FALSE
 
uint8_t vsupply
 Supply voltage in deciVolt. More...
 
static int32_t current
 Supply current in milliAmpere. More...
 
float energy
 Fuel consumption (mAh) TODO: move to electrical subsystem. More...
 
bool_t gps_lost = FALSE
 
tid_t modules_tid
 id for modules_periodic_task() timer More...
 
tid_t telemetry_tid
 id for telemetry_periodic() timer More...
 
tid_t sensors_tid
 id for sensors_task() timer More...
 
tid_t attitude_tid
 id for attitude_loop() timer More...
 
tid_t navigation_tid
 id for navigation_task() timer More...
 
tid_t monitor_tid
 id for monitor_task() timer More...
 

Detailed Description

AP ( AutoPilot ) tasks.

This process is reponsible for the collecting the different sensors data, fusing them to obtain aircraft attitude and running the different control loops

Definition in file main_ap.c.

Macro Definition Documentation

#define CONTROL_FREQUENCY   20

Definition at line 155 of file main_ap.c.

Referenced by init_ap().

#define KILL_MODE_DISTANCE   (1.5*MAX_DIST_FROM_HOME)

Maximum distance from HOME waypoint before going into kill mode.

Definition at line 569 of file main_ap.c.

Referenced by monitor_task().

#define LOW_BATTERY_DELAY   5

Maximum time allowed for low battery level before going into kill mode.

Definition at line 565 of file main_ap.c.

Referenced by monitor_task().

#define MIN_SPEED_FOR_TAKEOFF   5.

Define minimal speed for takeoff in m/s.

Definition at line 573 of file main_ap.c.

Referenced by monitor_task().

#define MODULES_C

Definition at line 33 of file main_ap.c.

#define MODULES_FREQUENCY   60

Definition at line 164 of file main_ap.c.

Referenced by init_ap().

#define NAVIGATION_FREQUENCY   4

Definition at line 160 of file main_ap.c.

Referenced by init_ap().

#define RC_LOST_MODE   PPRZ_MODE_HOME

mode to enter when RC is lost in PPRZ_MODE_MANUAL or PPRZ_MODE_AUTO1

Definition at line 336 of file main_ap.c.

Referenced by telecommand_task().

Function Documentation

void attitude_loop ( void  )

Definition at line 522 of file main_ap.c.

References ahrs_update_infrared(), ap_state, h_ctl_aileron_setpoint, h_ctl_attitude_loop(), h_ctl_elevator_setpoint, inter_mcu_received_ap, TRUE, v_ctl_throttle_slew(), and v_ctl_throttle_slewed.

Referenced by event_task_ap(), handle_periodic_tasks_ap(), and sim_periodic_task().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void copy_from_to_fbw ( void  )
inlinestatic

Send back uncontrolled channels.

Definition at line 326 of file main_ap.c.

References ap_state, fbw_state, and RADIO_YAW.

Referenced by telecommand_task().

+ Here is the caller graph for this function:

void event_task_ap ( void  )

USE_GPS

Definition at line 606 of file main_ap.c.

References AhrsEvent, attitude_loop(), FALSE, GpsEvent, i2c_event(), ImuEvent, inter_mcu_received_fbw, link_mcu_event_task(), on_accel_event(), on_gyro_event(), on_mag_event(), and telecommand_task().

Referenced by sim_periodic_task().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void handle_periodic_tasks_ap ( void  )
void init_ap ( void  )
static uint8_t mcu1_status_update ( void  )
inlinestatic

Definition at line 313 of file main_ap.c.

References FALSE, fbw_state, and mcu1_status.

Referenced by telecommand_task().

+ Here is the caller graph for this function:

void monitor_task ( void  )
static uint8_t pprz_mode_update ( void  )
inlinestatic

Update paparazzi mode.

Definition at line 308 of file main_ap.c.

References FALSE.

Referenced by telecommand_task().

+ Here is the caller graph for this function:

void reporting_task ( void  )

Send a series of initialisation messages followed by a stream of periodic ones.

Called at 60Hz.

initialisation phase during boot

then report periodicly

Definition at line 412 of file main_ap.c.

References DefaultChannel, DefaultDevice, FALSE, TRUE, and version.

Referenced by handle_periodic_tasks_ap(), and sim_periodic_task().

+ Here is the caller graph for this function:

void sensors_task ( void  )

Run at PERIODIC_FREQUENCY (60Hz if not defined)

Definition at line 546 of file main_ap.c.

References imu_periodic(), and ins_periodic_task().

Referenced by handle_periodic_tasks_ap(), and sim_periodic_task().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void telecommand_task ( void  )
inlinestatic

Variable Documentation

tid_t attitude_tid

id for attitude_loop() timer

Definition at line 146 of file main_ap.c.

Referenced by handle_periodic_tasks_ap(), and init_ap().

int32_t current
static

Supply current in milliAmpere.

This the ap copy of the measurement from fbw

Definition at line 133 of file main_ap.c.

Referenced by navigation_task(), and telecommand_task().

float energy

Fuel consumption (mAh) TODO: move to electrical subsystem.

Definition at line 138 of file main_ap.c.

Referenced by generic_com_periodic(), and navigation_task().

bool_t gps_lost = FALSE

Definition at line 140 of file main_ap.c.

Referenced by navigation_task().

bool_t kill_throttle = FALSE

Definition at line 120 of file main_ap.c.

Referenced by monitor_task(), and navigation_task().

uint8_t lateral_mode = LATERAL_MODE_MANUAL

Definition at line 112 of file main_ap.c.

Referenced by fly_to_xy(), nav_without_gps(), and navigation_task().

bool_t launch = FALSE

Definition at line 122 of file main_ap.c.

Referenced by monitor_task(), navigation_task(), and telecommand_task().

uint8_t mcu1_status
static

Definition at line 114 of file main_ap.c.

Referenced by mcu1_status_update().

tid_t modules_tid

id for modules_periodic_task() timer

Definition at line 143 of file main_ap.c.

Referenced by handle_periodic_tasks_ap(), and init_ap().

tid_t monitor_tid

id for monitor_task() timer

Definition at line 148 of file main_ap.c.

Referenced by handle_periodic_tasks_ap(), and init_ap().

tid_t navigation_tid

id for navigation_task() timer

Definition at line 147 of file main_ap.c.

Referenced by handle_periodic_tasks_ap(), and init_ap().

bool_t power_switch

Definition at line 106 of file main_ap.c.

Referenced by init_ap().

tid_t sensors_tid

id for sensors_task() timer

Definition at line 145 of file main_ap.c.

Referenced by handle_periodic_tasks_ap(), and init_ap().

tid_t telemetry_tid

id for telemetry_periodic() timer

Definition at line 144 of file main_ap.c.

Referenced by handle_periodic_tasks_ap(), and init_ap().

const uint16_t version = 1
static

Definition at line 109 of file main_ap.c.

Referenced by reporting_task().

uint8_t vsupply

Supply voltage in deciVolt.

This the ap copy of the measurement from fbw

Definition at line 128 of file main_ap.c.

Referenced by gsm_send_report_continue(), monitor_task(), navigation_task(), and telecommand_task().