robot_state_publisher.cpp
Go to the documentation of this file.
1 // TODO if https://github.com/ros/robot_state_publisher/pull/106 is merged, this hack can be left out
2 // HACK we cannot substitute the RobotStatePublisher in JointStateListener, so we hack it like this
3 #define protected public
4 #include <robot_state_publisher/robot_state_publisher.h>
5 #undef protected
6 
8 
9 std::string stripSlash(const std::string & in)
10 {
11  if (!in.empty() && in[0] == '/')
12  {
13  return in.substr(1);
14  }
15  return in;
16 }
17 
19 {
22 
23  auto old_segments_fixed = publisher->segments_fixed_;
24 
25  publisher->segments_.clear();
26  publisher->segments_fixed_.clear();
28 
29  // find out which segments have disappeared and publish a special TF message
30  // that disconnects them from the main TF tree
31 
32  for (const auto& seg : publisher->segments_fixed_)
33  {
34  old_segments_fixed.erase(seg.first);
35  }
36  for (const auto& seg : publisher->segments_)
37  {
38  old_segments_fixed.erase(seg.first);
39  }
40 
41  std::vector<geometry_msgs::TransformStamped> deleteTfs;
42  for (const auto& seg : old_segments_fixed)
43  {
44  geometry_msgs::TransformStamped tf;
45  tf.child_frame_id = stripSlash(seg.second.tip);
47  tf.header.stamp = ros::Time::now();
48  tf.transform.rotation.w = 1.0;
49  deleteTfs.push_back(tf);
50  }
52 }
53 
56 {}
57 
59 {
60  return publisher->segments_.size();
61 }
62 
64 {
65  return publisher->segments_fixed_.size();
66 }
std::string stripSlash(const std::string &in)
DynamicRobotStatePublisher(RobotStatePublisher *publisher)
Create the publisher.
virtual void addChildren(const KDL::SegmentMap::const_iterator segment)
RobotStatePublisher * publisher
The underlying (hacked) publisher.
std::map< std::string, SegmentPair > segments_fixed_
std::map< std::string, SegmentPair > segments_
tf2_ros::StaticTransformBroadcaster static_tf_broadcaster_
SegmentMap::const_iterator getRootSegment() const
virtual size_t getNumFixedJoints() const
Return the number of fixed joints in the currently represented model.
virtual void updateTree(const KDL::Tree &tree)
Sets the robot model.
static Time now()
const std::string DELETED_STATIC_TFS_FRAME
The TF frame name of the virtual frame that&#39;s parent of all deleted static TF frames.
void sendTransform(const geometry_msgs::TransformStamped &transform)
virtual size_t getNumMovingJoints() const
Return the number of moving joints in the currently represented model.


dynamic_robot_state_publisher
Author(s): Martin Pecka
autogenerated on Mon Jun 10 2019 13:05:57