MAV'RIC
/home/travis/build/lis-epfl/MAVRIC_Library/flight_controller/flight_controller_hexhog.hpp
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 flight_controller_hexhog.hpp
00034  *
00035  * \author MAV'RIC Team
00036  * \author Julien Lecoeur
00037  *
00038  * \brief   Flight controller for the hexhog
00039  *
00040  ******************************************************************************/
00041 
00042 #ifndef FLIGHT_CONTROLLER_HEXHOG_HPP_
00043 #define FLIGHT_CONTROLLER_HEXHOG_HPP_
00044 
00045 #include "flight_controller/flight_controller_stack.hpp"
00046 #include "control/position_controller.hpp"
00047 #include "control/velocity_controller_holonomic.hpp"
00048 #include "control/attitude_controller.hpp"
00049 #include "control/rate_controller.hpp"
00050 #include "control/servos_mix_matrix.hpp"
00051 
00055 class Flight_controller_hexhog: public Flight_controller_stack
00056 {
00057 public:
00061     struct conf_t
00062     {
00063         Position_controller::conf_t            pos_config;
00064         Velocity_controller_holonomic::conf_t  vel_config;
00065         Attitude_controller::conf_t            att_config;
00066         Rate_controller::conf_t                rate_config;
00067         Servos_mix_matrix<6>::conf_t           mix_config;
00068     };
00069 
00075     static conf_t default_config(void)
00076     {
00077         conf_t conf;
00078 
00079         conf.pos_config  = Position_controller::default_config();
00080         conf.vel_config  = Velocity_controller_holonomic::default_config();
00081         conf.att_config  = Attitude_controller::default_config();
00082         conf.rate_config = Rate_controller::default_config();
00083 
00084         float s60 = 0.866025f;
00085         conf.mix_config  = Servos_mix_matrix<6>::default_config();
00086         conf.mix_config.mix  = Mat<6, 6>({ 0.0f, -1.0f,  1.0f, -1.0f, 0.0f, -1.0f,   // rear
00087                                             s60, -0.5f, -1.0f,  0.5f,  s60, -1.0f,   // rear left
00088                                             s60,  0.5f,  1.0f,  0.5f, -s60, -1.0f,   // front left
00089                                            0.0f,  1.0f, -1.0f, -1.0f, 0.0f, -1.0f,   // front
00090                                            -s60,  0.5f,  1.0f,  0.5f,  s60, -1.0f,   // front right
00091                                            -s60, -0.5f, -1.0f,  0.5f, -s60, -1.0f}); // rear right
00092         return conf;
00093     };
00094 
00098     Flight_controller_hexhog(const INS& ins,
00099                             const AHRS& ahrs,
00100                             Servo& motor_rear,
00101                             Servo& motor_rear_left,
00102                             Servo& motor_front_left,
00103                             Servo& motor_front,
00104                             Servo& motor_front_right,
00105                             Servo& motor_rear_right,
00106                             conf_t config = default_config());
00107 
00113     bool set_manual_rate_command(const Manual_control& manual_control);
00114 
00120     bool set_manual_attitude_command(const Manual_control& manual_control);
00121 
00127     bool set_manual_velocity_command(const Manual_control& manual_control);
00128 
00129 public:
00130     Position_controller             pos_ctrl_;  
00131     Velocity_controller_holonomic   vel_ctrl_;  
00132     Attitude_controller             att_ctrl_;  
00133     Rate_controller                 rate_ctrl_; 
00134     Servos_mix_matrix<6>            mix_ctrl_;  
00135 
00136 private:
00137     const AHRS& ahrs_;                          
00138 };
00139 
00140 #endif  // FLIGHT_CONTROLLER_HEXHOG_HPP_
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines