rt_publisher.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017, 2018 Simon Rasmussen (refactor)
3  *
4  * Copyright 2015, 2016 Thomas Timm Andersen (original version)
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 
21 #include <geometry_msgs/PoseStamped.h>
22 #include <geometry_msgs/TwistStamped.h>
23 #include <geometry_msgs/WrenchStamped.h>
24 #include <ros/ros.h>
25 #include <sensor_msgs/JointState.h>
26 #include <sensor_msgs/Temperature.h>
27 #include <tf/tf.h>
29 #include <cstdlib>
30 #include <vector>
31 
33 
34 using namespace ros;
35 using namespace tf;
36 
37 const std::string JOINTS[] = { "shoulder_pan_joint", "shoulder_lift_joint", "elbow_joint",
38  "wrist_1_joint", "wrist_2_joint", "wrist_3_joint" };
39 // links with origin in the joints configured above.
40 const std::string LINKS[] = { "shoulder_link", "upper_arm_link", "forearm_link",
41  "wrist_1_link", "wrist_2_link", "wrist_3_link" };
42 
44 {
45 private:
52  std::vector<std::string> joint_names_;
53  std::vector<std::string> link_names_;
54  std::string base_frame_;
55  std::string tool_frame_;
56  bool temp_only_;
57 
58  bool publishJoints(RTShared& packet, Time& t);
59  bool publishWrench(RTShared& packet, Time& t);
60  bool publishTool(RTShared& packet, Time& t);
61  bool publishTransform(RTShared& packet, Time& t);
62  bool publishTemperature(RTShared& packet, Time& t);
63 
64  bool publish(RTShared& packet);
65 
66 public:
67  RTPublisher(std::string& joint_prefix, std::string& base_frame, std::string& tool_frame, bool temp_only = false)
68  : joint_pub_(nh_.advertise<sensor_msgs::JointState>("joint_states", 1))
69  , wrench_pub_(nh_.advertise<geometry_msgs::WrenchStamped>("wrench", 1))
70  , tool_vel_pub_(nh_.advertise<geometry_msgs::TwistStamped>("tool_velocity", 1))
71  , joint_temperature_pub_(nh_.advertise<sensor_msgs::Temperature>("joint_temperature", 1))
72  , base_frame_(base_frame)
73  , tool_frame_(tool_frame)
74  , temp_only_(temp_only)
75  {
76  for (auto const& j : JOINTS)
77  {
78  joint_names_.push_back(joint_prefix + j);
79  }
80  for (auto const& link : LINKS)
81  {
82  link_names_.push_back(joint_prefix + link);
83  }
84  }
85 
86  virtual bool consume(RTState_V1_6__7& state);
87  virtual bool consume(RTState_V1_8& state);
88  virtual bool consume(RTState_V3_0__1& state);
89  virtual bool consume(RTState_V3_2__3& state);
90 
91  virtual void setupConsumer()
92  {
93  }
94  virtual void teardownConsumer()
95  {
96  }
97  virtual void stopConsumer()
98  {
99  }
100 };
NodeHandle nh_
Definition: rt_publisher.h:46
std::string tool_frame_
Definition: rt_publisher.h:55
Publisher joint_temperature_pub_
Definition: rt_publisher.h:50
RTPublisher(std::string &joint_prefix, std::string &base_frame, std::string &tool_frame, bool temp_only=false)
Definition: rt_publisher.h:67
const std::string LINKS[]
Definition: rt_publisher.h:40
Publisher tool_vel_pub_
Definition: rt_publisher.h:49
Publisher wrench_pub_
Definition: rt_publisher.h:48
std::vector< std::string > link_names_
Definition: rt_publisher.h:53
TransformBroadcaster transform_broadcaster_
Definition: rt_publisher.h:51
std::string base_frame_
Definition: rt_publisher.h:54
const std::string JOINTS[]
Definition: rt_publisher.h:37
virtual void teardownConsumer()
Definition: rt_publisher.h:94
virtual void stopConsumer()
Definition: rt_publisher.h:97
bool temp_only_
Definition: rt_publisher.h:56
Publisher joint_pub_
Definition: rt_publisher.h:47
virtual void setupConsumer()
Definition: rt_publisher.h:91
std::vector< std::string > joint_names_
Definition: rt_publisher.h:52


ur_modern_driver
Author(s): Thomas Timm Andersen, Simon Rasmussen
autogenerated on Fri Jun 26 2020 03:37:00