Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00056
00057 #ifndef _HEKATEROS_AS_TRAJECTORY_H
00058 #define _HEKATEROS_AS_TRAJECTORY_H
00059
00060
00061
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
00071
00072 #include "ros/ros.h"
00073
00074
00075
00076
00077 #include "std_msgs/String.h"
00078 #include "control_msgs/FollowJointTrajectoryAction.h"
00079
00080
00081
00082
00083 #include "actionlib/server/simple_action_server.h"
00084
00085
00086
00087
00088 #include "Hekateros/hekateros.h"
00089 #include "Hekateros/hekTraj.h"
00090 #include "Hekateros/hekRobot.h"
00091
00092
00093
00094
00095 #include "hekateros_control.h"
00096
00097
00098 namespace hekateros_control
00099 {
00103 class ASFollowTrajectory
00104 {
00105 public:
00106
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),
00119 node_(node),
00120 as_(node.getNodeHandle(),
00121 name,
00122 boost::bind(&ASFollowTrajectory::execute_cb, this, _1),
00123
00124 false)
00125 {
00126
00127
00128
00129 as_.registerPreemptCallback(boost::bind(&ASFollowTrajectory::preempt_cb,
00130 this));
00131
00132
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 }
00235
00236 #endif // _HEKATEROS_AS_TRAJECTORY_H