1. Introduction
RPLIDAR is a low cost 360 degree 2D laser scanner (LIDAR) solution developed by RoboPeak. The system can perform 360 degree scan within 6 meter range. The produced 2D point cloud data can be used in mapping, localization and object/environment modeling.
2. How to use the sensor
2.1. Detect obstacles in the range 345º to 15º
package examples;
import ev3dev.sensors.slamtec.RPLidarA1;
import ev3dev.sensors.slamtec.RPLidarProviderListener;
import ev3dev.sensors.slamtec.model.Scan;
public class Demo3 {
public static void main(String[] args) throws Exception {
System.out.println("Testing RPLidar");
final String USBPort = "/dev/ttyUSB0";
final RPLidarA1 lidar = new RPLidarA1(USBPort);
lidar.init();
lidar.addListener(new RPLidarProviderListener() {
@Override
public void scanFinished(Scan scan) {
System.out.println("Measures: " + scan.getDistances().size());
scan.getDistances()
.stream()
.filter((measure) -> measure.getQuality() > 10)
.filter((measure) -> (measure.getAngle() >= 345 || measure.getAngle() <= 15))
.filter((measure) -> measure.getDistance() <= 50)
.forEach(System.out::println);
}
});
for(int x = 0; x <= 10; x++) {
lidar.scan();
}
lidar.close();
System.out.println("End");
System.exit(0);
}
}