Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
autopilot.h File Reference

Autopilot modes. More...

#include "std.h"
#include "led.h"
#include "generated/airframe.h"
#include "subsystems/ins.h"
+ Include dependency graph for autopilot.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define AP_MODE_FAILSAFE   0
 
#define AP_MODE_KILL   1
 
#define AP_MODE_RATE_DIRECT   2
 
#define AP_MODE_ATTITUDE_DIRECT   3
 
#define AP_MODE_RATE_RC_CLIMB   4
 
#define AP_MODE_ATTITUDE_RC_CLIMB   5
 
#define AP_MODE_ATTITUDE_CLIMB   6
 
#define AP_MODE_RATE_Z_HOLD   7
 
#define AP_MODE_ATTITUDE_Z_HOLD   8
 
#define AP_MODE_HOVER_DIRECT   9
 
#define AP_MODE_HOVER_CLIMB   10
 
#define AP_MODE_HOVER_Z_HOLD   11
 
#define AP_MODE_NAV   12
 
#define AP_MODE_RC_DIRECT   13
 
#define AP_MODE_CARE_FREE_DIRECT   14
 
#define AP_MODE_FORWARD   15
 
#define MODE_MANUAL   AP_MODE_RATE_DIRECT
 Default RC mode. More...
 
#define MODE_AUTO1   AP_MODE_ATTITUDE_DIRECT
 
#define MODE_AUTO2   AP_MODE_ATTITUDE_Z_HOLD
 
#define THRESHOLD_1_PPRZ   (MIN_PPRZ / 2)
 
#define THRESHOLD_2_PPRZ   (MAX_PPRZ / 2)
 
#define AP_MODE_OF_PPRZ(_rc, _mode)
 
#define autopilot_KillThrottle(_kill)
 
#define autopilot_SetPowerSwitch(_v)
 
#define SetRotorcraftCommands(_cmd, _in_flight,_motor_on)
 Set Rotorcraft commands. More...
 
#define THRESHOLD_GROUND_DETECT   25.0
 Z-acceleration threshold to detect ground in m/s^2. More...
 

Functions

void autopilot_init (void)
 Autopilot inititalization. More...
 
void autopilot_periodic (void)
 
void autopilot_on_rc_frame (void)
 
void autopilot_set_mode (uint8_t new_autopilot_mode)
 
void autopilot_set_motors_on (bool_t motors_on)
 
static void DetectGroundEvent (void)
 Ground detection based on vertical acceleration. More...
 

Variables

uint8_t autopilot_mode
 
uint8_t autopilot_mode_auto2
 
bool_t autopilot_motors_on
 
bool_t autopilot_in_flight
 
bool_t kill_throttle
 
bool_t autopilot_rc
 
bool_t autopilot_power_switch
 
bool_t autopilot_detect_ground
 
bool_t autopilot_detect_ground_once
 
uint16_t autopilot_flight_time
 flight time in seconds. More...
 

Detailed Description

Autopilot modes.

Definition in file autopilot.h.

Macro Definition Documentation

#define AP_MODE_ATTITUDE_CLIMB   6

Definition at line 45 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_ATTITUDE_DIRECT   3

Definition at line 42 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_ATTITUDE_RC_CLIMB   5

Definition at line 44 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_ATTITUDE_Z_HOLD   8

Definition at line 47 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_CARE_FREE_DIRECT   14

Definition at line 53 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_FAILSAFE   0
#define AP_MODE_HOVER_CLIMB   10

Definition at line 49 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_HOVER_DIRECT   9

Definition at line 48 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_HOVER_Z_HOLD   11

Definition at line 50 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_NAV   12

Definition at line 51 of file autopilot.h.

Referenced by autopilot_on_rc_frame(), autopilot_set_mode(), and failsafe_check().

#define AP_MODE_OF_PPRZ (   _rc,
  _mode 
)
Value:
{ \
else if (_rc > THRESHOLD_1_PPRZ) \
_mode = MODE_AUTO1; \
else \
_mode = MODE_MANUAL; \
}
if(PrimarySpektrumState.SpektrumTimer)--PrimarySpektrumState.SpektrumTimer
#define THRESHOLD_1_PPRZ
Definition: autopilot.h:89
#define THRESHOLD_2_PPRZ
Definition: autopilot.h:90
#define MODE_AUTO1
Definition: autopilot.h:82
#define MODE_MANUAL
Default RC mode.
Definition: autopilot.h:79
uint8_t autopilot_mode_auto2
Definition: autopilot.c:40

