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 flight_controller_stack.hpp 00034 * 00035 * \author MAV'RIC Team 00036 * \author Basil Huber 00037 * \author Julien Lecoeur 00038 * 00039 * \brief Base class for cascade style controller hierarchy 00040 * 00041 ******************************************************************************/ 00042 00043 00044 #ifndef FLIGHT_CONTROLLER_STACK_HPP_ 00045 #define FLIGHT_CONTROLLER_STACK_HPP_ 00046 00047 #include "control/control_command.hpp" 00048 #include "control/controller.hpp" 00049 #include "flight_controller/flight_controller.hpp" 00050 #include "control/servos_mix.hpp" 00051 00055 class Flight_controller_stack: public Flight_controller 00056 { 00057 public: 00058 typedef Controller< position_command_t, velocity_command_t> pos_ctrl_t; 00059 typedef Controller_1_to_2<velocity_command_t, attitude_command_t, thrust_command_t> vel_ctrl_t; 00060 typedef Controller<attitude_command_t, rate_command_t> att_ctrl_t; 00061 typedef Controller<rate_command_t, torque_command_t> rate_ctrl_t; 00062 typedef Servos_mix mix_ctrl_t; 00063 00073 Flight_controller_stack(pos_ctrl_t& pos_ctrl, 00074 vel_ctrl_t& vel_ctrl, 00075 att_ctrl_t& att_ctrl, 00076 rate_ctrl_t& rate_ctrl, 00077 mix_ctrl_t& mix_ctrl); 00078 00079 00086 virtual bool update(void); 00087 00088 00092 bool failsafe(void); 00093 00094 00101 bool set_command(const position_command_t& position); 00102 bool set_command(const velocity_command_t& velocity); 00103 bool set_command(const attitude_command_t& attitude); 00104 bool set_command(const rate_command_t& rate); 00105 bool set_command(const torque_command_t& torque); 00106 bool set_command(const thrust_command_t& thrust); 00107 00111 bool get_command(position_command_t& position) const; 00112 bool get_command(velocity_command_t& velocity) const; 00113 bool get_command(attitude_command_t& attitude) const; 00114 bool get_command(rate_command_t& rate) const; 00115 bool get_command(torque_command_t& torque) const; 00116 bool get_command(thrust_command_t& thrust) const; 00117 bool get_output(empty_command_t& command) const; 00118 00119 protected: 00123 bool update_in_thrust_and_torque_mode(void); 00124 00128 bool update_in_thrust_and_rate_mode(void); 00129 00133 bool update_in_thrust_and_attitude_mode(void); 00134 00138 bool update_in_velocity_mode(void); 00139 00143 bool update_in_position_mode(void); 00144 00145 00146 protected: 00147 command_t command_; 00148 00149 private: 00150 pos_ctrl_t& pos_ctrl_; 00151 vel_ctrl_t& vel_ctrl_; 00152 att_ctrl_t& att_ctrl_; 00153 rate_ctrl_t& rate_ctrl_; 00154 mix_ctrl_t& mix_ctrl_; 00155 }; 00156 00157 #endif /* FLIGHT_CONTROLLER_STACK_HPP_ */