Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
sys_id_wave.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#include "math.h"
36#include "pprz_wave.h"
37
38#include "sys_id_wave.h"
39
41#include "generated/airframe.h"
42#include "mcu_periph/sys_time.h"
44#include "math/pprz_random.h"
45
46#ifndef WAVE_AXES
47#define WAVE_AXES {COMMAND_ROLL,COMMAND_PITCH,COMMAND_YAW,COMMAND_THRUST}
48#endif
49
50#ifndef WAVE_ENABLED
51#define WAVE_ENABLED TRUE
52#endif
53
54
55
56static struct wave_t wave_s;
60float frequency_hz_ = 0.0f;
61float lag_rad_ = 0.0f;
62
64#define WAVE_NB_AXES sizeof ACTIVE_WAVE_AXES / sizeof ACTIVE_WAVE_AXES[0] // Number of items in ACTIVE_WAVE_AXES
65
66// Chirp and noise values for all axes (indices correspond to the axes given in WAVE_AXES)
68
69static void set_current_wave_values(void){
70 if (wave_active){
72 wave_s.is_running = true;
73 }
74 else{
75 for (uint8_t i = 0; i < WAVE_NB_AXES; i++) {
77 wave_s.is_running = false;
78 }
79 }
80}
85
86static void start_wave(void){
88 wave_active = true;
90
91}
92
93static void stop_wave(void){
95 wave_active = false;
97
98}
99
109
111{
112 if (axis < WAVE_NB_AXES) {
113 wave_axis = axis;
114 }
115}
116
117
121
122
128
134
135
143
145{
146// #if WAVE_ENABLED
147
148 if (wave_active) {
149 if (!wave_is_running(&wave_s)) {
150 stop_wave();
151 } else {
154 }
155 }
156// #endif
157}
158
159void sys_id_wave_add_values(bool motors_on, bool override_on, pprz_t in_cmd[])
160{
161 (void)(override_on); // Suppress unused parameter warnings
162
163#if WAVE_ENABLED
164
165if (motors_on) {
166 for (uint8_t i = 0; i < WAVE_NB_AXES; i++) {
169 }
170}
171
172#endif
173}
Simple first order low pass filter with bilinear transform.
uint16_t foo
Definition main_demo5.c:58
int16_t pprz_t
Definition paparazzi.h:6
#define MAX_PPRZ
Definition paparazzi.h:8
void wave_reset(struct wave_t *wave, float current_time_s)
Definition pprz_wave.c:45
float wave_update(struct wave_t *wave, float current_time_s)
Definition pprz_wave.c:57
bool wave_is_running(struct wave_t *wave)
Definition pprz_wave.c:52
void wave_init(struct wave_t *wave, float start_time_s, float current_time_s, float frequency_hz, float lag_rad)
Definition pprz_wave.c:33
float current_value
Definition pprz_wave.h:39
float frequency_hz
Definition pprz_wave.h:38
float lag_rad
Definition pprz_wave.h:37
bool is_running
Definition pprz_wave.h:40
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
static void stop_wave(void)
Definition sys_id_wave.c:93
static pprz_t current_wave_values[WAVE_NB_AXES]
Definition sys_id_wave.c:67
static void start_wave(void)
Definition sys_id_wave.c:86
static void set_current_wave_values(void)
Definition sys_id_wave.c:69
static void send_wave(struct transport_tx *trans, struct link_device *dev)
Definition sys_id_wave.c:81
float frequency_hz_
Definition sys_id_wave.c:60
static struct wave_t wave_s
Definition sys_id_wave.c:56
void sys_id_wave_init(void)
void sys_id_wave_run(void)
#define WAVE_AXES
Definition sys_id_wave.c:47
void sys_id_wave_add_values(bool motors_on, bool override_on, pprz_t in_cmd[])
void sys_id_wave_lag_rad_set(float lag_rad_set)
#define WAVE_NB_AXES
Definition sys_id_wave.c:64
uint8_t wave_active
Definition sys_id_wave.c:57
uint8_t wave_axis
Definition sys_id_wave.c:58
pprz_t wave_amplitude
Definition sys_id_wave.c:59
void sys_id_wave_frequency_hz_set(float frequency_hz_set)
float lag_rad_
Definition sys_id_wave.c:61
void sys_id_wave_axis_handler(uint8_t axis)
uint8_t sys_id_wave_running(void)
void sys_id_wave_activate_handler(uint8_t activate)
static const int8_t ACTIVE_WAVE_AXES[]
Definition sys_id_wave.c:63
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
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.