diff --git a/src/ldrobot-lidar-ros2/ldlidar_node/launch/ldlidar.launch.py b/src/ldrobot-lidar-ros2/ldlidar_node/launch/ldlidar.launch.py index 8194041..19f927e 100644 --- a/src/ldrobot-lidar-ros2/ldlidar_node/launch/ldlidar.launch.py +++ b/src/ldrobot-lidar-ros2/ldlidar_node/launch/ldlidar.launch.py @@ -41,6 +41,7 @@ def generate_launch_description(): declare_node_name_cmd = DeclareLaunchArgument( 'node_name', default_value='ldlidar_node', + namespace='lidar', description='Name of the node' ) diff --git a/src/ldrobot-lidar-ros2/ldlidar_node/launch/ldlidar_with_mgr.launch.py b/src/ldrobot-lidar-ros2/ldlidar_node/launch/ldlidar_with_mgr.launch.py index 839efa6..f9e5612 100644 --- a/src/ldrobot-lidar-ros2/ldlidar_node/launch/ldlidar_with_mgr.launch.py +++ b/src/ldrobot-lidar-ros2/ldlidar_node/launch/ldlidar_with_mgr.launch.py @@ -50,6 +50,7 @@ def generate_launch_description(): package='nav2_lifecycle_manager', executable='lifecycle_manager', name='lidar_lifecycle_manager', + namespace='lidar', output='screen', parameters=[ # YAML files diff --git a/src/listen_package/listen_package/ecoute.py b/src/listen_package/listen_package/ecoute.py index dc2e5d8..1e8f1a5 100644 --- a/src/listen_package/listen_package/ecoute.py +++ b/src/listen_package/listen_package/ecoute.py @@ -10,7 +10,7 @@ def __init__(self): qos_profile = rclpy.qos.QoSProfile(depth=10, reliability=rclpy.qos.QoSReliabilityPolicy.BEST_EFFORT) self.subscription = self.create_subscription( LaserScan, - 'ldlidar_node/scan', + '/lidar/ldlidar_node/scan', self.listener_callback, qos_profile) self.subscription # prevent unused variable warning @@ -25,8 +25,9 @@ def listener_callback(self, msg): # Check if any of the range values are within the specified distance for range_value in msg.ranges: if min_distance < range_value < max_distance: + # If an object is detected within the specified range, publish a message - self.get_logger().info("Object detected") + self.get_logger().info("Object detected at distance : %f" % range_value) self.publisher.publish(String(data='Object detected')) break