hysteresis_controller2.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2008, Willow Garage, Inc.
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 Willow Garage 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 
00035 #ifndef _JOINT_QUALIFICATION_CONTROLLERS_HYSTERESIS_CONTROLLER_H
00036 #define _JOINT_QUALIFICATION_CONTROLLERS_HYSTERESIS_CONTROLLER_H
00037 
00038 /***************************************************/
00046 /***************************************************/
00047 
00048 #include <ros/ros.h>
00049 #include <string>
00050 #include <math.h>
00051 #include <joint_qualification_controllers/HysteresisData2.h>
00052 #include "realtime_tools/realtime_publisher.h"
00053 #include <pr2_controller_interface/controller.h>
00054 #include <robot_mechanism_controllers/joint_velocity_controller.h>
00055 #include <boost/scoped_ptr.hpp>
00056 
00057 namespace joint_qualification_controllers
00058 {
00059 
00060 class HysteresisController2 : public pr2_controller_interface::Controller
00061 {
00062 
00063 public:
00064   enum { STOPPED, MOVING_HOME, MOVING_UP, MOVING_DOWN, ANALYZING, DONE};
00065 
00066   HysteresisController2();
00067   ~HysteresisController2();
00068 
00074   bool init(pr2_mechanism_model::RobotState *robot, ros::NodeHandle &n);
00075 
00079   void starting();
00080 
00084   void analysis();
00085 
00089   void update();
00090 
00094   bool sendData();
00095   
00096   bool done() { return state_ == DONE; }
00097   
00098 
00099 private:
00100   joint_qualification_controllers::HysteresisData2 test_data_;
00101 
00102   pr2_mechanism_model::JointState *joint_;     
00103   pr2_mechanism_model::RobotState *robot_;     
00104   controller::JointVelocityController *velocity_controller_;    
00105   double velocity_;            
00106   double max_effort_;          
00107   ros::Time initial_time_;             
00108   double initial_position_;
00109   int up_count_, down_count_;
00110   std::vector<int> move_count_;
00111   int repeat_count_; // the number of repeats we'll do
00112   int repeat_;       // the current repeat
00113   bool complete;
00114 
00115   double timeout_;
00116 
00117   int state_;
00118   int starting_count_;
00119 
00120   bool data_sent_;
00121   
00122   double last_publish_time_;
00123 
00124   // RT service call
00125   boost::scoped_ptr<realtime_tools::RealtimePublisher<joint_qualification_controllers::HysteresisData2> > hyst_pub_;
00126 
00127   bool turn();
00128 
00129 };
00130 }
00131 
00132 
00133 #endif


joint_qualification_controllers
Author(s): Kevin Watts, Melonee Wise
autogenerated on Sat Dec 28 2013 17:29:55