ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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::init(argc,argv,"point_cloud_publisher");
ros::NodeHandle n;
ros::Publisher cloud_pub = n.advertise<sensor_msgs::PointCloud2>("cloud",50);
ros::Rate r(1.0);
while(n.ok()){
sensor_msgs::PointCloud2 cloud;
cloud.header.stamp = ros::Time::now();
cloud.header.frame_id = "sensor_frame";

  cloud_pub.publish(cloud);
 r.sleep();
 }  
 }
edit retag flag offensive close merge delete

Comments

1

Which camera node are you using? Why not set the frame_id in the camera node, as suggested in https://answers.ros.org/question/3276... ?

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
0

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

ahendrix gravatar image

You should be able to set frame_id in msg.header.frame_idhere: https://github.com/dbc/side_x_side_st...

edit flag offensive delete link more

Comments

Thank you so much, the problem perfectly solved

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

Question Tools

1 follower

Stats

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

Seen: 259 times

Last updated: Jul 10 '19