frame issue with PointCloud2 and rviz
After reviewing the source for Velodyne I see that:
- the velodyne_packets topic is published with "velodyne" frame id in the ROS header
- the velodyne_points topic is published with "odom" frame id in the ROS header
- when I run with a PCAP file and visualize in rviz, I launch rviz by passing the fixed frame ID as in "rosrun rviz rviz -f velodyne"
- rviz display the fixed frame options as only velodyne and properly displays the PointCloud2 data
I have a similar LiDAR with a driver that has been using the PCL Point XYZI. I'm using pcl::toROSMsg to convert the PCL point cloud (Point XYZI) to sensor_msgs::PointCloud2. I format the header with a frame_id that I made up with a simple text string. I didn't broadcast a tf transform since I didn't see that the velodyne code did either.
When I run my ROS node and then rviz (e.g. "rosrun rviz rviz -f myframe" where "myframe" is the same string used in my header for the PointCloud2 message.), I get an error:
Transform [sender=unknown_publisher]
For frame []: Fixed Frame [myframe] does not exist
In the case of both the velodyne (using PCAP file) and my node, I checked the tf by running "rosrun tf tf_echo" but see no frames listed.
I'm a little confused why the velodyne driver works and mine doesn't since the velodyne code doesn't seem to broadcast the transforms. I've been alerted to that the text "For frame []:" in the error above is really stating that the translation is from from "" (empty string) to "myframe". Without a broadcast transform, how can having two frames (in the case of velodyne) for two different topics make any difference? The PointCloud2 status for Velodyne shows "OK" and the subitem under status, Transform also simply says OK for velodyne but gives the error above for my sensor.
I "rostopic echo ..." my topic and the PointCloud2 data looks well formed when compared to the velodyne PointCloud2 message so I think the error is simply a matter of tf frames and frame IDs.
In my code I'm not doing a tf::MessageFilter or pcl_ros::transformPointCloud like the velodyne code does in transform.cc. I don't have a second node for my data like velodyne so I don't suppose I really need the MessageFilter because I can't subscribe to anything getting the raw data. I'm curious if the ros::transformPointCloud would actually be of much use since I don't have two transform IDs like velodyne does (odom and velodyne).
Any help is greatly appreciated.
Here's the header: seq: 451713 stamp: secs: 83567 nsecs: 240980000 frame_id: '' height: 8 width: 4872 fields: - name: x offset: 0 datatype: 7 count: 1 - name: y offset: 4 datatype: 7 count: 1 - name: z offset: 8 datatype: 7 count: 1 - name: intensity offset: 16 datatype: 7 count: 1 is_bigendian: False point_step: 32 row_step: 155904
Here's the snippet:
while(ros::ok())
{
//create and send ...
Can you do
rostopic echo /<topic you're subscribed to in rviz>
and just post the header part of the output?I noticed two problems. The frame_id is an empty string even though I'm adding the string in my code. I also noticed the time stamps seem to reflect miliseconds and not seconds. Header below.
Is it possible for you to post the snippet of your code which does the publishing. I'd say the only way this could happen is a mistake in the publishing code.
I added the snippet. (and removed the answer section. Thanks for the tip)