RobotWebTools / roslibjs

The Standard ROS JavaScript Library
https://robotwebtools.github.io/roslibjs
Other
659 stars 372 forks source link

Subscription for PointCloud2 is not working #726

Open apoorvcn47 opened 1 month ago

apoorvcn47 commented 1 month ago

Description I am trying subscribe to a Pointcloud2 topic but my subscription callback function never triggers. Similar styled subsciptions work for Image and MarkerArray topics.

let pc_topic = new ROSLIB.Topic(
{
    ros : ros,
    // name : '/camera/color/image_raw',
    // messageType : 'sensor_msgs/msg/Image',
    name : '/camera/depth_registered/points',
    messageType : 'sensor_msgs/msg/PointCloud2',
    // name : '/rviz/pallet1',
    // messageType : 'visualization_msgs/MarkerArray',
    // latch : true
});
// render_ob.create_pointcloud_sub(pc_topic);
pc_topic.subscribe(function(message) 
{
    console.log('message.width');
    console.log(message.width);
    console.log(message.height);
});

I was wondering if anyone has come across this.

spxvszero commented 1 month ago

try 'sensor_msgs/PointCloud2' instead of 'sensor_msgs/msg/PointCloud2'

apoorvcn47 commented 1 month ago

try 'sensor_msgs/PointCloud2' instead of 'sensor_msgs/msg/PointCloud2'

I tried both. It doesn't make a difference.

MatthijsBurgh commented 1 month ago

I suggest you start with the simple example and start adding changes, not all at the same, just as minimal as possible.

And you should indeed use sensor_msgs/PointCloud2'.