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/PIDBase.h>
00037 #include <navcon_msgs/VelConConfig.h>
00038 #include <navcon_msgs/ConfigureVelocityController.h>
00039 #include <navcon_msgs/EnableControl.h>
00040 #include <navcon_msgs/ModelParamsUpdate.h>
00041 #include <dynamic_reconfigure/server.h>
00042 
00043 #include <auv_msgs/NavSts.h>
00044 #include <auv_msgs/BodyVelocityReq.h>
00045 #include <auv_msgs/BodyForceReq.h>
00046 #include <ros/ros.h>
00047 #include <std_msgs/String.h>
00048 #include <sensor_msgs/Joy.h>
00049 
00050 #include <string>
00051 #include <map>
00052 
00053 namespace labust
00054 {
00055         namespace control
00056         {
00071                 class VelocityControl
00072                 {
00073                         enum {u=0,v,w,p,q,r};
00074                         enum {X=0,Y,Z,K,M,N};
00075                         enum {alpha=0,beta,betaa};
00076                         enum {Kp=0,Ki,Kd,Kt};
00077                         enum {disableAxis=0,
00078                                 manualAxis=1,
00079                                 controlAxis=2,
00080                                 identAxis=3,
00081                           directAxis=4};
00082                         enum {numcnt = 6};
00083 
00084                 public:
00088                         VelocityControl();
00092                         void onInit();
00096                         void step();
00100                         void start();
00101 
00102                 private:
00106                         void handleReference(const auv_msgs::BodyVelocityReq::ConstPtr& ref);
00110                         void handleEstimates(const auv_msgs::NavSts::ConstPtr& estimate);
00114                         void handleMeasurement(const auv_msgs::NavSts::ConstPtr& meas);
00118                         void handleWindup(const auv_msgs::BodyForceReq::ConstPtr& tau);
00122                         void handleModelUpdate(const navcon_msgs::ModelParamsUpdate::ConstPtr& update);
00126                         void handleExt(const auv_msgs::BodyForceReq::ConstPtr& tau);
00130                         void handleManual(const sensor_msgs::Joy::ConstPtr& joy);
00134                         bool handleServerConfig(navcon_msgs::ConfigureVelocityController::Request& req,
00135                                         navcon_msgs::ConfigureVelocityController::Response& resp);
00139                         bool handleEnableControl(navcon_msgs::EnableControl::Request& req,
00140                                         navcon_msgs::EnableControl::Response& resp);
00144                         void dynrec_cb(navcon_msgs::VelConConfig& config, uint32_t level);
00148                         void safetyTest();
00152                         void updateDynRecConfig();
00156                         ros::NodeHandle nh,ph;
00160                         ros::Time lastRef, lastMan, lastEst, lastMeas;
00164                         double timeout;
00165 
00169                         void initialize_controller();
00173                         PIDBase controller[r+1];
00177                         double measurement[r+1];
00181                         float tauManual[N+1], tauExt[N+1];
00185                         double joy_scale, Ts;
00189                         boost::array<int32_t,r+1> axis_control;
00193                         bool suspend_axis[r+1], externalIdent, use_gvel;
00197                         boost::recursive_mutex serverMux;
00198 
00202                         ros::Publisher tauOut, tauAchW;
00206                         ros::Subscriber velocityRef, stateHat, manualIn, tauAch, measSub, identExt, modelUpdate;
00210                         ros::ServiceServer highLevelSelect, enableControl;
00214                         navcon_msgs::VelConConfig config;
00218                   dynamic_reconfigure::Server<navcon_msgs::VelConConfig> server;
00222                   const static std::string dofName[r+1];
00226                   bool doSafetyTest;
00227                 };
00228         }
00229 }
00230 
00231 /* VELOCITYCONTROL_HPP_ */
00232 #endif


labust_control
Author(s): Gyula Nagy
autogenerated on Fri Aug 28 2015 11:22:42