Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
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_KILL   0
 
#define AP_MODE_FAILSAFE   1
 
#define AP_MODE_HOME   2
 
#define AP_MODE_RATE_DIRECT   3
 
#define AP_MODE_ATTITUDE_DIRECT   4
 
#define AP_MODE_RATE_RC_CLIMB   5
 
#define AP_MODE_ATTITUDE_RC_CLIMB   6
 
#define AP_MODE_ATTITUDE_CLIMB   7
 
#define AP_MODE_RATE_Z_HOLD   8
 
#define AP_MODE_ATTITUDE_Z_HOLD   9
 
#define AP_MODE_HOVER_DIRECT   10
 
#define AP_MODE_HOVER_CLIMB   11
 
#define AP_MODE_HOVER_Z_HOLD   12
 
#define AP_MODE_NAV   13
 
#define AP_MODE_RC_DIRECT   14
 
#define AP_MODE_CARE_FREE_DIRECT   15
 
#define AP_MODE_FORWARD   16
 
#define MODE_MANUAL   AP_MODE_ATTITUDE_DIRECT
 Default RC mode. More...
 
#define MODE_AUTO1   AP_MODE_HOVER_Z_HOLD
 
#define MODE_AUTO2   AP_MODE_NAV
 
#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)
 
void autopilot_check_in_flight (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_ground_detected
 
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   7

Definition at line 46 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_ATTITUDE_DIRECT   4

Definition at line 43 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_ATTITUDE_RC_CLIMB   6

Definition at line 45 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_ATTITUDE_Z_HOLD   9

Definition at line 48 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_CARE_FREE_DIRECT   15

Definition at line 54 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_FORWARD   16

Definition at line 55 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_HOME   2
#define AP_MODE_HOVER_CLIMB   11

Definition at line 50 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_HOVER_DIRECT   10

Definition at line 49 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_HOVER_Z_HOLD   12

Definition at line 51 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_NAV   13
#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:91
#define THRESHOLD_2_PPRZ
Definition: autopilot.h:92
#define MODE_AUTO1
Definition: autopilot.h:84
#define MODE_MANUAL
Default RC mode.
Definition: autopilot.h:81
uint8_t autopilot_mode_auto2
Definition: autopilot.c:48

Definition at line 94 of file autopilot.h.

Referenced by autopilot_on_rc_frame().

#define AP_MODE_RATE_DIRECT   3

Definition at line 42 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_RATE_RC_CLIMB   5

Definition at line 44 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_RATE_Z_HOLD   8

Definition at line 47 of file autopilot.h.

Referenced by autopilot_set_mode().

#define AP_MODE_RC_DIRECT   14

Definition at line 53 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:474

Definition at line 103 of file autopilot.h.

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

Definition at line 118 of file autopilot.h.

#define MODE_AUTO1   AP_MODE_HOVER_Z_HOLD

Definition at line 84 of file autopilot.h.

#define MODE_AUTO2   AP_MODE_NAV

Definition at line 87 of file autopilot.h.

Referenced by autopilot_init().

#define MODE_MANUAL   AP_MODE_ATTITUDE_DIRECT

Default RC mode.

Definition at line 81 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 128 of file autopilot.h.

Referenced by autopilot_periodic().

#define THRESHOLD_1_PPRZ   (MIN_PPRZ / 2)

Definition at line 91 of file autopilot.h.

#define THRESHOLD_2_PPRZ   (MAX_PPRZ / 2)

Definition at line 92 of file autopilot.h.

#define THRESHOLD_GROUND_DETECT   25.0

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

Definition at line 148 of file autopilot.h.

Referenced by DetectGroundEvent().

Function Documentation

void autopilot_check_in_flight ( bool_t  motors_on)

Definition at line 436 of file autopilot.c.

References autopilot_in_flight, autopilot_in_flight_counter, AUTOPILOT_IN_FLIGHT_MIN_ACCEL, AUTOPILOT_IN_FLIGHT_MIN_SPEED, AUTOPILOT_IN_FLIGHT_MIN_THRUST, AUTOPILOT_IN_FLIGHT_TIME, FALSE, stabilization_cmd, stateGetAccelNed_f(), stateGetSpeedNed_f(), and TRUE.

Referenced by failsafe_check().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void autopilot_set_motors_on ( bool_t  motors_on)

Definition at line 474 of file autopilot.c.

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

Referenced by actuators_ardrone_motor_status(), and 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 152 of file autopilot.h.

References AP_MODE_FAILSAFE, autopilot_detect_ground_once, autopilot_ground_detected, 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_once

Definition at line 61 of file autopilot.c.

Referenced by autopilot_init(), autopilot_periodic(), and DetectGroundEvent().

bool_t autopilot_ground_detected
uint8_t autopilot_mode_auto2

Definition at line 48 of file autopilot.c.

Referenced by autopilot_init().

bool_t autopilot_power_switch

Definition at line 58 of file autopilot.c.

Referenced by autopilot_init().

bool_t autopilot_rc

Definition at line 57 of file autopilot.c.

Referenced by autopilot_init(), and main_event().