MAV'RIC
/home/travis/build/lis-epfl/MAVRIC_Library/control/velocity_controller_holonomic.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 velocity_controller_holonomic.hpp
00034  *
00035  * \author MAV'RIC Team
00036  * \author Julien Lecoeur
00037 
00038  *
00039  * \brief A velocity controller for holonomic hovering platform capable of generating 3D thrust
00040  *
00041  * \details It takes a velocity command as input and computes an attitude
00042  * command and thrust command as output.
00043  *
00044  ******************************************************************************/
00045 
00046 
00047 #ifndef VELOCITY_CONTROLLER_HOLONOMIC_HPP_
00048 #define VELOCITY_CONTROLLER_HOLONOMIC_HPP_
00049 
00050 #include "control/velocity_controller_copter.hpp"
00051 
00055 class Velocity_controller_holonomic : public Velocity_controller_copter
00056 {
00057 public:
00061     struct conf_t: public Velocity_controller_copter::conf_t
00062     {
00063         pid_controller_conf_t attitude_offset_config[2];
00064     };
00065 
00071     static inline conf_t default_config(void);
00072 
00080     Velocity_controller_holonomic(const args_t& args, const conf_t& config = default_config());
00081 
00082 
00083 protected:
00084 
00094     virtual bool compute_attitude_and_thrust_from_desired_accel(const std::array<float,3>& accel_command,
00095                                                                 attitude_command_t& attitude_command,
00096                                                                 thrust_command_t& thrust_command);
00097 
00098 public:
00099     uint32_t          use_3d_thrust_;               
00100     uint32_t          use_3d_thrust_threshold_;     
00101     float             accel_threshold_3d_thrust_;   
00102     pid_controller_t  attitude_offset_pid_[2];      
00103 };
00104 
00105 
00106 Velocity_controller_holonomic::conf_t Velocity_controller_holonomic::default_config(void)
00107 {
00108     conf_t conf;
00109 
00110     (*(Velocity_controller_copter::conf_t*)&conf) = Velocity_controller_copter::default_config();
00111 
00112     // Do control in semilocal frame
00113     conf.control_frame = SEMILOCAL_FRAME;
00114 
00115     // -----------------------------------------------------------------
00116     // ------ ROLL OFFSET ----------------------------------------------
00117     // -----------------------------------------------------------------
00118     conf.attitude_offset_config[X]                         = {};
00119     conf.attitude_offset_config[X].p_gain                  = 0.0f;
00120     conf.attitude_offset_config[X].clip_min                = -0.5f;
00121     conf.attitude_offset_config[X].clip_max                = 0.5f;
00122     conf.attitude_offset_config[X].integrator              = {};
00123     conf.attitude_offset_config[X].integrator.gain         = 0.001f;
00124     conf.attitude_offset_config[X].integrator.clip_pre     = 0.1f;
00125     conf.attitude_offset_config[X].integrator.accumulator  = 0.0f;
00126     conf.attitude_offset_config[X].integrator.clip         = 0.5f;
00127     conf.attitude_offset_config[X].differentiator          = {};
00128     conf.attitude_offset_config[X].differentiator.gain     = 0.0f;
00129     conf.attitude_offset_config[X].differentiator.previous = 0.0f;
00130     conf.attitude_offset_config[X].differentiator.clip     = 0.0f;
00131     conf.attitude_offset_config[X].soft_zone_width         = 0.0f;
00132 
00133     // -----------------------------------------------------------------
00134     // ------ PITCH OFFSET ---------------------------------------------
00135     // -----------------------------------------------------------------
00136     conf.attitude_offset_config[Y]                         = {};
00137     conf.attitude_offset_config[Y].p_gain                  = 0.0f;
00138     conf.attitude_offset_config[Y].clip_min                = -0.5f;
00139     conf.attitude_offset_config[Y].clip_max                = 0.5f;
00140     conf.attitude_offset_config[Y].integrator              = {};
00141     conf.attitude_offset_config[Y].integrator.gain         = 0.001f;
00142     conf.attitude_offset_config[Y].integrator.clip_pre     = 0.1f;
00143     conf.attitude_offset_config[Y].integrator.accumulator  = 0.0f;
00144     conf.attitude_offset_config[Y].integrator.clip         = 0.5f;
00145     conf.attitude_offset_config[Y].differentiator          = {};
00146     conf.attitude_offset_config[Y].differentiator.gain     = 0.0f;
00147     conf.attitude_offset_config[Y].differentiator.previous = 0.0f;
00148     conf.attitude_offset_config[Y].differentiator.clip     = 0.0f;
00149     conf.attitude_offset_config[Y].soft_zone_width         = 0.0f;
00150 
00151     return conf;
00152 }
00153 
00154 #endif /* VELOCITY_CONTROLLER_HOLONOMIC_HPP_ */
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines