Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LiDAR scan range setting #159

Open
seongminJadenLeeunib opened this issue Nov 27, 2024 · 0 comments
Open

LiDAR scan range setting #159

seongminJadenLeeunib opened this issue Nov 27, 2024 · 0 comments

Comments

@seongminJadenLeeunib
Copy link

seongminJadenLeeunib commented Nov 27, 2024

I am doing SLAM using a2m8.

I have a question.
What I want to do is as follows.

  1. Scan only -90 to 90 degrees
  2. Read data only 30 centimeters or more from the lidar origin

How do I set these two settings?

`
#!/usr/bin/env python3

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import LogInfo
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

def generate_launch_description():
channel_type = LaunchConfiguration('channel_type', default='serial')
serial_port = LaunchConfiguration('serial_port', default='/dev/ttyUSB0')
serial_baudrate = LaunchConfiguration('serial_baudrate', default='115200')
frame_id = LaunchConfiguration('frame_id', default='laser')
inverted = LaunchConfiguration('inverted', default='false')
angle_min = LaunchConfiguration('angle_min', default='-1.5708')
angle_max = LaunchConfiguration('angle_max', default='1.5708')
range_min = LaunchConfiguration('range_min', default='0.1')
angle_compensate = LaunchConfiguration('angle_compensate', default='true')
scan_mode = LaunchConfiguration('scan_mode', default='Sensitivity')

rviz_config_dir = os.path.join(
        get_package_share_directory('sllidar_ros2'),
        'rviz',
        'sllidar_ros2.rviz')

return LaunchDescription([
    DeclareLaunchArgument(
        'channel_type',
        default_value=channel_type,
        description='Specifying channel type of lidar'),

    DeclareLaunchArgument(
        'serial_port',
        default_value=serial_port,
        description='Specifying usb port to connected lidar'),

    DeclareLaunchArgument(
        'serial_baudrate',
        default_value=serial_baudrate,
        description='Specifying usb port baudrate to connected lidar'),
    
    DeclareLaunchArgument(
        'frame_id',
        default_value=frame_id,
        description='Specifying frame_id of lidar'),

    DeclareLaunchArgument(
        'inverted',
        default_value=inverted,
        description='Specifying whether or not to invert scan data'),

    DeclareLaunchArgument(
        'angle_compensate',
        default_value=angle_compensate,
        description='Specifying whether or not to enable angle_compensate of scan data'),

    DeclareLaunchArgument(
        'scan_mode',
        default_value=scan_mode,
        description='Specifying scan mode of lidar'),

    Node(
        package='sllidar_ros2',
        executable='sllidar_node',
        name='sllidar_node',
        parameters=[{
            'channel_type': channel_type,
            'serial_port': serial_port, 
            'serial_baudrate': serial_baudrate, 
            'frame_id': frame_id,
            'inverted': inverted == 'true',  # Convert string to bool
            'angle_min': angle_min,  # Keep as string for now (unless the node expects float)
            'angle_max': angle_max,  # Keep as string for now
            'range_min': range_min,  # Keep as string for now
            'angle_compensate': angle_compensate == 'true',  # Convert string to bool
            'scan_mode': scan_mode,
        }],
        output='screen'),
])

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant