Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
parachute.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 Ewoud Smeur <e.j.j.smeur@tudelft.nl>
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
28
30// LIDAR AGL threshold (m)
31#define PARACHUTE_AGL_THRESHOLD 6.0
32
33// number of consequtive threshold samples
34#ifndef PARACHUTE_AGL_COUNTER_TRIGGER
35#define PARACHUTE_AGL_COUNTER_TRIGGER 10
36#endif
37
38// number of consequtive threshold samples
39#ifndef PARACHUTE_ATT_ANGLE_THRESHOLD
40#define PARACHUTE_ATT_ANGLE_THRESHOLD RadOfDeg(55.f)
41#endif
42
44
45bool close_to_ground = true;
46
47void check_parachute_arming(void);
49
50#if PERIODIC_TELEMETRY
52static void send_parachute(struct transport_tx *trans, struct link_device *dev)
53{
55 pprz_msg_send_DEBUG(trans, dev, AC_ID, 3, msg);
56}
57#endif // PERIODIC_TELEMETRY
58
60{
61 // Start the drone in a desired hover state
63 parachute.armed = false;
64 parachute.deploy = false;
65
66#if PERIODIC_TELEMETRY
68#endif
69}
70
72{
73 // Check if the parachute should be armed
76 } else if(parachute.arming_method == OFF) {
77 parachute.armed = false;
78 } else {
79 parachute.armed = true;
80 }
81
82 if(parachute.armed) {
84 }
85}
86
87
88inline void check_parachute_arming(void) {
89 // Alt 30m+
90 // not in RATE mode
91 // LIDAR >6m AND valid
92
93 // Check if close to ground
94 static int32_t counter_agl_dist = 0;
97 } else {
99 }
101 close_to_ground = true;
102 // keep counter at maximum in order not to overflow
104 } else {
105 close_to_ground = false;
106 }
107
108 /* Arm parachute only when:
109 * Not in RATE mode
110 * Higher than 30 meters
111 * Not close to ground as measured with a LIDAR
112 */
114 parachute.armed = true;
115 } else {
116 parachute.armed = false;
117 }
118
119}
120
122
123 /* Trigger if armed one of the following:
124 * 1. roll or pitch angle more than 55 degrees
125 * 2. in KILL mode
126 * Then
127 * Set mode to KILL and deploy parachute
128 */
129
130 struct FloatEulers *euler = stateGetNedToBodyEulers_f();
131
133 parachute.deploy = true;
134 } else {
135 parachute.deploy = false;
136 }
137
138}
float agl_dist_valid
Definition agl_dist.c:33
float agl_dist_value_filtered
Definition agl_dist.c:35
Bind to agl ABI message and provide a filtered value to be used in flight plans.
struct pprz_autopilot autopilot
Global autopilot structure.
Definition autopilot.c:49
uint8_t mode
current autopilot mode
Definition autopilot.h:63
float phi
in radians
float theta
in radians
euler angles
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition state.h:1306
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition state.h:848
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
uint16_t foo
Definition main_demo5.c:58
#define PARACHUTE_AGL_THRESHOLD
Definition parachute.c:31
#define PARACHUTE_ATT_ANGLE_THRESHOLD
Definition parachute.c:40
void init_parachute(void)
Definition parachute.c:59
#define PARACHUTE_AGL_COUNTER_TRIGGER
Definition parachute.c:35
void check_parachute_arming(void)
Definition parachute.c:88
struct Parachute parachute
Definition parachute.c:43
void check_parachute_trigger(void)
Definition parachute.c:121
bool close_to_ground
Definition parachute.c:45
void periodic_parachute(void)
Definition parachute.c:71
static void send_parachute(struct transport_tx *trans, struct link_device *dev)
Definition parachute.c:52
bool deploy
Definition parachute.h:40
enum arming_method_t arming_method
Definition parachute.h:38
@ OFF
ARMING OVERRIDE OFF.
Definition parachute.h:32
@ AUTO
AUTOMATIC ARMING.
Definition parachute.h:33
bool armed
Definition parachute.h:39
Rotorcraft specific autopilot interface and initialization.
#define AP_MODE_RATE_DIRECT
#define AP_MODE_KILL
Static autopilot modes.
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
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
int int32_t
Typedef defining 32 bit int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.