Skip to content

Commit 65850e0

Browse files
[fix] Fix the program so that the time stamps of the points are the same with the original image topic
1 parent 753341b commit 65850e0

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

include/pytorch_ros/pytorch_seg_trav_path_ros.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ class PyTorchSegTravPathROS {
3838
image_transport::Publisher pub_prob_image_;
3939
ros::Publisher pub_start_point_;
4040
ros::Publisher pub_end_point_;
41-
42-
// For listening to messages
43-
tf2_ros::Buffer tf_buffer_;
44-
tf2_ros::TransformListener * tf_listener_;
41+
ros::Time stamp_of_current_image_;
4542

4643
PyTorchCppWrapperSegTravPath pt_wrapper_;
4744

src/pytorch_seg_trav_path_ros.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ PyTorchSegTravPathROS::image_callback(const sensor_msgs::ImageConstPtr& msg)
4747

4848
// Convert the image message to a cv_bridge object
4949
cv_bridge::CvImagePtr cv_ptr = msg_to_cv_bridge(msg);
50+
stamp_of_current_image_ = msg->header.stamp;
5051

5152
// Run inference
5253
sensor_msgs::ImagePtr label_msg;
@@ -178,9 +179,9 @@ PyTorchSegTravPathROS::tensor_to_points(const at::Tensor point_tensor, const int
178179
auto points_a = points.accessor<float, 2>();
179180

180181
// Initialize messgaes
181-
start_point_msg->header.stamp = ros::Time::now();
182+
start_point_msg->header.stamp = stamp_of_current_image_;//ros::Time::now();
182183
start_point_msg->header.frame_id = "kinect2_rgb_optical_frame";
183-
end_point_msg->header.stamp = ros::Time::now();
184+
end_point_msg->header.stamp = stamp_of_current_image_;//ros::Time::now();
184185
end_point_msg->header.frame_id = "kinect2_rgb_optical_frame";
185186
// Point tensor has coordinate values normalized with the width and height.
186187
// Therefore each value is multiplied by width or height.

0 commit comments

Comments
 (0)