Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
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(_)
#define autopilot_KillThrottle(_kill)
#define autopilot_StoreSettings(_)
#define autopilot_ClearSettings(_)

Functions

void autopilot_init (void)
 Autopilot initialization function.
void autopilot_periodic (void)
 Autopilot periodic call at PERIODIC_FREQUENCY.
void autopilot_event (void)
 Autopilot event check function.
void autopilot_on_rc_frame (void)
 Autopilot RC input event hadler.
void autopilot_failsafe_checks (void)
 Autopilot periodic failsafe checks.
bool autopilot_set_mode (uint8_t new_autopilot_mode)
 Set new autopilot mode.
void autopilot_SetModeHandler (float new_autopilot_mode)
 Handler for setter function with dl_setting.
uint8_t autopilot_get_mode (void)
 Get autopilot mode.
void autopilot_reset_flight_time (void)
 Reset flight time and launch status Also provide macro for dl_setting backward compatibility.
void autopilot_force_motors_on (bool motors_on)
 Force start/stop the motors WARNING This will skip he preflight checks.
bool autopilot_set_motors_on (bool motors_on)
 Start or stop motors May have no effect if motors has auto-start based on throttle setpoint or when the preflight checks are failing.
bool autopilot_arming_motors_on (bool motors_on)
 Start or stop the motors during arming May not happen when preflight checks are failing.
bool autopilot_get_motors_on (void)
 Get motor status.
void autopilot_set_kill_throttle (bool kill)
 Enable or disable motor control from autopilot Also provide macro for dl_setting backward compatibility.
bool autopilot_throttle_killed (void)
 Get kill status.
void autopilot_check_in_flight (bool motors_on)
 Check if airframe is in flight.
void autopilot_set_in_flight (bool in_flight)
 Set in flight status.
bool autopilot_in_flight (void)
 Get in flight status.
void autopilot_reset_in_flight_counter (void)
 reset in_flight counter actual implementation is firmware dependent
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.
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.
void autopilot_send_version (void)
 Report autopilot version on default downlink channel.
void autopilot_send_mode (void)
 Report autopilot mode on default downlink channel.

Variables

struct pprz_autopilot autopilot
 Global autopilot structure.

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

◆ pprz_autopilot

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
pprz_t throttle throttle level as will be displayed in GCS
bool use_rc enable/disable RC input

Macro Definition Documentation

◆ autopilot_ClearSettings

#define autopilot_ClearSettings ( _)
Value:
void autopilot_clear_settings(void)
clear settings
Definition autopilot.c:368

Definition at line 204 of file autopilot.h.

◆ autopilot_KillThrottle

#define autopilot_KillThrottle ( _kill)
Value:
void autopilot_set_kill_throttle(bool kill)
set kill throttle Kill always kills, also when motors_on is already false (fixedwing in flight).
Definition autopilot.c:312
void _kill(void)

Definition at line 161 of file autopilot.h.

◆ autopilot_ResetFlightTimeAndLaunch

#define autopilot_ResetFlightTimeAndLaunch ( _)
Value:
void autopilot_reset_flight_time(void)
reset flight time and launch
Definition autopilot.c:236

Definition at line 123 of file autopilot.h.

◆ autopilot_StoreSettings

#define autopilot_StoreSettings ( _)
Value:
void autopilot_store_settings(void)
store settings
Definition autopilot.c:358

Definition at line 197 of file autopilot.h.

◆ USE_GENERATED_AUTOPILOT

#define USE_GENERATED_AUTOPILOT   FALSE

Definition at line 51 of file autopilot.h.

Function Documentation

◆ autopilot_arming_motors_on()

bool autopilot_arming_motors_on ( bool motors_on)
extern

Start or stop the motors during arming May not happen when preflight checks are failing.

Start or stop the motors during arming May not happen when preflight checks are failing.

Definition at line 281 of file autopilot.c.

References autopilot, preflight_bypass, and preflight_check().

Referenced by autopilot_arming_check_motors_on(), autopilot_arming_check_motors_on(), and autopilot_arming_check_motors_on().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autopilot_check_in_flight()

void autopilot_check_in_flight ( bool motors_on)
extern

Check if airframe is in flight.

Parameters
[in]motors_onmotors status

Check if airframe is in flight.

Definition at line 332 of file autopilot.c.

References autopilot, autopilot_in_flight_counter, autopilot_in_flight_end_detection(), AUTOPILOT_IN_FLIGHT_MIN_THRUST, AUTOPILOT_IN_FLIGHT_TIME, and stabilization.

Referenced by autopilot_periodic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autopilot_clear_settings()

void autopilot_clear_settings ( void )
extern

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 368 of file autopilot.c.

References autopilot, settings_clear(), and settings_clear_flag.

Here is the call graph for this function:

