Go to the documentation of this file.00001
00013 #ifndef _SR_JOINT_TRAJECTORY_ACTION_CONTROLLER_H_
00014 #define _SR_JOINT_TRAJECTORY_ACTION_CONTROLLER_H_
00015 #include <ros/ros.h>
00016
00017 #include <actionlib/server/simple_action_server.h>
00018 #include <control_msgs/FollowJointTrajectoryAction.h>
00019
00020
00021
00022 namespace shadowrobot
00023 {
00024 class JointTrajectoryActionController
00025 {
00026 typedef actionlib::SimpleActionServer<control_msgs::FollowJointTrajectoryAction> JTAS;
00027 public:
00028 JointTrajectoryActionController();
00029 ~JointTrajectoryActionController();
00030
00031 private:
00032 ros::NodeHandle nh, nh_tilde;
00033 ros::Subscriber command_sub;
00034 ros::Publisher sr_arm_target_pub;
00035 ros::Publisher sr_hand_target_pub;
00036 ros::Publisher desired_joint_state_pusblisher;
00037 std::vector<std::string> joint_names_;
00038 ros::ServiceClient joint_state_client;
00039 std::map<std::string,double> joint_state_map;
00040
00041 std::vector< ros::Publisher > controller_publishers;
00042 std::map<std::string,std::string> jointControllerMap;
00043 std::map<std::string,unsigned int> jointPubIdxMap;
00044 std::map<std::string,unsigned int> joint_state_idx_map;
00045 bool use_sendupdate;
00046
00047 ros::Time last_time_;
00048 boost::shared_ptr<JTAS> action_server;
00049
00050
00051
00052
00053
00054
00055
00056 struct Spline
00057 {
00058 std::vector<double> coef;
00059
00060 Spline() : coef(6, 0.0) {}
00061 };
00062
00063 struct Segment
00064 {
00065 double start_time;
00066 double duration;
00067 std::vector<Spline> splines;
00068 };
00069 typedef std::vector<Segment> SpecifiedTrajectory;
00070
00071 std::vector<double> q, qd, qdd;
00072
00073
00074
00075
00076 static void sampleSplineWithTimeBounds(const std::vector<double>& coefficients, double duration, double time,
00077 double& position, double& velocity, double& acceleration);
00078
00079
00080 void execute_trajectory(const control_msgs::FollowJointTrajectoryGoalConstPtr& goal);
00081 void commandCB(const trajectory_msgs::JointTrajectoryConstPtr &msg);
00082 void updateJointState();
00083 bool getPosition(std::string joint_name, double &position);
00084
00085 };
00086 }
00087
00088
00089
00090
00091
00092
00093
00094 #endif
00095
00096