Paparazzi UAS  v5.15_devel-99-g2ff7410
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
autopilot.h File Reference

Core autopilot interface common to all firmwares. More...

#include "std.h"
#include "paparazzi.h"
#include "generated/airframe.h"
#include "state.h"
#include "autopilot_utils.h"
#include "autopilot_firmware.h"
#include "autopilot_static.h"
+ Include dependency graph for autopilot.h:

Go to the source code of this file.

Data Structures

struct  pprz_autopilot
 PPRZ Autopilot structure definition. More...
 

Macros

#define USE_GENERATED_AUTOPILOT   FALSE
 
#define autopilot_ResetFlightTimeAndLaunch(_)   autopilot_reset_flight_time()
 
#define autopilot_KillThrottle(_kill)   autopilot_set_kill_throttle(_kill)
 
#define autopilot_SetPowerSwitch(_ps)   autopilot_set_power_switch(_ps)
 
#define autopilot_StoreSettings(_)   autopilot_store_settings()
 
#define autopilot_ClearSettings(_)   autopilot_clear_settings()
 

Functions

void autopilot_init (void)
 Autopilot initialization function. More...
 
void autopilot_periodic (void)
 Autopilot periodic call at PERIODIC_FREQUENCY. More...
 
void autopilot_event (void)
 Autopilot event check function. More...
 
void autopilot_on_rc_frame (void)
 Autopilot RC input event hadler. More...
 
bool autopilot_set_mode (uint8_t new_autopilot_mode)
 Set new autopilot mode. More...
 
void autopilot_SetModeHandler (float new_autopilot_mode)
 Handler for setter function with dl_setting. More...
 
uint8_t autopilot_get_mode (void)
 Get autopilot mode. More...
 
void autopilot_reset_flight_time (void)
 Reset flight time and launch status Also provide macro for dl_setting backward compatibility. More...
 
void autopilot_set_motors_on (bool motors_on)
 Start or stop motors May have no effect if motors has auto-start based on throttle setpoint. More...
 
bool autopilot_get_motors_on (void)
 Get motor status. More...
 
void autopilot_set_kill_throttle (bool kill)
 Enable or disable motor control from autopilot Also provide macro for dl_setting backward compatibility. More...
 
bool autopilot_throttle_killed (void)
 Get kill status. More...
 
void autopilot_check_in_flight (bool motors_on)
 Check if airframe is in flight. More...
 
void autopilot_set_in_flight (bool in_flight)
 Set in flight status. More...
 
bool autopilot_in_flight (void)
 Get in flight status. More...
 
void autopilot_reset_in_flight_counter (void)
 reset in_flight counter actual implementation is firmware dependent More...
 
void autopilot_set_power_switch (bool power_switch)
 Set power switch state This will actually enable the switch if POWER_SWITCH_GPIO is defined Also provide macro for dl_setting backward compatibility. More...
 
void autopilot_store_settings (void)
 Store marked settings in flash Try to make sure that we don't write to flash while flying Also provide macro for dl_setting backward compatibility. More...
 
void autopilot_clear_settings (void)
 Clear marked settings in flash try to make sure that we don't write to flash while flying Also provide macro for dl_setting backward compatibility. More...
 
void autopilot_send_version (void)
 Report autopilot version on default downlink channel. More...
 
void autopilot_send_mode (void)
 Report autopilot mode on default downlink channel. More...
 

Variables

struct pprz_autopilot autopilot
 Global autopilot structure. More...
 

Detailed Description

Core autopilot interface common to all firmwares.

Using either static or generated autopilot logic, which depends on the firmware.

Definition in file autopilot.h.


Data Structure Documentation

struct pprz_autopilot

PPRZ Autopilot structure definition.

Definition at line 62 of file autopilot.h.

Data Fields
uint8_t arming_status arming status
bool detect_ground_once enable automatic detection of ground (one shot)
uint16_t flight_time flight time in seconds
bool ground_detected automatic detection of landing
bool in_flight in flight status
bool kill_throttle allow autopilot to use throttle
bool launch request launch
uint8_t mode current autopilot mode
uint8_t mode_auto2 FIXME hide this in a private part ?
bool motors_on motor status
bool power_switch enable/disable power from power switch (if any)
pprz_t throttle throttle level as will be displayed in GCS
bool use_rc enable/disable RC input

Macro Definition Documentation

#define autopilot_ClearSettings (   _)    autopilot_clear_settings()

Definition at line 193 of file autopilot.h.

