Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
main_recovery.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3 *
4 * This file is part of Paparazzi.
5 *
6 * Paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * Paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
31#include "generated/airframe.h"
32#include "generated/modules.h"
33#include "modules/core/abi.h"
37#include "autopilot_utils.h"
38#if PERIODIC_TELEMETRY
40#endif
41
43
46#if PERIODIC_TELEMETRY
48#endif
49
50#ifndef RECOVERY_RC_ID
51#define RECOVERY_RC_ID ABI_BROADCAST
52#endif
55
56#define RECOVERY_MODE_OF_PPRZ(mode) ((mode) < THRESHOLD_MANUAL_PPRZ ? RECOVERY_MODE_MANUAL : RECOVERY_MODE_FAILSAFE)
57
58static void rc_cb(uint8_t __attribute__((unused)) sender_id,
59 struct RadioControl *rc)
60{
62 if (recovery_mode == RECOVERY_MODE_MANUAL && rc->status == RC_OK) {
63 // on RC callback in manual, set commands from RC
65 }
66}
67
68/********** PERIODIC MESSAGES ************************************************/
69#if PERIODIC_TELEMETRY
71
72static void send_fbw_status(struct transport_tx *trans, struct link_device *dev)
73{
74#ifdef RADIO_CONTROL
75 uint8_t rc_status = radio_control.status;
77#else
78 uint8_t rc_status = 0;
79 uint8_t rc_rate = 0;
80#endif
82 &rc_status, &rc_rate, &recovery_mode,
84}
85
86#endif /* PERIODIC_TELEMETRY */
87
88/********** INIT *************************************************************/
90{
91 // mcu init done in main
92
93 // don't call all core modules, only a subset
96
100
102
103 /**** start timers for periodic functions *****/
106
107 // actuators periodic will update the actuators
108 // but the autopilot.mode is passed to SetActuatorsFromCommands
109 // it is set to manual if possible, otherwise behavior is undefined
110#ifdef AP_MODE_MANUAL
112#endif
113
114 // Bind to RC event
116
117#if PERIODIC_TELEMETRY
120#endif /* PERIODIC_TELEMETRY */
121
122}
123
124/********** EVENT ************************************************************/
125
133
134/************* PERIODIC ******************************************************/
135
137{
141 // if RC is lost or not in manual, set failsafe commands
146 }
148 }
149
150#if !(RECOVERY_DISABLE_ELECTRICAL)
153 }
154#endif
155
156#if PERIODIC_TELEMETRY
158 // only fbw part during recovery
160 }
161#endif
162
163}
164
Main include for ABI (AirBorneInterface).
Event structure to store callbacks in a linked list.
Definition abi_common.h:67
struct pprz_autopilot autopilot
Global autopilot structure.
Definition autopilot.c:49
uint8_t mode
current autopilot mode
Definition autopilot.h:63
void commands_init(void)
Definition commands.c:46
const pprz_t commands_failsafe[COMMANDS_NB]
Definition commands.c:31
Hardware independent code for commands handling.
struct Electrical electrical
Definition electrical.c:92
void electrical_init(void)
Definition electrical.c:128
void electrical_periodic(void)
Definition electrical.c:166
Interface for electrical status: supply voltage, current, battery status, etc.
float current
current in A
Definition electrical.h:47
float vsupply
supply voltage in V
Definition electrical.h:45
#define AP_MODE_MANUAL
AP modes.
uint16_t foo
Definition main_demo5.c:58
void main_recovery_periodic(void)
#define RECOVERY_RC_ID
tid_t periodic_tid
id for periodic task timer
static void rc_cb(uint8_t sender_id, struct RadioControl *rc)
tid_t electrical_tid
id for electrical_periodic() timer
uint8_t recovery_mode
static void send_fbw_status(struct transport_tx *trans, struct link_device *dev)
#define RECOVERY_MODE_OF_PPRZ(mode)
tid_t telemetry_tid
id for periodic telemetry
void main_recovery_event(void)
void main_recovery_init(void)
static abi_event rc_ev
Recovery mode: run manual mode in case of hardfault Based on legacy FBW.
#define RECOVERY_MODE_MANUAL
recovery modes
#define RECOVERY_MODE_FAILSAFE
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
struct RadioControl radio_control
Generic interface for radio control modules.
#define RC_REALLY_LOST
uint8_t frame_rate
#define RC_OK
Utility functions and includes for autopilots.
static const ShellCommand commands[]
Definition shell_arch.c:78
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition sys_time.c:43
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
Definition sys_time.h:123
int8_t tid_t
sys_time timer id type
Definition sys_time.h:60
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition telemetry.c:51
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
Definition telemetry.h:66
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.