MAV'RIC
|
00001 /******************************************************************************* 00002 * Copyright (c) 2009-2016, MAV'RIC Development Team 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 00011 * 2. Redistributions in binary form must reproduce the above copyright notice, 00012 * this list of conditions and the following disclaimer in the documentation 00013 * and/or other materials provided with the distribution. 00014 * 00015 * 3. Neither the name of the copyright holder nor the names of its contributors 00016 * may be used to endorse or promote products derived from this software without 00017 * specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00023 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00029 * POSSIBILITY OF SUCH DAMAGE. 00030 ******************************************************************************/ 00031 00032 /******************************************************************************* 00033 * \file acoustic.hpp 00034 * 00035 * \author MAV'RIC Team 00036 * \author Meysam Basiri 00037 * \author Gregoire Heitz 00038 * 00039 * \brief Acoustic communication and processing functions 00040 * 00041 ******************************************************************************/ 00042 00043 #ifndef ACOUSTIC_HPP_ 00044 #define ACOUSTIC_HPP_ 00045 00046 #include <cstdint> 00047 #include <cstdbool> 00048 00049 #include "communication/mavlink_waypoint_handler.hpp" 00050 #include "control/stabilisation_copter.hpp" 00051 #include "control/stabilisation.hpp" 00052 #include "mission/navigation.hpp" 00053 #include "sensing/ahrs.hpp" 00054 #include "sensing/ins.hpp" 00055 #include "manual_control/remote.hpp" 00056 00057 extern "C" 00058 { 00059 #include "util/streams.h" 00060 #include "buffer.h" 00061 } 00062 00063 #define STORE_SIZE 4 ///< number of azimuth/elevation values stored for reliability test 00064 #define RELIABILITY_ARC 0.25f ///< the threshold to consider a measurement as reliable (compared with previous 3 measurements) 00065 #define WAIT_LIMIT 6 ///< wait for WAITLIMIT*ACOUSTIC_TASK_ITERATION ms to recieve the new measurement, else reset reliability 00066 #define MAX_DETECTION_RANGE 100 ///< set the maximum range 00067 00068 00072 typedef struct 00073 { 00074 int16_t azimuth; 00075 int16_t elevation; 00076 bool new_data; 00077 bool reliabe_data; 00078 float reliabe_az; 00079 float reliabe_el; 00080 00081 buffer_t audio_buffer; 00082 byte_stream_t audio_stream_in; 00083 //byte_stream_t* audio_stream_out; ///< Acoustic out coming stream 00084 00085 ahrs_t* ahrs; 00086 INS* position_estimation; 00087 remote_t* remote; 00088 navigation_t* navigation; 00089 stabilisation_copter_t* stabilisation_copter; 00090 control_command_t* controls_nav; 00091 Mavlink_waypoint_handler* waypoint_handler; 00092 byte_stream_t* telemetry_down_stream; 00093 } audio_t; 00094 00095 00110 void acoustic_init(audio_t* audio_data, 00111 int32_t UID, 00112 ahrs_t* ahrs, 00113 Position_estimation* position_estimation, 00114 remote_t* remote, 00115 navigation_t* navigation, 00116 stabilisation_copter_t* stabilisation_copter, 00117 control_command_t* controls_nav, 00118 Mavlink_waypoint_handler* waypoint_handler, 00119 byte_stream_t* telemetry_down_stream); 00120 00121 00129 bool acoustic_update(audio_t* audio_data); 00130 00131 00139 void turn_off_siren(byte_stream_t* out_stream); 00140 00150 void acoustic_set_speed_command(audio_t* audio_data, float rel_pos[], float dist2wpSqr); 00151 00152 #endif