#define autopilot_KillThrottle (   _kill)    autopilot_set_kill_throttle(_kill)

Definition at line 141 of file autopilot.h.

#define autopilot_ResetFlightTimeAndLaunch (   _)    autopilot_reset_flight_time()

Definition at line 120 of file autopilot.h.

#define autopilot_SetPowerSwitch (   _ps)    autopilot_set_power_switch(_ps)

Definition at line 179 of file autopilot.h.

#define autopilot_StoreSettings (   _)    autopilot_store_settings()

Definition at line 186 of file autopilot.h.

#define USE_GENERATED_AUTOPILOT   FALSE

Definition at line 51 of file autopilot.h.

Function Documentation

void autopilot_check_in_flight ( bool  motors_on)

Check if airframe is in flight.

Parameters
[in]motors_onmotors status

Check if airframe is in flight.

Definition at line 238 of file autopilot.c.

References autopilot, autopilot_in_flight_counter, AUTOPILOT_IN_FLIGHT_MIN_ACCEL, AUTOPILOT_IN_FLIGHT_MIN_SPEED, AUTOPILOT_IN_FLIGHT_MIN_THRUST, AUTOPILOT_IN_FLIGHT_TIME, pprz_autopilot::in_flight, stabilization_cmd, stateGetAccelNed_f(), stateGetSpeedNed_f(), and NedCoor_f::z.

Referenced by failsafe_check().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void autopilot_clear_settings ( void  )

Clear marked settings in flash try to make sure that we don't write to flash while flying Also provide macro for dl_setting backward compatibility.

Clear marked settings in flash try to make sure that we don't write to flash while flying Also provide macro for dl_setting backward compatibility.

Definition at line 288 of file autopilot.c.

References autopilot, pprz_autopilot::kill_throttle, settings_clear(), and settings_clear_flag.

+ Here is the call graph for this function:

void autopilot_event ( void  )

Autopilot event check function.

Autopilot event check function.

Autopilot event check function.

used for automatic ground detection

Definition at line 146 of file autopilot.c.

References AP_MODE_FAILSAFE, autopilot, pprz_autopilot::detect_ground_once, pprz_autopilot::ground_detected, pprz_autopilot::mode, stateGetAccelNed_f(), THRESHOLD_GROUND_DETECT, and NedCoor_f::z.

Referenced by event_task_ap(), and main_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool autopilot_get_motors_on ( void  )
bool autopilot_in_flight ( void  )

Get in flight status.

Returns
true if airframe in flight

Get in flight status.

Definition at line 257 of file autopilot.c.

References autopilot, and pprz_autopilot::in_flight.

Referenced by autopilot_generated_periodic(), autopilot_static_on_rc_frame(), autopilot_static_periodic(), gps_sim_hitl_event(), guidance_flip_run(), ins_ekf2_publish_attitude(), ins_ekf2_update(), main_periodic(), nav_home(), nav_is_in_flight(), and orange_avoider_periodic().

+ Here is the caller graph for this function:

void autopilot_on_rc_frame ( void  )

Autopilot RC input event hadler.

Autopilot RC input event hadler.

Definition at line 150 of file autopilot.c.

References autopilot_generated_on_rc_frame(), and autopilot_static_on_rc_frame().

Referenced by event_task_ap(), and main_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void autopilot_periodic ( void  )

Autopilot periodic call at PERIODIC_FREQUENCY.

Autopilot periodic call at PERIODIC_FREQUENCY.

Definition at line 135 of file autopilot.c.

References autopilot_generated_periodic(), and autopilot_static_periodic().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void autopilot_reset_flight_time ( void  )

Reset flight time and launch status Also provide macro for dl_setting backward compatibility.

Reset flight time and launch status Also provide macro for dl_setting backward compatibility.

Definition at line 191 of file autopilot.c.

References autopilot, pprz_autopilot::flight_time, and pprz_autopilot::launch.

void autopilot_reset_in_flight_counter ( void  )

reset in_flight counter actual implementation is firmware dependent

reset in_flight counter actual implementation is firmware dependent

Definition at line 243 of file autopilot.c.

References autopilot_in_flight_counter.

Referenced by autopilot_set_in_flight().

+ Here is the caller graph for this function:

void autopilot_send_mode ( void  )

Report autopilot mode on default downlink channel.

Report autopilot mode on default downlink channel.

Definition at line 306 of file autopilot.c.

References DefaultChannel, DefaultDevice, and send_mode().

