Closed debanik123 closed 6 months ago
I have the same question! anyone can help please?
Were you able to solve it? If so, Did you change the frequency in the launch file or.... What exactly did you do?
Thanks in advance
Modify the scan_frequency parameter in the corresponding launch file.
@deyouslamtec I am also struggling with changing the frequency on ros2 humble and I have included rplidar_s1_launch.py
this way
rplidar_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([str(rplidar_launch_src), '/rplidar_s1_launch.py']),
launch_arguments={'frame_id': 'laser_link', 'serial_port': '/dev/laser_usb', 'scan_frequency':'15.0'}.items(),
)
frame_id
and serial_port
parameters are working, but scan_frequency
is not, because after launching I received message like these
[rplidar_node]: current scan mode: DenseBoost, sample rate: 9 Khz, max_distance: 40.0 m, scan frequency:10.0 Hz,
also frequency of the /scan
topic is closely about 10 Hz
changing with launch parameter is not working in my case and ros2 launch files.
[EDIT]
Even if I added scan_frequency
parameter to the rplidar_s1_launch.py
as below, in console I am getting proper info but frequency is not changed.
Then I am adding parameter to my own file like below
rplidar_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([str(rplidar_launch_src), '/rplidar_s1_launch.py']),
launch_arguments={'frame_id': 'laser_link', 'serial_port': '/dev/laser_usb', 'scan_frequency':'15.0'}.items(),
)
Inside `rplidar_s1_launch.py I added the following lines
scan_frequency = LaunchConfiguration('scan_frequency', default='10.0')
DeclareLaunchArgument(
'scan_frequency',
default_value=scan_frequency,
description='Specifying scan freqquency for lidar'),
and finally
Node(
package='rplidar_ros',
executable='rplidar_node',
name='rplidar_node',
parameters=[{'channel_type':channel_type,
'serial_port': serial_port,
'serial_baudrate': serial_baudrate,
'frame_id': frame_id,
'inverted': inverted,
'angle_compensate': angle_compensate,
'scan_frequency': scan_frequency}],
output='screen'),
and console gives me this
[rplidar_node]: current scan mode: DenseBoost, sample rate: 9 Khz, max_distance: 40.0 m, scan frequency:15.0 Hz,
but ros2 topic hz /scan
gives me the following average rate: 10.012
I am working with rplidar s1 on ROS1 noetic and after updating launch file in the way @deyouslamtec suggested but still the lidar is not spinning any faster.
While launching there is an info: set lidar scan frequency to 10.0 Hz(600.0 Rpm)
I've also checked rostopic hz /scan
but it gives me reading of about 10 Hz
I tested under Ubuntu20.04 ROS noetic. rplidar S1, S2, and S3 can adjust the publishing frequency by modifying scan_frequency in the launch file.
This is content of modified launch I am using:
<launch>
<node name="rplidarNode" pkg="rplidar_ros" type="rplidarNode" output="screen">
<param name="serial_port" type="string" value="/dev/ttyUSB0"/>
<param name="serial_baudrate" type="int" value="256000"/>
<param name="frame_id" type="string" value="laser"/>
<param name="inverted" type="bool" value="false"/>
<param name="angle_compensate" type="bool" value="true"/>
<param name="scan_frequncy" type="double" value="15.0"/>
</node>
</launch>
after launching it I get
So the ros parameter is being set, but does not affect the lidar
@darkhannibal 'scan_frequency' not 'scan_frequncy'
@deyouslamtec Thanks man, now it works like a charm. I have not noticed that typo :/
@deyouslamtec does the same work on ROS2? Cause I tried to add this parameter to launch with default value of 15.0 and it does not change anything :crying_cat_face:
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='256000')
frame_id = LaunchConfiguration('frame_id', default='laser')
inverted = LaunchConfiguration('inverted', default='false')
angle_compensate = LaunchConfiguration('angle_compensate', default='true')
scan_frequency = LaunchConfiguration('scan_frequency', default='15.0')
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_frequency',
default_value=scan_frequency,
description='Specifying whether or not to enable angle_compensate of scan data'),
Node(
package='rplidar_ros',
executable='rplidar_node',
name='rplidar_node',
parameters=[{'channel_type':channel_type,
'serial_port': serial_port,
'serial_baudrate': serial_baudrate,
'frame_id': frame_id,
'inverted': inverted,
'angle_compensate': angle_compensate,
'scan_frequency': scan_frequency}],
output='screen'),
])
Parameters also do not work to increase the frequency
@kosmonauta144 It doesn't work properly on ROS2 yet, wait for me to adjust the code
@kosmonauta144 scan_frequcund can work on ROS2, please update the ros2 branch
thank you very much, it works with parameter from launch file :smile:
how to increase the rplidar S2 publishing frequency upto 15Hz? Rplidar current publish frequency is only 10Hz. However the publishing frequency of rplidar A2 is 13 to 15 Hz.