◆ autopilot_event()

void autopilot_event ( void )
extern

Autopilot event check function.

Autopilot event check function.

Autopilot event check function.

used for automatic ground detection

Definition at line 181 of file autopilot.c.

References AP_MODE_FAILSAFE, autopilot, and autopilot_ground_detection().

Here is the call graph for this function:

◆ autopilot_failsafe_checks()

void autopilot_failsafe_checks ( void )
extern

Autopilot periodic failsafe checks.

Autopilot periodic failsafe checks.

Autopilot periodic failsafe checks.

Checks order:

  • mode from RC
  • RC lost (if MANUAL or AUTO1)
  • RC kill switch (any case)
  • launch detect from RC
  • GPS lost (if AUTO2 or HOME)
  • too far from HOME (if not HOME or not GPS_OUT_OF_ORDER)

send mode if changed at the end

Definition at line 196 of file autopilot.c.

References AP_MODE_AUTO1, AP_MODE_AUTO2, AP_MODE_FAILSAFE, AP_MODE_GPS_OUT_OF_ORDER, AP_MODE_GUIDED, AP_MODE_HOME, AP_MODE_KILL, AP_MODE_MANUAL, AP_MODE_NAV, autopilot, autopilot_get_mode(), autopilot_get_motors_on(), autopilot_set_kill_throttle(), autopilot_set_mode(), datalink_lost(), datalink_time, electrical, gps, GpsIsLost, higher_than_max_altitude(), MIN_PPRZ, sys_time::nb_sec, pprz_mode_update(), radio_control, radio_control_get(), RADIO_KILL_SWITCH, RADIO_THROTTLE, RadioControlIsLost, RC_LOST_MODE, RC_OK, RC_REALLY_LOST, rc_settings(), THROTTLE_THRESHOLD_TAKEOFF, and too_far_from_home.

Referenced by autopilot_periodic(), and main_ap_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autopilot_force_motors_on()

void autopilot_force_motors_on ( bool motors_on)
extern

Force start/stop the motors WARNING This will skip he preflight checks.

Parameters
motors_onWheter the motors should be forced on/off

Force start/stop the motors WARNING This will skip he preflight checks.

Definition at line 244 of file autopilot.c.

References autopilot, autopilot_generated_set_motors_on(), and autopilot_static_set_motors_on().

Referenced by autopilot_set_motors_on().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autopilot_get_mode()

◆ autopilot_get_motors_on()

◆ autopilot_in_flight()

◆ autopilot_init()

void autopilot_init ( void )
extern

◆ autopilot_on_rc_frame()

void autopilot_on_rc_frame ( void )
extern

Autopilot RC input event hadler.

Autopilot RC input event hadler.

Definition at line 185 of file autopilot.c.

References autopilot_generated_on_rc_frame(), and autopilot_static_on_rc_frame().

Referenced by rc_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autopilot_periodic()

void autopilot_periodic ( void )
extern

Autopilot periodic call at PERIODIC_FREQUENCY.

Autopilot periodic call at PERIODIC_FREQUENCY.

Definition at line 153 of file autopilot.c.

References autopilot, autopilot_check_in_flight(), autopilot_failsafe_checks(), autopilot_generated_periodic(), autopilot_get_motors_on(), autopilot_in_flight(), and autopilot_static_periodic().

Here is the call graph for this function:

◆ autopilot_reset_flight_time()

void autopilot_reset_flight_time ( void )
extern

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 236 of file autopilot.c.

References autopilot.

◆ autopilot_reset_in_flight_counter()

void autopilot_reset_in_flight_counter ( void )
extern

reset in_flight counter actual implementation is firmware dependent

reset in_flight counter actual implementation is firmware dependent

Definition at line 337 of file autopilot.c.

References autopilot_in_flight_counter.

Referenced by autopilot_set_in_flight().

Here is the caller graph for this function:

◆ autopilot_send_mode()

void autopilot_send_mode ( void )
extern

Report autopilot mode on default downlink channel.

Report autopilot mode on default downlink channel.

Definition at line 386 of file autopilot.c.

References DefaultChannel, DefaultDevice, send_mode(), and send_status().

Referenced by autopilot_set_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autopilot_send_version()

void autopilot_send_version ( void )
extern

Report autopilot version on default downlink channel.

Report autopilot version on default downlink channel.

Definition at line 378 of file autopilot.c.

References DefaultChannel, DefaultDevice, and send_autopilot_version().

Referenced by telemetry_reporting_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autopilot_set_in_flight()

void autopilot_set_in_flight ( bool in_flight)
extern

Set in flight status.

Parameters
[in]in_flightin flight status

Set in flight status.

Definition at line 341 of file autopilot.c.

References autopilot, and autopilot_reset_in_flight_counter().