Referenced by autopilot_static_on_rc_frame(), and navigation_task().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void autopilot_send_version ( void  )

Report autopilot version on default downlink channel.

Report autopilot version on default downlink channel.

Definition at line 298 of file autopilot.c.

References DefaultChannel, DefaultDevice, and send_autopilot_version().

Referenced by reporting_task(), and telemetry_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void autopilot_set_in_flight ( bool  in_flight)

Set in flight status.

Parameters
[in]in_flightin flight status

Set in flight status.

Definition at line 247 of file autopilot.c.

References autopilot, autopilot_reset_in_flight_counter(), and pprz_autopilot::in_flight.

Referenced by autopilot_arming_check_motors_on(), and autopilot_static_set_mode().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void autopilot_set_kill_throttle ( bool  kill)

Enable or disable motor control from autopilot Also provide macro for dl_setting backward compatibility.

Parameters
[in]killtrue to disable (kill), false to enable (un-kill)

Enable or disable motor control from autopilot Also provide macro for dl_setting backward compatibility.

Definition at line 219 of file autopilot.c.

References autopilot_set_motors_on().

Referenced by actuators_disco_commit(), autopilot_static_on_rc_frame(), nav_bungee_takeoff_run(), nav_bungee_takeoff_setup(), and nav_skid_landing_run().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool autopilot_set_mode ( uint8_t  new_autopilot_mode)

Set new autopilot mode.

Parameters
[in]new_autopilot_modenew mode to set
Returns
true if mode has changed

Set new autopilot mode.

Definition at line 161 of file autopilot.c.

References autopilot, autopilot_generated_set_mode(), autopilot_static_set_mode(), and pprz_autopilot::mode.

Referenced by autopilot_static_on_rc_frame(), failsafe_check(), guidance_flip_run(), mavlink_common_message_handler(), nav_set_failsafe(), navigation_task(), and pprz_mode_update().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void autopilot_set_motors_on ( bool  motors_on)

Start or stop motors May have no effect if motors has auto-start based on throttle setpoint.

Parameters
[in]motors_ontrue to start motors, false to stop

Start or stop motors May have no effect if motors has auto-start based on throttle setpoint.

Definition at line 200 of file autopilot.c.

References autopilot, autopilot_generated_set_motors_on(), autopilot_static_set_motors_on(), pprz_autopilot::kill_throttle, and pprz_autopilot::motors_on.

Referenced by actuators_ardrone_motor_status(), actuators_bebop_commit(), autopilot_set_kill_throttle(), autopilot_static_set_mode(), mavlink_common_message_handler(), NavKillThrottle(), and NavResurrect().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void autopilot_set_power_switch ( bool  power_switch)

Set power switch state This will actually enable the switch if POWER_SWITCH_GPIO is defined Also provide macro for dl_setting backward compatibility.

Parameters
[in]power_switchtrue to enable, false to disable

Set power switch state This will actually enable the switch if POWER_SWITCH_GPIO is defined Also provide macro for dl_setting backward compatibility.

Definition at line 264 of file autopilot.c.

References autopilot, gpio_clear(), gpio_set(), pprz_autopilot::power_switch, and POWER_SWITCH_GPIO.

Referenced by autopilot_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void autopilot_SetModeHandler ( float  mode)

Handler for setter function with dl_setting.

Handler for setter function with dl_setting.

Definition at line 173 of file autopilot.c.

References autopilot_generated_SetModeHandler(), and autopilot_static_SetModeHandler().

+ Here is the call graph for this function:

void autopilot_store_settings ( void  )

Store marked settings in flash Try to make sure that we don't write to flash while flying Also provide macro for dl_setting backward compatibility.

Store marked settings in flash Try to make sure that we don't write to flash while flying Also provide macro for dl_setting backward compatibility.

Definition at line 278 of file autopilot.c.

References autopilot, pprz_autopilot::kill_throttle, settings_store(), and settings_store_flag.

+ Here is the call graph for this function:

bool autopilot_throttle_killed ( void  )

Get kill status.

Returns
true if motors are killed

Get kill status.

Definition at line 230 of file autopilot.c.

References autopilot, and pprz_autopilot::kill_throttle.

Referenced by electrical_periodic(), geo_mag_periodic(), mavlink_send_heartbeat(), nav_skid_landing_run(), v_ctl_climb_loop(), and v_ctl_landing_loop().

+ Here is the caller graph for this function:

Variable Documentation