ROS2 : Subscribing to LaserScan
Hello everyone , noobie question :
I'm trying to write a subscriber to LaserScan from the Dolly robot (https://github.com/chapulina/dolly) . I've written the launch file , for the Gazebo simulation,then wrote the subscriber but i can't get feedback from the laserscan.
So basically i've got this so far :
import rclpy
from rclpy.node import Node
import sensor_msgs.msg
class ReadingLaser(Node):
def __init__(self):
super().__init__('reading_laser')
self.subscription= self.create_subscription(
sensor_msgs.msg.LaserScan,
'/dolly/laser_scan'
self.listener_callback,
qos_profile= 10
)
def listener_callback(self, msg):
self.get_logger().info('I heard "%f"' %msg.data[100] )
def main(args=None):
rclpy.init()
reading_laser = ReadingLaser()
reading_laser.get_logger().info("Hello friend!")
rclpy.spin(reading_laser)
# Destroy the node explicitly
# (optional - otherwise it will be done automatically
# when the garbage collector destroys the node object)
reading_laser.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
After I build it, I run it then i get the log message ("hello friend") , but no LaserScan content. What am I doing wrong here?
Thanks in advance!
(EDIT: i finally got it to spit something , but it seems I don't defined well the QoS Profile, since now i've got : [WARN] [1651161136.977626994] [reading_laser]: New publisher discovered on topic '/dolly/laser_scan', offering incompatible QoS. No messages will be received from it. Last incompatible policy: RELIABILITY -> how do I define this QoS Profile? )