Skip to content

Commit 2843cd4

Browse files
committed
fixed to handle TF timeout correctly
1 parent 6132b10 commit 2843cd4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

‎opengl_ros/src/depth_image_projector_nodecore.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ void DepthImageProjectorNode::depthCallback(const sensor_msgs::Image::ConstPtr&
8181
tfListener_.lookupTransform(map_frame_id_, cameraInfoMsg->header.frame_id,
8282
cameraInfoMsg->header.stamp, transform);
8383
getTransformMatrixArray(transform, depthToMap);
84+
} else {
85+
ROS_WARN_STREAM("TF wait transform timeout in depthCallback().");
86+
return;
8487
}
8588

8689
if (tfListener_.waitForTransform(map_frame_id_, fixed_frame_id_,
@@ -92,11 +95,20 @@ void DepthImageProjectorNode::depthCallback(const sensor_msgs::Image::ConstPtr&
9295
map_frame_id_, cameraInfoMsg->header.stamp,
9396
fixed_frame_id_, tramsform);
9497
getTransformMatrixArray(tramsform, mapToPreviousMap);
98+
} else {
99+
ROS_WARN_STREAM("TF wait transform timeout in depthCallback().");
100+
101+
//stop accumulation in case required TF is already removed from the cache
102+
previousTimestamp_ = cameraInfoMsg->header.stamp;
103+
return;
95104
}
96105
}
97106
catch (tf::TransformException& ex)
98107
{
99108
ROS_WARN("Transform Exception in depthCallback(). %s", ex.what());
109+
110+
//stop accumulation in case required TF is already removed from the cache
111+
previousTimestamp_ = cameraInfoMsg->header.stamp;
100112
return;
101113
}
102114

‎opengl_ros/src/object_position_extractor_nodecore.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ void ObjectPositionExtractorNode::depthCallback(const sensor_msgs::Image::ConstP
229229
{
230230
tfListener_.lookupTransform(fixed_frame_id_, depth_frame_id_,
231231
cv_ptr->header.stamp, transform_to_fixed_frame);
232+
} else {
233+
ROS_WARN_STREAM("TF wait transform timeout in depthCallback().");
234+
return;
232235
}
233236
}
234237
catch (tf::TransformException& ex)
@@ -373,6 +376,9 @@ bool ObjectPositionExtractorNode::updateDepthToColor()
373376
getTransformMatrixArray(transform, latestDepthToColor_);
374377

375378
depthToColorArrived_ = true;
379+
} else {
380+
ROS_WARN_STREAM("TF wait transform timeout in depthCallback().");
381+
return false;
376382
}
377383
}
378384
catch (tf::TransformException& ex)

0 commit comments

Comments
 (0)