hekateros_as_follow_traj.h
Go to the documentation of this file.
00001 
00002 //
00003 // Package:   RoadNarrows Robotics Hekateros Robotiic Manipulator ROS Package
00004 //
00005 // Link:      https://github.com/roadnarrows-robotics/hekateros
00006 //
00007 // ROS Node:  hekateros_control
00008 //
00009 // File:      hekateros_as_follow_traj.h
00010 //
00026 /*
00027  * @EulaBegin@
00028  * 
00029  * Permission is hereby granted, without written agreement and without
00030  * license or royalty fees, to use, copy, modify, and distribute this
00031  * software and its documentation for any purpose, provided that
00032  * (1) The above copyright notice and the following two paragraphs
00033  * appear in all copies of the source code and (2) redistributions
00034  * including binaries reproduces these notices in the supporting
00035  * documentation.   Substantial modifications to this software may be
00036  * copyrighted by their authors and need not follow the licensing terms
00037  * described here, provided that the new terms are clearly indicated in
00038  * all files where they apply.
00039  * 
00040  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
00041  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
00042  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
00043  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
00044  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
00045  * THE POSSIBILITY OF SUCH DAMAGE.
00046  * 
00047  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
00048  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
00049  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
00050  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
00051  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
00052  * 
00053  * @EulaEnd@
00054  */
00056 
00057 #ifndef _HEKATEROS_AS_TRAJECTORY_H
00058 #define _HEKATEROS_AS_TRAJECTORY_H
00059 
00060 //
00061 // System and Boost
00062 //
00063 #include <sys/types.h>
00064 #include <unistd.h>
00065 #include <math.h>
00066 #include <boost/bind.hpp>
00067 #include <string>
00068 
00069 //
00070 // ROS
00071 //
00072 #include "ros/ros.h"
00073 
00074 //
00075 // ROS generated core, industrial, and hekateros messages.
00076 //
00077 #include "std_msgs/String.h"
00078 #include "control_msgs/FollowJointTrajectoryAction.h"
00079 
00080 //
00081 // ROS generated action servers.
00082 //
00083 #include "actionlib/server/simple_action_server.h"
00084 
00085 //
00086 // RoadNarrows embedded hekateros library.
00087 //
00088 #include "Hekateros/hekateros.h"
00089 #include "Hekateros/hekTraj.h"
00090 #include "Hekateros/hekRobot.h"
00091 
00092 //
00093 // Node headers.
00094 //
00095 #include "hekateros_control.h"
00096 
00097 
00098 namespace hekateros_control
00099 {
00103   class ASFollowTrajectory
00104   {
00105   public:
00106     // Monitoring tuning. Position tolerances are in radians.
00107     static const double TolWaypoint;  
00108     static const double TolGoal;      
00109     static const int    MaxIters;     
00110 
00117     ASFollowTrajectory(std::string name, HekaterosControl &node) :
00118       action_name_(name),       // action name
00119       node_(node),              // hekateros node
00120       as_(node.getNodeHandle(), // simple action server
00121           name,                       // action name
00122           boost::bind(&ASFollowTrajectory::execute_cb, this, _1),
00123                                       // execute callback
00124           false)                      // don't auto-start
00125     {
00126       // 
00127       // Optionally register the goal and feeback callbacks
00128       //
00129       as_.registerPreemptCallback(boost::bind(&ASFollowTrajectory::preempt_cb,
00130                                   this));
00131 
00132       // start the action server
00133       start();
00134     }
00135 
00139     virtual ~ASFollowTrajectory()
00140     {
00141     }
00142 
00146     void start()
00147     {
00148       as_.start();
00149     }
00150 
00159     void execute_cb(
00160                   const control_msgs::FollowJointTrajectoryGoalConstPtr &goal);
00161 
00168     void preempt_cb();
00169 
00170   protected:
00171     std::string       action_name_;         
00172     HekaterosControl &node_;                
00173     actionlib::SimpleActionServer<control_msgs::FollowJointTrajectoryAction>
00174                                       as_;  
00175     control_msgs::FollowJointTrajectoryFeedback feedback_;
00177     control_msgs::FollowJointTrajectoryResult   result_;
00179 
00180     double  m_fTolerance;                   
00181     double  m_fWaypointDist;                
00182     int     m_iterMonitor;                  
00183 
00192     int moveToWaypoint(trajectory_msgs::JointTrajectory &jt, ssize_t iWaypoint);
00193 
00200     void monitorMove(trajectory_msgs::JointTrajectory &jt, ssize_t iWaypoint);
00201 
00210     bool atWaypoint(trajectory_msgs::JointTrajectory &jt, ssize_t iWaypoint)
00211     {
00212       return fabs(m_fWaypointDist) < m_fTolerance;
00213     }
00214 
00223     bool failedWaypoint(trajectory_msgs::JointTrajectory &jt,
00224                         ssize_t iWaypoint);
00225 
00231     void publishFeedback(ssize_t iWaypoint);
00232   };
00233 
00234 } // namespace hekateros_control
00235 
00236 #endif // _HEKATEROS_AS_TRAJECTORY_H


hekateros_control
Author(s): Robin Knight , Daniel Packard
autogenerated on Mon Oct 6 2014 00:36:42