joint_spline_trajectory_action_controller.hpp
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    /* bool queryStateService(pr2_controllers_msgs::QueryTrajectoryState::Request &req,
00051                          pr2_controllers_msgs::QueryTrajectoryState::Response &resp);
00052   ros::ServiceServer serve_query_state_;*/
00053 
00054     
00055     // coef[0] + coef[1]*t + ... + coef[5]*t^5
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;  // Preallocated in init
00072 
00073   // Samples, but handling time bounds.  When the time is past the end
00074   // of the spline duration, the position is the last valid position,
00075   // and the derivatives are all 0.
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 /* For the emacs weenies in the crowd.
00089 Local Variables:
00090    c-basic-offset: 2
00091 End:
00092 */
00093 
00094 #endif
00095 
00096 


sr_mechanism_controllers
Author(s): Ugo Cupcic
autogenerated on Fri Aug 28 2015 13:09:56