Ask Your Question

tf broadcaster to subscribe a existing topic

asked 2019-07-10 11:55:28 -0500

mibclaric gravatar image

I'm trying to see the point cloud 2 on rviz but because the packages I'm using, the topic camera/points2 does not have a frame ID, so I use the tf_broadcaster to publish a cloud topic that have a frame ID following tf tutorial. Is there any way to make the new topic cloud subscribe to my camera/points2 so that cloud will be the same as camera/points2 and also have a frame ID.

#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>

int main(int argc, char** argv){
ros::NodeHandle n;
ros::Publisher cloud_pub = n.advertise<sensor_msgs::PointCloud2>("cloud",50);
ros::Rate r(1.0);
sensor_msgs::PointCloud2 cloud;
cloud.header.stamp = ros::Time::now();
cloud.header.frame_id = "sensor_frame";

edit retag flag offensive close merge delete



Which camera node are you using? Why not set the frame_id in the camera node, as suggested in ?

ahendrix gravatar image ahendrix  ( 2019-07-10 12:12:09 -0500 )edit

The node I was using is sxs stereo. The reason I didn't set the frame ID on that node is that the node didn't build with a frame ID and I don't know how to add a frame ID to that node.

mibclaric gravatar image mibclaric  ( 2019-07-11 12:10:13 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-07-12 00:13:40 -0500

ahendrix gravatar image

You should be able to set frame_id in msg.header.frame_idhere:

edit flag offensive delete link more


Thank you so much, the problem perfectly solved

mibclaric gravatar image mibclaric  ( 2019-07-12 13:17:06 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-07-10 11:55:28 -0500

Seen: 87 times

Last updated: Jul 10 '19