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 mavrinux.hpp 00034 * 00035 * \author MAV'RIC Team 00036 * 00037 * \brief Emulated board running on linux 00038 * 00039 ******************************************************************************/ 00040 00041 00042 #ifndef MAVRINUX_HPP_ 00043 #define MAVRINUX_HPP_ 00044 00045 00046 #include "sensing/imu.hpp" 00047 00048 #include "hal/dummy/gpio_dummy.hpp" 00049 #include "hal/dummy/serial_dummy.hpp" 00050 #include "hal/dummy/adc_dummy.hpp" 00051 #include "hal/dummy/pwm_dummy.hpp" 00052 #include "hal/dummy/led_dummy.hpp" 00053 #include "hal/dummy/i2c_dummy.hpp" 00054 00055 #include "hal/linux/serial_linux_io.hpp" 00056 #include "hal/linux/serial_udp.hpp" 00057 #include "hal/linux/file_linux.hpp" 00058 00059 #include "drivers/spektrum_satellite.hpp" 00060 #include "drivers/state_display_mavrinux.hpp" 00061 #include "drivers/airspeed_analog.hpp" 00062 #include "drivers/battery.hpp" 00063 #include "drivers/servo.hpp" 00064 #include "drivers/px4flow_i2c.hpp" 00065 00066 #include "simulation/simulation.hpp" 00067 #include "simulation/dynamic_model_quad_diag.hpp" 00068 00069 extern "C" 00070 { 00071 #include "util/streams.h" 00072 } 00073 00074 00078 typedef struct 00079 { 00080 imu_conf_t imu_config; 00081 serial_udp_conf_t serial_udp_config; 00082 std::string flash_filename; 00083 dynamic_model_quad_diag_conf_t dynamic_model_config; 00084 } mavrinux_conf_t; 00085 00086 00092 static inline mavrinux_conf_t mavrinux_default_config(); 00093 00094 00099 class Mavrinux 00100 { 00101 public: 00107 Mavrinux(mavrinux_conf_t config = mavrinux_default_config()); 00108 00109 00115 bool init(void); 00116 00117 00121 Pwm_dummy pwm_0; 00122 Pwm_dummy pwm_1; 00123 Pwm_dummy pwm_2; 00124 Pwm_dummy pwm_3; 00125 Pwm_dummy pwm_4; 00126 Pwm_dummy pwm_5; 00127 Pwm_dummy pwm_6; 00128 Pwm_dummy pwm_7; 00129 Servo servo_0; 00130 Servo servo_1; 00131 Servo servo_2; 00132 Servo servo_3; 00133 Servo servo_4; 00134 Servo servo_5; 00135 Servo servo_6; 00136 Servo servo_7; 00137 00138 Dynamic_model_quad_diag dynamic_model; 00139 Simulation sim; 00140 Imu imu; 00141 00142 I2c_dummy i2c_dummy; 00143 PX4Flow_i2c flow; 00144 00145 Adc_dummy adc_battery; 00146 Battery battery; 00147 00148 Adc_dummy adc_airspeed; 00149 Airspeed_analog airspeed_analog; 00150 00151 Gpio_dummy dsm_receiver_pin; 00152 Gpio_dummy dsm_power_pin; 00153 Serial_dummy dsm_serial; 00154 Spektrum_satellite spektrum_satellite; 00155 Led_dummy led; 00156 00157 Serial_udp mavlink_serial; 00158 Serial_linux_io debug_serial; 00159 00160 File_linux file_flash; 00161 00162 State_display_mavrinux state_display_mavrinux_; 00163 00164 private: 00165 mavrinux_conf_t config_; 00166 byte_stream_t dbg_stream_; 00167 }; 00168 00169 00175 static inline mavrinux_conf_t mavrinux_default_config() 00176 { 00177 mavrinux_conf_t conf = {}; 00178 00179 // ------------------------------------------------------------------------- 00180 // Imu config 00181 // ------------------------------------------------------------------------- 00182 conf.imu_config = imu_default_config(); 00183 00184 // ------------------------------------------------------------------------- 00185 // UDP config 00186 // ------------------------------------------------------------------------- 00187 conf.serial_udp_config = serial_udp_default_config(); 00188 00189 // ------------------------------------------------------------------------- 00190 // Flash config 00191 // ------------------------------------------------------------------------- 00192 conf.flash_filename = "flash000.bin"; 00193 00194 // ------------------------------------------------------------------------- 00195 // Simulation dynamic model config 00196 // ------------------------------------------------------------------------- 00197 conf.dynamic_model_config = dynamic_model_quad_diag_default_config(); 00198 00199 return conf; 00200 } 00201 00202 00203 #endif /* MAVRINUX_HPP_ */