@@ -132,24 +132,35 @@ class OdometryController: public GeomController<hardware_interface::JointStateIn
132
132
ros::Time stop_time_;
133
133
134
134
135
- void publish (const ros::TimerEvent&){
135
+ void publish (const ros::TimerEvent& event ){
136
136
if (!isRunning ()) return ;
137
137
138
138
boost::mutex::scoped_lock lock (mutex_);
139
139
140
140
topic_pub_odometry_.publish (odom_);
141
141
142
142
if (tf_broadcast_odometry_){
143
- // compose and publish transform for tf package
144
- // compose header
145
- odom_tf_.header .stamp = odom_.header .stamp ;
146
- // compose data container
147
- odom_tf_.transform .translation .x = odom_.pose .pose .position .x ;
148
- odom_tf_.transform .translation .y = odom_.pose .pose .position .y ;
149
- odom_tf_.transform .rotation = odom_.pose .pose .orientation ;
150
-
151
- // publish the transform (for debugging, conflicts with robot-pose-ekf)
152
- tf_broadcast_odometry_->sendTransform (odom_tf_);
143
+ // check prevents TF_REPEATED_DATA warning
144
+ if (odom_tf_.header .stamp == odom_.header .stamp ){
145
+ // ROS_WARN_STREAM("OdometryController: already published odom_tf before");
146
+ // ROS_WARN_STREAM("\todom_tf: " << odom_tf_);
147
+ // ROS_WARN_STREAM("\todom_: " << odom_);
148
+ // ROS_WARN_STREAM("\tevent.last_expected: " << event.last_expected);
149
+ // ROS_WARN_STREAM("\tevent.last_real: " << event.last_real);
150
+ // ROS_WARN_STREAM("\tevent.current_expected: " << event.current_expected);
151
+ // ROS_WARN_STREAM("\tevent.current_real: " << event.current_real);
152
+ } else {
153
+ // compose and publish transform for tf package
154
+ // compose header
155
+ odom_tf_.header .stamp = odom_.header .stamp ;
156
+ // compose data container
157
+ odom_tf_.transform .translation .x = odom_.pose .pose .position .x ;
158
+ odom_tf_.transform .translation .y = odom_.pose .pose .position .y ;
159
+ odom_tf_.transform .rotation = odom_.pose .pose .orientation ;
160
+
161
+ // publish the transform (for debugging, conflicts with robot-pose-ekf)
162
+ tf_broadcast_odometry_->sendTransform (odom_tf_);
163
+ }
153
164
}
154
165
}
155
166
};
0 commit comments