joint_spline_trajectory_action_controller.hpp
Go to the documentation of this file.
1 
29 #ifndef _SR_JOINT_TRAJECTORY_ACTION_CONTROLLER_H_
30 #define _SR_JOINT_TRAJECTORY_ACTION_CONTROLLER_H_
31 
32 #include <ros/ros.h>
33 
34 #include <map>
35 #include <string>
36 #include <vector>
38 #include <control_msgs/FollowJointTrajectoryAction.h>
39 
40 
41 namespace shadowrobot
42 {
44 {
46 public:
48 
49 private:
55  std::vector<std::string> joint_names_;
57  std::map<std::string, double> joint_state_map;
58 
59  std::vector<ros::Publisher> controller_publishers; // This vector stores publishers to each joint controller.
60  std::map<std::string, std::string> jointControllerMap; // stores a map of controller name and associated joints
61  std::map<std::string, unsigned int> jointPubIdxMap; // stores a map of publisher associated with joint index
62  std::map<std::string, unsigned int> joint_state_idx_map; // store internal order of joints
64 
67 
68  // coef[0] + coef[1]*t + ... + coef[5]*t^5
69  struct Spline
70  {
71  std::vector<double> coef;
72 
73  Spline() : coef(6, 0.0)
74  {
75  }
76  };
77 
78  struct Segment
79  {
80  double start_time;
81  double duration;
82  std::vector<Spline> splines;
83  };
84  typedef std::vector<Segment> SpecifiedTrajectory;
85 
86  std::vector<double> q, qd, qdd; // Preallocated in init
87 
88  // Samples, but handling time bounds. When the time is past the end
89  // of the spline duration, the position is the last valid position,
90  // and the derivatives are all 0.
91  static void sampleSplineWithTimeBounds(const std::vector<double> &coefficients, double duration, double time,
92  double &position, double &velocity, double &acceleration);
93 
94 
95  void execute_trajectory(const control_msgs::FollowJointTrajectoryGoalConstPtr &goal);
96 
97  void commandCB(const trajectory_msgs::JointTrajectoryConstPtr &msg);
98 
99  void updateJointState();
100 
101  bool getPosition(std::string joint_name, double &position);
102 };
103 } // namespace shadowrobot
104 
105 /* For the emacs weenies in the crowd.
106 Local Variables:
107  c-basic-offset: 2
108 End:
109 */
110 
111 #endif
112 
113 
void commandCB(const trajectory_msgs::JointTrajectoryConstPtr &msg)
static void sampleSplineWithTimeBounds(const std::vector< double > &coefficients, double duration, double time, double &position, double &velocity, double &acceleration)
actionlib::SimpleActionServer< control_msgs::FollowJointTrajectoryAction > JTAS
void execute_trajectory(const control_msgs::FollowJointTrajectoryGoalConstPtr &goal)


sr_mechanism_controllers
Author(s): Ugo Cupcic
autogenerated on Tue Oct 13 2020 03:55:58