Robotics StackExchange | Archived questions

Rviz2 wont show data although messages are arriving

Rviz2 doesn't show any point from a lidar feed. Messages arrive properly and I can read them out using ros2 topic echo /lidardatain. I can verify the structure and data of the PointCloud2 and is correct.

I have no tf tree defined yet so I do :

ros2 run tf2ros statictransformpublisher --frame-id map --child-frame-id myframe

I also fixed the frameid to myframe so there are no complains from Rviz2.

I also tried changing the background colors for contrast support, modifying the reliability policy and the points size. No luck.

Please see the the publishing node :

        sensor_msgs::msg::PointCloud2 cloud;
        sensor_msgs::PointCloud2Modifier pcd_modifier(cloud);

        std_msgs::msg::Header header;
        header.frame_id = "my_frame";
        std::vector<float> points;

            cloud.header.frame_id = header.frame_id;
            cloud.header.stamp = header.stamp;
            cloud.width = 2;
            cloud.height = count;

            pcd_modifier.setPointCloud2Fields(2, "x", 1, sensor_msgs::msg::PointField::FLOAT32,
                                              "y", 1, sensor_msgs::msg::PointField::FLOAT32);

            sensor_msgs::PointCloud2Iterator<float> x_it{cloud, "x"};
            sensor_msgs::PointCloud2Iterator<float> y_it{cloud, "y"};

            for (auto i = 0;
                 (i < points.size()) && (x_it != x_it.end()) && (y_it != y_it.end());
                 ++i, ++x_it, ++y_it)
            {
                *x_it = points[i];
                *y_it = points[i + 1];
            }

            publisher->publish(cloud);

The ros2 topic echo /lidardatain gives:

header: stamp: sec: 0 nanosec: 0 frameid: myframe height: 3197 width: 2 fields: - name: x offset: 0 datatype: 7 count: 1 - name: y offset: 4 datatype: 7 count: 1 isbigendian: false pointstep: 8 rowstep: 16 data: - 3 - 229 - 91 - 192 - 226 - 63 - 204 - 68 - 226 - 63 - 204 - 68 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 64 - 204 - 68 - 0 - 64 - 204 - 68 - 71 - 145 - 92 - 64 - 71 - 145 - 92 - 64 - 226 - 63 - 204 - 68 - 226 - 63 - 204 - 68 - 146 - 138 - 210 - 64 - 146 - 138 - 210 - 64 - 147 - 63 - 204 - 68 - 147 - 63 - 204 - 68 - 127 - 126 - 27 - 65 - 127 - 126 - 27 - 65 - 19 - 95 - 204 - 68 - 19 - 95 - 204 - 68 - 172 - 7 - 78 - 65 - 172 - 7 - 78 - 65 - 97 - 190 - 204 - 68 - 97 - 190 - 204 - 68 - 247 - 155 - 128 - 65 - 247 - 155 - 128 - 65 - 124 - 125 - 205 - 68 - 124 - 125 - 205 - 68 - 60 - 27 - 154 - 65 - 60 - 27 - 154 - 65 - 101 - 220 - 205 - 68 - 101 - 220 - 205 - 68 - 67 - 97 - 183 - 65 - '...' isdense: false

I am using ROS Humble on Ubuntu 22.

Asked by Rick_O on 2022-08-18 13:48:22 UTC

Comments

The timestamp is not populated. You could try setting the time in the published message. Rviz may be trying to use the message timestamp to see if it should display the points at the current time or if it is stale data.

Asked by Thomas D on 2022-08-18 16:05:55 UTC

I populated the timestamp as follows: cloud.header.stamp = node -> now();

still nothing. see new message :

header: stamp: sec: 1660906162 nanosec: 768930231 frame_id: my_frame height: 825 width: 2 fields: - name: x offset: 0 datatype: 7 count: 1 - name: y offset: 4 datatype: 7 count: 1 is_bigendian: false point_step: 8 row_step: 16 data: - 85 - 147 - 100 - 190 - 254 ....

Asked by Rick_O on 2022-08-19 06:03:50 UTC

Answers