MAV'RIC
acoustic.h
1 /*******************************************************************************
2  * Copyright (c) 2009-2014, MAV'RIC Development Team
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  ******************************************************************************/
31 
32 /*******************************************************************************
33  * \file acoustic.h
34  *
35  * \author MAV'RIC Team
36  * \author Meysam Basiri
37  * \author Gregoire Heitz
38  *
39  * \brief Acoustic communication and processing functions
40  *
41  ******************************************************************************/
42 
43 #ifndef ACOUSTIC_H_
44 #define ACOUSTIC_H_
45 
46 
47 #ifdef __cplusplus
48 extern "C" {
49  #endif
50 
51 #include <stdint.h>
52 #include <stdbool.h>
53 #include "streams.h"
54 
55 #include "buffer.h"
56 #include "ahrs.h"
57 #include "position_estimation.h"
58 #include "remote.h"
59 #include "navigation.h"
60 #include "stabilisation_copter.h"
61 #include "stabilisation.h"
62 #include "mavlink_waypoint_handler.h"
63 #include "tasks.h"
64 
65 
66 #define STORE_SIZE 4
67 #define RELIABILITY_ARC 0.25f
68 #define WAIT_LIMIT 6
69 #define MAX_DETECTION_RANGE 100
70 
71 
75 typedef struct
76 {
77  int16_t azimuth;
78  int16_t elevation;
79  bool new_data;
80  bool reliabe_data;
81  float reliabe_az;
82  float reliabe_el;
83 
86  //byte_stream_t* audio_stream_out; ///< Acoustic out coming stream
87 
96 }audio_t;
97 
98 
113 void acoustic_init( audio_t* audio_data,
114  int32_t UID,
115  ahrs_t* ahrs,
116  position_estimation_t* position_estimation,
117  remote_t* remote,
118  navigation_t* navigation,
119  stabilisation_copter_t* stabilisation_copter,
120  control_command_t* controls_nav,
121  mavlink_waypoint_handler_t* waypoint_handler,
122  byte_stream_t* telemetry_down_stream);
123 
124 
132 task_return_t acoustic_update(audio_t* audio_data);
133 
134 
142 void turn_off_siren(byte_stream_t *out_stream);
143 
153 void acoustic_set_speed_command(audio_t* audio_data, float rel_pos[], float dist2wpSqr);
154 
155 
156 
157 #ifdef __cplusplus
158 }
159 #endif
160 
161 #endif
bool reliabe_data
The flag to tell that new data are reliable.
Definition: acoustic.h:80
Structure containing the Attitude and Heading Reference System.
Definition: ahrs.h:58
mavlink_waypoint_handler_t * waypoint_handler
The pointer to the waypoint handler structure.
Definition: acoustic.h:94
float reliabe_az
Number of reliable azimuth measurement.
Definition: acoustic.h:81
The configuration structure of the remote.
Definition: remote.h:150
ahrs_t * ahrs
The pointer to the attitude estimation structure.
Definition: acoustic.h:88
The navigation structure.
Definition: navigation.h:66
int16_t elevation
The elevation angle corresponds to the vertical orientation of the sound.
Definition: acoustic.h:78
byte_stream_t audio_stream_in
Acoustic in coming stream.
Definition: acoustic.h:85
Buffer structure.
Definition: buffer.h:61
Structure containing the pointers to the data needed in this module.
Definition: stabilisation_copter.h:82
bool new_data
The flag to tell that new data are available.
Definition: acoustic.h:79
The control command typedef.
Definition: stabilisation.h:77
stabilisation_copter_t * stabilisation_copter
The pointer to the stabilization copter structure.
Definition: acoustic.h:92
buffer_t audio_buffer
Acoustic buffer.
Definition: acoustic.h:84
Structure of the acoustic data.
Definition: acoustic.h:75
remote_t * remote
The pointer to the remote structure.
Definition: acoustic.h:90
int16_t azimuth
The azimuth angle corresponds to the horizontal orientation of the sound.
Definition: acoustic.h:77
position_estimation_t * position_estimation
The pointer to the position estimation structure.
Definition: acoustic.h:89
Byte stream.
Definition: streams.h:62
byte_stream_t * telemetry_down_stream
The pointer to the down coming telemetry byte stream.
Definition: acoustic.h:95
float reliabe_el
Number of reliable elevation measurement.
Definition: acoustic.h:82
control_command_t * controls_nav
The pointer to the control structure.
Definition: acoustic.h:93
The position estimator structure.
Definition: position_estimation.h:79
navigation_t * navigation
The pointer to the navigation control structure.
Definition: acoustic.h:91