|
Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Core autopilot interface common to all firmwares. More...
#include "autopilot.h"#include "generated/modules.h"#include "mcu.h"#include "mcu_periph/uart.h"#include "mcu_periph/sys_time.h"#include "mcu_periph/gpio.h"#include "modules/core/commands.h"#include "modules/datalink/telemetry.h"#include "modules/core/abi.h"#include "modules/checks/preflight_checks.h"#include "modules/core/settings.h"#include "generated/settings.h"#include "pprz_version.h"Go to the source code of this file.
Macros | |
| #define | AUTOPILOT_RC_ID ABI_BROADCAST |
Functions | |
| static void | rc_cb (uint8_t sender_id, struct RadioControl *rc) |
| static void | send_autopilot_version (struct transport_tx *trans, struct link_device *dev) |
| static void | send_alive (struct transport_tx *trans, struct link_device *dev) |
| static void | send_attitude (struct transport_tx *trans, struct link_device *dev) |
| static void | send_dl_value (struct transport_tx *trans, struct link_device *dev) |
| static void | send_minimal_com (struct transport_tx *trans, struct link_device *dev) |
| void | autopilot_init (void) |
| Autopilot initialization function. | |
| void | autopilot_periodic (void) |
| AP periodic call. | |
| void WEAK | autopilot_event (void) |
| AP event call. | |
| void | autopilot_on_rc_frame (void) |
| RC frame handler. | |
| void WEAK | autopilot_failsafe_checks (void) |
| Failsafe checks. | |
| bool | autopilot_set_mode (uint8_t new_autopilot_mode) |
| set autopilot mode | |
| void | autopilot_SetModeHandler (float mode) |
| AP mode setting handler. | |
| uint8_t | autopilot_get_mode (void) |
| get autopilot mode | |
| void | autopilot_reset_flight_time (void) |
| reset flight time and launch | |
| void | autopilot_force_motors_on (bool motors_on) |
| Force the motors on/off skipping preflight checks. | |
| bool | autopilot_set_motors_on (bool motors_on) |
| turn motors on/off, eventually depending of the current mode set kill_throttle accordingly: kill_throttle == !motors_on (fixedwing and rover cut the throttle with kill_throttle, rotorcraft uses motors_on) | |
| bool | autopilot_arming_motors_on (bool motors_on) |
| turn motors on/off during arming, not done automatically prevents takeoff with preflight checks | |
| bool | autopilot_get_motors_on (void) |
| get motors status | |
| void | autopilot_set_kill_throttle (bool kill) |
| set kill throttle Kill always kills, also when motors_on is already false (fixedwing in flight). | |
| bool | autopilot_throttle_killed (void) |
| get kill status | |
| void WEAK | autopilot_check_in_flight (bool motors_on) |
| in flight check utility function actual implementation is firmware dependent | |
| void WEAK | autopilot_reset_in_flight_counter (void) |
| reset in_flight counter actual implementation is firmware dependent | |
| void | autopilot_set_in_flight (bool in_flight) |
| set in_flight flag | |
| bool | autopilot_in_flight (void) |
| get in_flight flag | |
| void | autopilot_store_settings (void) |
| store settings | |
| void | autopilot_clear_settings (void) |
| clear settings | |
| void | autopilot_send_version (void) |
| send autopilot version | |
| void WEAK | autopilot_send_mode (void) |
| send autopilot mode actual implementation is firmware dependent | |
Variables | |
| struct pprz_autopilot | autopilot |
| Global autopilot structure. | |
| static abi_event | rc_ev |
Core autopilot interface common to all firmwares.
Using either static or generated autopilot logic, which depends on the firmware.
Definition in file autopilot.c.
| #define AUTOPILOT_RC_ID ABI_BROADCAST |
Definition at line 53 of file autopilot.c.
Referenced by autopilot_init().
| bool autopilot_arming_motors_on | ( | bool | motors_on | ) |
turn motors on/off during arming, not done automatically prevents takeoff with preflight checks
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().
| void WEAK autopilot_check_in_flight | ( | bool | motors_on | ) |
in flight check utility function actual implementation is firmware dependent
Check if airframe is in flight.
Definition at line 332 of file autopilot.c.
Referenced by autopilot_periodic().
| void autopilot_clear_settings | ( | void | ) |
clear settings
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.
| void WEAK autopilot_event | ( | void | ) |
| void WEAK autopilot_failsafe_checks | ( | void | ) |
Failsafe checks.
Autopilot periodic failsafe checks.
Definition at line 196 of file autopilot.c.
Referenced by autopilot_periodic(), and main_ap_init().
| void autopilot_force_motors_on | ( | bool | motors_on | ) |
Force the motors on/off skipping preflight checks.
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().
| uint8_t autopilot_get_mode | ( | void | ) |
get autopilot mode
Get autopilot mode.
Definition at line 229 of file autopilot.c.
References autopilot.
Referenced by attitude_loop(), autopilot_arming_check_motors_on(), autopilot_arming_check_motors_on(), autopilot_arming_check_motors_on(), autopilot_arming_check_valid(), autopilot_arming_set(), autopilot_failsafe_checks(), autopilot_static_on_rc_frame(), collective_tracking_control(), distributed_circular(), generic_com_periodic(), guidance_flip_enter(), gvf_low_level_control_2D(), gvf_low_level_control_3D(), h_ctl_pitch_loop(), h_ctl_roll_loop(), mavlink_common_message_handler(), mavlink_send_heartbeat(), navigation_task(), NavKillThrottle(), NavResurrect(), periodic_auto1_commands(), pprz_mode_update(), send_fbw_status(), send_mode(), takeoff_detect_periodic(), v_ctl_set_pitch(), v_ctl_set_throttle(), and wedgebug_periodic().
| bool autopilot_get_motors_on | ( | void | ) |
get motors status
Get motor status.
Definition at line 303 of file autopilot.c.
References autopilot.
Referenced by actuators_bebop_commit(), air_data_start_calibration(), autopilot_arming_check_motors_on(), autopilot_failsafe_checks(), autopilot_periodic(), control_mixing_heewing_attitude_direct(), control_mixing_heewing_nav_run(), event_update(), get_act_state_oneloop(), hott_check_serial_data(), hott_update_eam_msg(), hott_update_gam_msg(), ins_ekf2_update_system_flags(), intermcu_send_commands(), mavlink_common_message_handler(), nav_takeoff_run(), nav_takeoff_run(), nps_autopilot_run_step(), stabilization_attitude_run(), stabilization_indi_rate_run(), and throttle_curve_run().
| bool autopilot_in_flight | ( | void | ) |
get in_flight flag
Get in flight status.
Definition at line 351 of file autopilot.c.
References autopilot.
Referenced by autopilot_generated_periodic(), autopilot_periodic(), autopilot_static_periodic(), control_mixing_heewing_attitude_direct(), control_mixing_heewing_attitude_plane(), control_mixing_heewing_nav_run(), e_identification_fr_periodic(), ekf_aw_wrapper_periodic(), guidance_flip_run(), guidance_module_enter(), guidance_module_run(), ins_ekf2_update_system_flags(), ins_flow_update(), mav_exercise_periodic(), mavlink_send_extended_sys_state(), nav_is_in_flight(), orange_avoider_periodic(), rc_cb(), rc_cb(), stabilization_indi_attitude_controller(), and stabilization_indi_rate_controller().
| void autopilot_init | ( | void | ) |
Autopilot initialization function.
Definition at line 114 of file autopilot.c.
References autopilot, autopilot_firmware_init(), autopilot_generated_init(), AUTOPILOT_RC_ID, autopilot_static_init(), DefaultPeriodic, MODE_AUTO2, rc_cb(), rc_ev, register_periodic_telemetry(), send_alive(), send_attitude(), send_autopilot_version(), send_dl_value(), and send_minimal_com().
| void autopilot_on_rc_frame | ( | void | ) |
RC frame handler.
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().
| void autopilot_periodic | ( | void | ) |
AP periodic call.
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().
| void autopilot_reset_flight_time | ( | void | ) |
reset flight time and launch
Reset flight time and launch status Also provide macro for dl_setting backward compatibility.
Definition at line 236 of file autopilot.c.
References autopilot.
| void WEAK autopilot_reset_in_flight_counter | ( | void | ) |
reset in_flight counter actual implementation is firmware dependent
Definition at line 337 of file autopilot.c.
Referenced by autopilot_set_in_flight().
| void WEAK autopilot_send_mode | ( | void | ) |
send autopilot mode actual implementation is firmware dependent
Report autopilot mode on default downlink channel.
Definition at line 386 of file autopilot.c.
Referenced by autopilot_set_mode().
| void autopilot_send_version | ( | void | ) |
send autopilot version
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().
| void autopilot_set_in_flight | ( | bool | in_flight | ) |
set in_flight flag
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().
| void autopilot_set_kill_throttle | ( | bool | kill | ) |
set kill throttle Kill always kills, also when motors_on is already false (fixedwing in flight).
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().
| bool autopilot_set_mode | ( | uint8_t | new_autopilot_mode | ) |
set autopilot mode
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().
| bool autopilot_set_motors_on | ( | bool | motors_on | ) |
turn motors on/off, eventually depending of the current mode set kill_throttle accordingly: kill_throttle == !motors_on (fixedwing and rover cut the throttle with kill_throttle, rotorcraft uses 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.
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().
| void autopilot_SetModeHandler | ( | float | mode | ) |
AP mode setting handler.
Handler for setter function with dl_setting.
Definition at line 218 of file autopilot.c.
References autopilot_generated_SetModeHandler(), autopilot_static_SetModeHandler(), and mode.
| void autopilot_store_settings | ( | void | ) |
store settings
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.
| bool autopilot_throttle_killed | ( | void | ) |
get kill status
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().
|
static |
Definition at line 58 of file autopilot.c.
References autopilot_on_rc_frame(), and rc_cb().
Referenced by autopilot_init(), guidance_h_init(), guidance_v_init(), intermcu_init(), main_fbw_init(), main_recovery_init(), rc_cb(), and stabilization_init().
|
static |
Definition at line 78 of file autopilot.c.
References dev.
Referenced by autopilot_init().
|
static |
Definition at line 83 of file autopilot.c.
References dev, FloatEulers::phi, FloatEulers::psi, stateGetNedToBodyEulers_f(), and FloatEulers::theta.
Referenced by autopilot_init().
|
static |
Definition at line 65 of file autopilot.c.
References dev, and mcu_get_uid().
Referenced by autopilot_init(), and autopilot_send_version().
|
static |
Definition at line 89 of file autopilot.c.
References dev.
Referenced by autopilot_init().
|
static |
Definition at line 94 of file autopilot.c.
References UtmCoor_f::alt, autopilot, course, dev, electrical, gps, MAX_PPRZ, nav_block, stateGetHorizontalSpeedDir_f(), stateGetHorizontalSpeedNorm_f(), stateGetPositionLla_f(), stateGetPositionUtm_f(), stateGetSpeedEnu_f(), and EnuCoor_f::z.
Referenced by autopilot_init().
| struct pprz_autopilot autopilot |
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().
|
static |
Definition at line 56 of file autopilot.c.
Referenced by autopilot_init(), guidance_h_init(), guidance_v_init(), intermcu_init(), main_fbw_init(), main_recovery_init(), and stabilization_init().