Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
pprz_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 */
27#include "std.h"
28#include "math.h"
29
30#include "pprz_wave.h"
31
32
33void wave_init(struct wave_t *wave, float start_time_s, float current_time_s, float frequency_hz, float lag_rad)
34{
35 wave->start_time_s = start_time_s;
36 wave->current_time_s = current_time_s;
37 wave->lag_rad = lag_rad;
38 wave->frequency_hz = frequency_hz;
39 wave->is_running = false;
40 wave->current_value = 0.0f;
41
42
43}
44
45void wave_reset(struct wave_t *wave, float current_time_s)
46{
47 wave->start_time_s = current_time_s;
48 wave->current_time_s = current_time_s;
49 wave->current_value = 0.0f;
50}
51
53
54 return wave->is_running;
55}
56
57float wave_update(struct wave_t *wave, float current_time_s){
58 float frequency_rad = wave->frequency_hz * 2 * M_PI;
59 float t = current_time_s - wave->start_time_s;
60 wave->current_value = sinf(t*frequency_rad + wave->lag_rad);
61 return wave->current_value;
62}
uint16_t foo
Definition main_demo5.c:58
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