tf broadcaster to subscribe a existing topic
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();
}
}
Asked by mibclaric on 2019-07-10 11:55:28 UTC
Answers
You should be able to set frame_id in msg.header.frame_id
here: https://github.com/dbc/side_x_side_stereo/blob/master/src/side_by_side_stereo_node.cpp#L107-L108
Asked by ahendrix on 2019-07-12 00:13:40 UTC
Comments
Thank you so much, the problem perfectly solved
Asked by mibclaric on 2019-07-12 13:17:06 UTC
Comments
Which camera node are you using? Why not set the frame_id in the camera node, as suggested in https://answers.ros.org/question/327640/stereo-camera-does-not-generate-depth-image/ ?
Asked by ahendrix on 2019-07-10 12:12:09 UTC
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.
Asked by mibclaric on 2019-07-11 12:10:13 UTC