VelocityControl.hpp
Go to the documentation of this file.
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 *
00004 *  Copyright (c) 2010, LABUST, UNIZG-FER
00005 *  All rights reserved.
00006 *
00007 *  Redistribution and use in source and binary forms, with or without
00008 *  modification, are permitted provided that the following conditions
00009 *  are met:
00010 *
00011 *   * Redistributions of source code must retain the above copyright
00012 *     notice, this list of conditions and the following disclaimer.
00013 *   * Redistributions in binary form must reproduce the above
00014 *     copyright notice, this list of conditions and the following
00015 *     disclaimer in the documentation and/or other materials provided
00016 *     with the distribution.
00017 *   * Neither the name of the LABUST nor the names of its
00018 *     contributors may be used to endorse or promote products derived
00019 *     from this software without specific prior written permission.
00020 *
00021 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 *  POSSIBILITY OF SUCH DAMAGE.
00033 *********************************************************************/
00034 #ifndef VELOCITYCONTROL_HPP_
00035 #define VELOCITYCONTROL_HPP_
00036 #include <labust/control/PIDController.h>
00037 #include <labust/control/SOIdentification.hpp>
00038 #include <labust_uvapp/VelConConfig.h>
00039 #include <labust_uvapp/ConfigureVelocityController.h>
00040 #include <labust_uvapp/EnableControl.h>
00041 #include <navcon_msgs/ModelParamsUpdate.h>
00042 #include <dynamic_reconfigure/server.h>
00043 
00044 #include <auv_msgs/NavSts.h>
00045 #include <auv_msgs/BodyVelocityReq.h>
00046 #include <auv_msgs/BodyForceReq.h>
00047 #include <ros/ros.h>
00048 #include <std_msgs/String.h>
00049 #include <sensor_msgs/Joy.h>
00050 
00051 #include <string>
00052 #include <map>
00053 
00054 namespace labust
00055 {
00056         namespace control
00057         {
00063                 class VelocityControl
00064                 {
00065                         enum {u=0,v,w,p,q,r};
00066                         enum {X=0,Y,Z,K,M,N};
00067                         enum {alpha=0,beta,betaa};
00068                         enum {Kp=0,Ki,Kd,Kt};
00069                         enum {disableAxis=0,
00070                                 manualAxis=1,
00071                                 controlAxis=2,
00072                                 identAxis=3,
00073                           directAxis=4};
00074 
00075                 public:
00079                         VelocityControl();
00083                         void onInit();
00087                         void step();
00091                         void start();
00092 
00093                 private:
00097                         void handleReference(const auv_msgs::BodyVelocityReq::ConstPtr& ref);
00101                         void handleEstimates(const auv_msgs::NavSts::ConstPtr& estimate);
00105                         void handleMeasurement(const auv_msgs::NavSts::ConstPtr& meas);
00109                         void handleWindup(const auv_msgs::BodyForceReq::ConstPtr& tau);
00113                         void handleModelUpdate(const navcon_msgs::ModelParamsUpdate::ConstPtr& update);
00117                         void handleExt(const auv_msgs::BodyForceReq::ConstPtr& tau);
00121                         void handleManual(const sensor_msgs::Joy::ConstPtr& joy);
00125                         bool handleServerConfig(labust_uvapp::ConfigureVelocityController::Request& req,
00126                                         labust_uvapp::ConfigureVelocityController::Response& resp);
00130                         bool handleEnableControl(labust_uvapp::EnableControl::Request& req,
00131                                         labust_uvapp::EnableControl::Response& resp);
00135                         void dynrec_cb(labust_uvapp::VelConConfig& config, uint32_t level);
00139                         void safetyTest();
00143                         void updateDynRecConfig();
00147                         double doIdentification(int i);
00151                         ros::NodeHandle nh,ph;
00155                         ros::Time lastRef, lastMan, lastEst, lastMeas;
00159                         double timeout;
00160 
00164                         void initialize_controller();
00168                         PIDController controller[r+1];
00172                         boost::shared_ptr<SOIdentification> ident[r+1];
00176                         double measurement[r+1];
00180                         float tauManual[N+1], tauExt[N+1];
00184                         double joy_scale, Ts;
00188                         boost::array<int32_t,r+1> axis_control;
00192                         bool suspend_axis[r+1], externalIdent;
00196                         boost::recursive_mutex serverMux;
00197 
00201                         ros::Publisher tauOut, tauAchW;
00205                         ros::Subscriber velocityRef, stateHat, manualIn, tauAch, measSub, identExt, modelUpdate;
00209                         ros::ServiceServer highLevelSelect, enableControl;
00213                         labust_uvapp::VelConConfig config;
00217                   dynamic_reconfigure::Server<labust_uvapp::VelConConfig> server;
00221                   const static std::string dofName[r+1];
00222                 };
00223         }
00224 }
00225 
00226 /* VELOCITYCONTROL_HPP_ */
00227 #endif


labust_uvapp
Author(s): Dula Nad
autogenerated on Fri Feb 7 2014 11:36:37