Referenced by autopilot_arming_check_motors_on(), autopilot_static_set_mode(), and nav_takeoff_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autopilot_set_kill_throttle()

void autopilot_set_kill_throttle ( bool kill)
extern

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.

Resurrect only clears the kill when the motors may run (preflight checks, KILL mode).

Definition at line 312 of file autopilot.c.

References autopilot, and autopilot_set_motors_on().

Referenced by actuators_disco_commit(), autopilot_failsafe_checks(), 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:

◆ autopilot_set_mode()

bool autopilot_set_mode ( uint8_t new_autopilot_mode)
extern

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 200 of file autopilot.c.

References autopilot, autopilot_generated_set_mode(), autopilot_send_mode(), autopilot_static_set_mode(), and mode.

Referenced by autopilot_failsafe_checks(), guidance_flip_run(), guidance_module_run(), mavlink_common_message_handler(), nav_set_failsafe(), and pprz_mode_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autopilot_set_motors_on()

bool autopilot_set_motors_on ( bool motors_on)
extern

Start or stop motors May have no effect if motors has auto-start based on throttle setpoint or when the preflight checks are failing.

Parameters
[in]motors_ontrue to start motors, false to stop
Returns
true The preflight checks are successful and motors are started/stopped
false The preflight checks are failed

Start or stop motors May have no effect if motors has auto-start based on throttle setpoint or when the preflight checks are failing.

Definition at line 258 of file autopilot.c.

References autopilot, autopilot_force_motors_on(), preflight_bypass, and preflight_check().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autopilot_SetModeHandler()

void autopilot_SetModeHandler ( float mode)
extern

Handler for setter function with dl_setting.

Handler for setter function with dl_setting.

Definition at line 218 of file autopilot.c.

References autopilot_generated_SetModeHandler(), autopilot_static_SetModeHandler(), and mode.

Here is the call graph for this function:

◆ autopilot_store_settings()

void autopilot_store_settings ( void )
extern

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 358 of file autopilot.c.

References autopilot, settings_store(), and settings_store_flag.

Here is the call graph for this function:

◆ autopilot_throttle_killed()

bool autopilot_throttle_killed ( void )
extern

Get kill status.

Returns
true if motors are killed

Get kill status.

Definition at line 324 of file autopilot.c.

References autopilot.

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

◆ autopilot

struct pprz_autopilot autopilot
extern

Global autopilot structure.

Definition at line 50 of file autopilot.c.

Referenced by attitude_loop(), autopilot_arming_check_motors_on(), autopilot_arming_check_motors_on(), autopilot_arming_check_valid(), autopilot_arming_check_valid(), autopilot_arming_motors_on(), autopilot_check_in_flight(), autopilot_clear_settings(), autopilot_event(), autopilot_failsafe_checks(), autopilot_force_motors_on(), autopilot_generated_init(), autopilot_generated_on_rc_frame(), autopilot_generated_periodic(), autopilot_generated_set_mode(), autopilot_generated_set_motors_on(), autopilot_get_mode(), autopilot_get_motors_on(), autopilot_in_flight(), autopilot_init(), autopilot_periodic(), autopilot_reset_flight_time(), autopilot_set_in_flight(), autopilot_set_kill_throttle(), autopilot_set_mode(), autopilot_set_motors_on(), autopilot_static_init(), autopilot_static_on_rc_frame(), autopilot_static_periodic(), autopilot_static_set_mode(), autopilot_static_set_motors_on(), autopilot_store_settings(), autopilot_throttle_killed(), calc_flight_time_left(), check_parachute_arming(), check_parachute_trigger(), control_mixing_heewing_attitude_direct(), control_mixing_heewing_attitude_plane(), control_mixing_heewing_manual(), control_mixing_heewing_nav_run(), draw_osd(), Drift_correction(), e_identification_fr_periodic(), gazebo_write(), gazebo_write(), generic_com_periodic(), gsm_send_report_continue(), h_ctl_course_loop(), h_ctl_pitch_loop(), h_ctl_roll_loop(), main_recovery_init(), mf_daq_send_state(), monitor_task(), nav_bungee_takeoff_run(), nav_catapult_highrate_module(), nav_check_wp_time(), nav_check_wp_time(), nav_detect_ground(), nav_home(), nav_takeoff_run(), nps_autopilot_run_step(), oneloop_andi_run(), oneloop_nB_run(), parse_mf_daq_msg(), rotwing_state_choose_state_by_dist(), rotwing_state_periodic(), send_energy(), send_fp(), send_minimal_com(), send_mode(), send_status(), takeoff_detect_periodic(), uav_recovery_periodic(), v_ctl_climb_loop(), v_ctl_guidance_loop(), v_ctl_set_pitch(), and v_ctl_set_throttle().