Definition at line 92 of file autopilot.h.

Referenced by autopilot_on_rc_frame().

#define AP_MODE_RATE_DIRECT   2

Definition at line 41 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_RATE_RC_CLIMB   4

Definition at line 43 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_RATE_Z_HOLD   7

Definition at line 46 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_RC_DIRECT   13

Definition at line 52 of file autopilot.h.

Referenced by autopilot_set_mode().

#define autopilot_KillThrottle (   _kill)
Value:
{ \
if (_kill) \
}
if(PrimarySpektrumState.SpektrumTimer)--PrimarySpektrumState.SpektrumTimer
#define FALSE
Definition: imu_chimu.h:141
#define TRUE
Definition: imu_chimu.h:144
void autopilot_set_motors_on(bool_t motors_on)
Definition: autopilot.c:299

Definition at line 101 of file autopilot.h.

#define autopilot_SetPowerSwitch (   _v)
Value:
{ \
}
bool_t autopilot_power_switch
Definition: autopilot.c:50

Definition at line 115 of file autopilot.h.

#define MODE_AUTO1   AP_MODE_ATTITUDE_DIRECT

Definition at line 82 of file autopilot.h.

#define MODE_AUTO2   AP_MODE_ATTITUDE_Z_HOLD

Definition at line 85 of file autopilot.h.

Referenced by autopilot_init().

#define MODE_MANUAL   AP_MODE_RATE_DIRECT

Default RC mode.

Definition at line 79 of file autopilot.h.

Referenced by autopilot_arming_check_motors_on(), and autopilot_arming_set().

#define SetRotorcraftCommands (   _cmd,
  _in_flight,
  _motor_on 
)
Value:
{ \
if (!(_in_flight)) { _cmd[COMMAND_YAW] = 0; } \
if (!(_motor_on)) { _cmd[COMMAND_THRUST] = 0; } \
commands[COMMAND_ROLL] = _cmd[COMMAND_ROLL]; \
commands[COMMAND_PITCH] = _cmd[COMMAND_PITCH]; \
commands[COMMAND_YAW] = _cmd[COMMAND_YAW]; \
commands[COMMAND_THRUST] = _cmd[COMMAND_THRUST]; \
}
if(PrimarySpektrumState.SpektrumTimer)--PrimarySpektrumState.SpektrumTimer
pprz_t commands[COMMANDS_NB]
Storage of intermediate command values.
Definition: commands.c:30

Set Rotorcraft commands.

Limit thrust and/or yaw depending of the in_flight and motors_on flag status

Definition at line 125 of file autopilot.h.

Referenced by autopilot_periodic().

#define THRESHOLD_1_PPRZ   (MIN_PPRZ / 2)

Definition at line 89 of file autopilot.h.

#define THRESHOLD_2_PPRZ   (MAX_PPRZ / 2)

Definition at line 90 of file autopilot.h.

#define THRESHOLD_GROUND_DETECT   25.0

Z-acceleration threshold to detect ground in m/s^2.

Definition at line 145 of file autopilot.h.

Referenced by DetectGroundEvent().

Function Documentation

void autopilot_set_motors_on ( bool_t  motors_on)

Definition at line 299 of file autopilot.c.

References ahrs_is_aligned(), autopilot_arming_set(), autopilot_motors_on, FALSE, kill_throttle, and TRUE.

Referenced by autopilot_set_mode().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void DetectGroundEvent ( void  )
inlinestatic

Ground detection based on vertical acceleration.

Definition at line 149 of file autopilot.h.

References AP_MODE_FAILSAFE, autopilot_detect_ground, autopilot_detect_ground_once, autopilot_mode, FALSE, stateGetAccelNed_f(), THRESHOLD_GROUND_DETECT, TRUE, and NedCoor_f::z.

Referenced by main_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

bool_t autopilot_detect_ground
bool_t autopilot_detect_ground_once

Definition at line 53 of file autopilot.c.

Referenced by autopilot_init(), and DetectGroundEvent().

uint16_t autopilot_flight_time
uint8_t autopilot_mode_auto2

Definition at line 40 of file autopilot.c.

Referenced by autopilot_init().

bool_t autopilot_power_switch

Definition at line 50 of file autopilot.c.

Referenced by autopilot_init().

bool_t autopilot_rc

Definition at line 49 of file autopilot.c.

Referenced by autopilot_init(), and main_event().