rviz: Need to display two different set of data
Hi, I have a set of data from a known topic in a bag file.
And also I have another set of point data which is published in a c++ file. The code is
ros::Publisher ros_pub = nh.advertise<sensor_msgs::PointCloud2> ("ros_output", 1);
pcl::PointCloud<pcl::PointXYZ> cloud;
cloud.width = 1200;
cloud.height = 1;
cloud.points.resize(cloud.width * cloud.height * 1);
for ( size_t i = 0; i < cloud.points.size(); i++)
{
cloud.points[i].x = 512 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].y = 512 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].z = 512 * rand () / (RAND_MAX + 1.0f);
}
pcl::toROSMsg(cloud, output);
output.header.frame_id = "random_data";
ros::Rate loop_rate(1);
while (ros::ok())
{
ros_pub.publish(output);
ros::spinOnce();
loop_rate.sleep();
}
The bag file is executed by $ rosbag play mydata.bag
And the C++ file is build using
catkinmake -DCMAKEBUILDTYPE=Release
and executed as
$ ./randomdata
How can I display both data in the rviz with two different dataset with different frame_ids?
Asked by sunkingac4 on 2020-01-06 01:14:53 UTC
Comments
You need to have a transform between your two frames. You can add code to your random cloud generating node that would publish this transform or the easier option would be to use the static transform publisher. If your transform does not change you could just run the following command (change to frames to what ever your topic frame_id parameters are).
rosrun tf static_transform_publisher 0.0 0.0 0.0 0.0 0.0 0.0 bag_data_frame random_data 100
If you don't know the frame of the data in your bag you could run
rostopic echo -n1 /point_cloud_topic/from_bag | grep frame
for example while the bag is running to find out what frame the messages are in.The easiest hack to view both messages in rviz would be to change frame_id in line
output.header.frame_id = "random_data";
to the same frame_id as the data in the bag. Then you could just use the frame used in the bag to show both point clouds.Asked by Reamees on 2020-01-06 08:22:29 UTC