This block samples the sensor signal of a laser scanner at its inputs and packs it into a ROS message of type sensor_msgs::LaserScan
. Each time the block is run by its time domain, this message is published under a given topic name.
// create publisher block, lasers canner range has a size of 150 values RosPublisherLaserScan<Matrix<150, 1, double>, Matrix<150, 1, double >> laserScan("myTopic", "laser", 100);
For ROS2 you have to pass the node, from where the topic is sent. The ROS2 message is of type std_msgs::msg::LaserScan.
// create publisher block, lasers canner range has a size of 150 values RosPublisherLaserScan<Matrix<150, 1, double>, Matrix<150, 1, double >> laserScan(node, "myTopic", "laser", 100);
The template parameter of the block determines the size of the range and intensity vectors. The time stamp of the signal is transmitted in the message header.