ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

help rplidar A1 python

asked 2019-06-24 09:47:43 -0500

mateusguilherme gravatar image

updated 2019-07-02 21:52:54 -0500

jayess gravatar image

Hi

Does anyone have a sample code for operating and publishing LaserScan message in python for the RPLIDAR A1 sensor?

I found the following library, but I do not know how to calculate some parameters of the message like:

float32 angle_min # start angle of the scan [rad]
float32 angle_max # end angle of the scan [rad]
float32 angle_increment # angular distance between measurements [rad]

float32 time_increment # time between measurements [seconds] - if your scanner
                          # is moving, this will be used in interpolating position
                          # of 3d points
float32 scan_time # time between scans [seconds]

According to the library example I get the following return for each iteration of the for loop:

#!/usr/bin/env python

from rplidar import RPLidar
lidar = RPLidar('/dev/ttyUSB0')

info = lidar.get_info()
print(info)

health = lidar.get_health()
print(health)

for i in lidar.iter_scans():
        print i

lidar.stop()
lidar.stop_motor()
lidar.disconnect()

Return iteration for: (intensities, angle, range)

[(15, 28.96875, 2558.75), (15, 260.46875, 517.25), (15, 261.9375, 511.25), (15, 263.21875, 506.5), (15, 264.46875, 501.25), (15, 265.65625, 496.0), (15, 267.09375, 491.75), (15, 268.4375, 487.5), (15, 269.78125, 483.5), (15, 271.125, 480.5), (15, 272.640625, 476.25), (15, 273.984375, 473.75), (15, 275.03125, 472.0), (15, 276.5, 468.25), (15, 277.703125, 466.75), (15, 278.90625, 465.5), (15, 280.4375, 463.75), (15, 281.65625, 462.75), (15, 283.0625, 461.75), (15, 284.234375, 461.75), (15, 285.609375, 460.25), (15, 286.796875, 460.25), (15, 288.21875, 460.5), (15, 289.46875, 460.25), (15, 290.921875, 461.0), (15, 292.09375, 460.75), (15, 293.265625, 462.25), (15, 294.671875, 463.25), (15, 295.875, 466.0), (15, 297.3125, 467.5), (15, 298.40625, 469.5), (15, 299.65625, 472.25), (15, 301.0, 476.0), (15, 302.328125, 479.0), (15, 303.8125, 484.0), (15, 305.046875, 484.5), (15, 306.359375, 488.5), (15, 307.40625, 492.5), (15, 308.90625, 496.5), (15, 310.171875, 501.25), (15, 311.328125, 506.25), (15, 312.625, 512.5), (15, 314.046875, 517.75), (15, 315.125, 524.75), (15, 316.421875, 532.75), (15, 317.84375, 537.0), (15, 319.03125, 544.75), (15, 320.25, 552.5), (15, 321.515625, 559.75), (15, 322.875, 569.75), (15, 324.046875, 579.0), (15, 325.140625, 589.5), (15, 326.609375, 599.75), (15, 327.6875, 612.0), (15, 328.984375, 623.75), (15, 330.40625, 633.5), (15, 331.515625, 649.0), (15, 332.75, 664.25), (15, 334.046875, 679.75), (15, 335.375, 697.0), (15, 336.625, 715.5), (15, 337.84375, 734.0)]
edit retag flag offensive close merge delete

Comments

I could be misunderstanding you, but there are actually quite a few packages for rpilidars available. Two of those would be wiki/rplidar and wiki/rplidar_ros.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-24 10:03:58 -0500 )edit

I would like an example in python ...

mateusguilherme gravatar image mateusguilherme  ( 2019-06-24 10:11:10 -0500 )edit
2

I believe my implied question was: why are you asking about interfacing with an rplidar on a ROS forum when there are already several packages available that do exactly that.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-24 10:12:37 -0500 )edit

Ok you're right. I just thought that if there was an example in python, it would make it easier for me. For me the python language is more understandable.

mateusguilherme gravatar image mateusguilherme  ( 2019-06-26 14:21:43 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-07-02 11:26:34 -0500

mateusguilherme gravatar image

I ended up using the manufacturer's own C ++ library (https://github.com/Slamtec/rplidar_ros). I got a better performance than some python examples I found on the internet.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-06-24 09:47:43 -0500

Seen: 1,371 times

Last updated: Jul 02 '19