Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
pprz_chirp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Joost Meulenbeld
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  */
51 #ifndef PPRZ_CHIRP_H
52 #define PPRZ_CHIRP_H
53 
54 #include "std.h"
55 
59 struct chirp_t {
60  float f0_hz;
61  float f1_hz;
62  float start_time_s;
63  float length_s; // Amount of seconds of the chirp, excluding fade-in if applicable
64  float total_length_s; // Amount of seconds of the chirp, including fade-in if applicable
65 
67  float current_value; // Value is [-1, 1]
69  float percentage_done; // t / total_length: [0, 1]
70 
72  bool fade_in;
73 };
74 
84 void chirp_init(struct chirp_t *chirp, float f0_hz, float f1_hz, float length_s, float current_time_s,
85  bool exponential_chirp, bool fade_in);
86 
92 void chirp_reset(struct chirp_t *chirp, float current_time_s);
93 
97 bool chirp_is_running(struct chirp_t *chirp, float current_time_s);
98 
103 float chirp_update(struct chirp_t *chirp, float current_time_s);
104 
105 #endif
chirp_t::percentage_done
float percentage_done
Definition: pprz_chirp.h:69
chirp_t::fade_in
bool fade_in
Definition: pprz_chirp.h:72
chirp_t::f0_hz
float f0_hz
Definition: pprz_chirp.h:60
chirp_is_running
bool chirp_is_running(struct chirp_t *chirp, float current_time_s)
Return if the current_time is within the chirp manoeuvre.
Definition: pprz_chirp.c:65
chirp_t::exponential_chirp
bool exponential_chirp
Definition: pprz_chirp.h:71
chirp_t::total_length_s
float total_length_s
Definition: pprz_chirp.h:64
chirp_init
void chirp_init(struct chirp_t *chirp, float f0_hz, float f1_hz, float length_s, float current_time_s, bool exponential_chirp, bool fade_in)
Allocate and initialize a new chirp struct.
Definition: pprz_chirp.c:34
chirp_update
float chirp_update(struct chirp_t *chirp, float current_time_s)
Calculate the value at current_time_s and update the struct with current frequency and value.
Definition: pprz_chirp.c:71
chirp_reset
void chirp_reset(struct chirp_t *chirp, float current_time_s)
Reset the time of the chirp.
Definition: pprz_chirp.c:56
chirp_t::start_time_s
float start_time_s
Definition: pprz_chirp.h:62
std.h
chirp_t::current_value
float current_value
Definition: pprz_chirp.h:67
chirp
static struct chirp_t chirp
Definition: sys_id_chirp.c:59
chirp_t
Initialize with chirp_init.
Definition: pprz_chirp.h:59
chirp_t::current_frequency_hz
float current_frequency_hz
Definition: pprz_chirp.h:66
chirp_t::length_s
float length_s
Definition: pprz_chirp.h:63
chirp_t::current_time_s
float current_time_s
Definition: pprz_chirp.h:68
chirp_t::f1_hz
float f1_hz
Definition: pprz_chirp.h:61