Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
sys_id_doublet.c
Go to the documentation of this file.
1/*
2 * Copyright (C) Alessandro Collicelli
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 */
34#include "std.h"
35
36#include "sys_id_doublet.h"
37#include "pprz_doublet.h"
38
40#include "generated/airframe.h"
41#include "mcu_periph/sys_time.h"
42
43#ifndef SYS_ID_DOUBLET_AXES
44#define SYS_ID_DOUBLET_AXES {COMMAND_ROLL,COMMAND_PITCH,COMMAND_YAW,COMMAND_THRUST}
45#endif
46
47#ifndef SYS_ID_DOUBLET_ENABLED
48#define SYS_ID_DOUBLET_ENABLED TRUE
49#endif
50
51#ifdef SYS_ID_DOUBLET_RADIO_CHANNEL
54#endif
55
56
57static struct doublet_t doublet;
58
61
63
65float doublet_length_s = 0.5f;
67
68
69
71#define SYS_ID_DOUBLET_NB_AXES sizeof SYS_ID_ACTIVE_DOUBLET_AXES / sizeof SYS_ID_ACTIVE_DOUBLET_AXES[0] // Number of items in ACTIVE_DOUBLET_AXES
72
74
76{
77 if (doublet_active) {
79
80 } else {
81 for (uint8_t i = 0; i < SYS_ID_DOUBLET_NB_AXES; i++) {
83 }
84 }
85}
86
92
99
100static void stop_doublet(void)
101{
103 doublet_active = false;
105}
106
110
112{
114 #ifdef DOUBLET_RADIO_CHANNEL
115 // Don't activate doublet when radio signal is low
117 {
118 doublet_active = 0;
119 }
120 #endif
121 if (doublet_active) {
124 } else {
125 stop_doublet();
126 }
127}
128
135
139
151
153{
154 #ifdef SYS_ID_DOUBLET_RADIO_CHANNEL
155 // Check if doublet switched on when off before
157 {
159 {
160 // Activate doublet
162 }
163 }
164 // Check if doublet switched off when on before
166 {
168 {
169 // Deactivate doublet
171 }
172 }
174 #endif
175 if (doublet_active) {
177 stop_doublet();
178 } else {
181 }
182 }
183
184
185}
186
188{
189
190#if SYS_ID_DOUBLET_ENABLED
191
192if (motors_on) {
193 for (uint8_t i = 0; i < SYS_ID_DOUBLET_NB_AXES; i++) {
196 }
197}
198
199#endif
200}
#define UNUSED(x)
uint16_t foo
Definition main_demo5.c:58
int16_t pprz_t
Definition paparazzi.h:6
#define MAX_PPRZ
Definition paparazzi.h:8
void doublet_init(struct doublet_t *doublet, float length_s, float extra_waiting_time_s, float current_time_s, uint8_t mod)
bool doublet_is_running(struct doublet_t *doublet, float current_time_s)
void doublet_reset(struct doublet_t *doublet, float current_time_s)
float doublet_update(struct doublet_t *doublet, float current_time_s)
float current_value
Initialize with doublet_init.
struct RadioControl radio_control
Generic interface for radio control modules.
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
Definition sonar_bebop.c:65
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
static pprz_t current_doublet_values[SYS_ID_DOUBLET_NB_AXES]
uint8_t doublet_active
uint8_t doublet_mode
static struct doublet_t doublet
void sys_id_doublet_activate_handler(uint8_t activate)
static void send_doublet(struct transport_tx *trans, struct link_device *dev)
float doublet_extra_waiting_time_s
static void set_current_doublet_values(void)
void sys_id_doublet_add_values(bool UNUSED motors_on, bool UNUSED override_on, pprz_t UNUSED in_cmd[])
void sys_id_doublet_init(void)
float doublet_length_s
#define SYS_ID_DOUBLET_AXES
#define SYS_ID_DOUBLET_NB_AXES
void sys_id_doublet_axis_handler(uint8_t axis)
void sys_id_doublet_run(void)
uint8_t doublet_axis
uint8_t sys_id_doublet_running(void)
static void stop_doublet(void)
static void start_doublet(void)
void sys_id_doublet_mod_handler(uint8_t mode)
static const int8_t SYS_ID_ACTIVE_DOUBLET_AXES[]
pprz_t doublet_amplitude
Architecture independent timing functions.
static float get_sys_time_float(void)
Get the time in seconds since startup.
Definition sys_time.h:138
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.
signed char int8_t
Typedef defining 8 bit char type.