dynamic_graph_manager
ros_robot_state_publisher.hpp
Go to the documentation of this file.
1 
10 #ifndef ROS_ROBOT_STATE_PUBLISHER_HPP
11 #define ROS_ROBOT_STATE_PUBLISHER_HPP
12 
13 #include <deque>
14 #include <memory>
15 
16 #include <dynamic-graph/all-commands.h>
17 #include <dynamic-graph/all-signals.h>
18 #include <dynamic-graph/entity.h>
19 #include <dynamic-graph/factory.h>
20 #include <dynamic-graph/linear-algebra.h>
21 
22 #include <realtime_tools/realtime_publisher.h>
23 #include <ros/ros.h>
24 #include <sensor_msgs/JointState.h>
25 #include <tf2_msgs/TFMessage.h>
26 
30 namespace dynamic_graph
31 {
35 typedef dynamicgraph::SignalTimeDependent<int, int> SignalOUT;
39 typedef dynamicgraph::SignalPtr<dynamicgraph::Vector, int> SignalIN;
43 typedef boost::function<void(int)> callback_t;
44 
48 typedef realtime_tools::RealtimePublisher<tf2_msgs::TFMessage> TfRtPublisher;
49 
53 typedef realtime_tools::RealtimePublisher<sensor_msgs::JointState>
55 
57 {
58  std::shared_ptr<TfRtPublisher> base_tf_publisher_;
59  std::shared_ptr<JointStateRtPublisher> joint_state_publisher_;
60  std::shared_ptr<SignalIN> robot_state_input_signal_;
61  callback_t callback_function_;
62 };
63 
67 class RosRobotStatePublisher : public dynamicgraph::Entity
68 {
69 public:
70  RosRobotStatePublisher(const std::string& name);
71 
73  {
74  }
75 
84  void add(const std::string& base_link_name,
85  const std::string& joint_names,
86  const std::string& tf_prefix,
87  const std::string& signal_name,
88  const std::string& joint_state_topic_name);
89 
95  int& trigger(int&, int);
96 
100  void send_data(const RosRobotStatePublisherInternal& publisher, int time);
101 
102 private:
106  static const std::string CLASS_NAME;
107 
113  virtual const std::string& getClassName(void) const
114  {
115  return CLASS_NAME;
116  }
117 
123  void set_tf_msg_to_identity(geometry_msgs::TransformStamped& msg);
124 
130  void normalize_tf_msg_quaternion(geometry_msgs::TransformStamped& msg);
131 
137  SignalOUT trigger_signal_;
138 
143  ros::NodeHandle& ros_node_handle_;
144 
150  std::map<std::string, RosRobotStatePublisherInternal> publishers_;
151 
155  ros::Duration rate_;
156 
161 };
162 } // namespace dynamic_graph
163 
164 namespace dynamicgraph
165 {
169 namespace command
170 {
174 namespace ros_state_publish
175 {
176 using ::dynamicgraph::command::Command;
177 using ::dynamicgraph::command::Value;
178 
183 // Define here a macro that automatically generates a command
184 #define ROS_PUBLISH_MAKE_COMMAND(CMD) \
185  class CMD : public Command \
186  { \
187  public: \
188  CMD(dynamic_graph::RosRobotStatePublisher& entity, \
189  const std::string& docstring); \
190  virtual Value doExecute(); \
191  }
192 
193 // Generate a couple of command classes
195 // Later in the code no one must have access to this macro.
196 #undef ROS_PUBLISH_MAKE_COMMAND
197 } // end of namespace ros_state_publish
198 } // end of namespace command
199 } // end of namespace dynamicgraph
200 
201 #endif // ROS_ROBOT_STATE_PUBLISHER_HPP
SignalOUT trigger_signal_
Create an internal output signal which should be call periodically in the device in order to publish ...
Definition: ros_robot_state_publisher.hpp:137
boost::function< void(int)> callback_t
Simple shortcut for code writing convenience.
Definition: ros_robot_state_publisher.hpp:43
#define ROS_PUBLISH_MAKE_COMMAND(CMD)
Declare here a couple of python command used for the ros_state publisher.
Definition: ros_robot_state_publisher.hpp:184
ros::NodeHandle & ros_node_handle_
Ros node handle corresponding to the dynamic graph process node handle.
Definition: ros_robot_state_publisher.hpp:143
static const std::string CLASS_NAME
The class name used to identify it in the dynamic graph pool.
Definition: ros_robot_state_publisher.hpp:106
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > SignalIN
Simple shortcut for code writing convenience.
Definition: ros_robot_state_publisher.hpp:39
ros::Time last_time_of_publication_
Check at what time the publication was done.
Definition: ros_robot_state_publisher.hpp:160
ros::Duration rate_
manage the rate data publication in topics
Definition: ros_robot_state_publisher.hpp:155
realtime_tools::RealtimePublisher< sensor_msgs::JointState > JointStateRtPublisher
Renaming of the joint position publisher type.
Definition: ros_robot_state_publisher.hpp:54
std::map< std::string, RosRobotStatePublisherInternal > publishers_
This is the list of publishers registered for this class.
Definition: ros_robot_state_publisher.hpp:150
realtime_tools::RealtimePublisher< tf2_msgs::TFMessage > TfRtPublisher
Renaming of the tf publisher type.
Definition: ros_robot_state_publisher.hpp:48
This class define a dynamic graph wrapper around the vicon client.
Definition: ros_robot_state_publisher.hpp:67
this is this package namespace in order to avoid naming conflict
Definition: device.hh:22
virtual const std::string & getClassName(void) const
Get the CLASS_NAME object.
Definition: ros_robot_state_publisher.hpp:113
Definition: ros_robot_state_publisher.hpp:56
Definition of the command.
Definition: ros_robot_state_publisher.hpp:164
dynamicgraph::SignalTimeDependent< int, int > SignalOUT
Simple shortcut for code writing convenience.
Definition: ros_robot_state_publisher.hpp:35