Search in sources :

Example 1 with LidarLiteDevice

use of com.robo4j.hw.rpi.i2c.lidar.LidarLiteDevice in project robo4j by Robo4J.

the class LidarLiteTest method main.

public static void main(String[] args) throws IOException, InterruptedException {
    LidarLiteDevice ld = new LidarLiteDevice();
    while (true) {
        ld.acquireRange();
        Thread.sleep(100);
        System.out.println(String.format("Distance: %.02fm", ld.readDistance()));
        Thread.sleep(500);
    }
}
Also used : LidarLiteDevice(com.robo4j.hw.rpi.i2c.lidar.LidarLiteDevice)

Example 2 with LidarLiteDevice

use of com.robo4j.hw.rpi.i2c.lidar.LidarLiteDevice in project robo4j by Robo4J.

the class LaserScanner method onInitialization.

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    super.onInitialization(configuration);
    pan = configuration.getString("servo", "laserscanner.servo");
    // Using degrees for convenience
    servoRange = (float) configuration.getFloat("servoRange", 45.0f);
    // Using angular degrees per second.
    angularSpeed = configuration.getFloat("angularSpeed", 90.0f);
    // Minimum acquisition time, in ms
    minimumAcquisitionTime = configuration.getFloat("minAquisitionTime", 2.0f);
    // Trim to align left to right and right to left scans (in degrees)
    trim = configuration.getFloat("trim", 0.0f);
    try {
        lidar = new LidarLiteDevice(getBus(), getAddress());
    } catch (IOException e) {
        throw new ConfigurationException(String.format("Failed to initialize lidar device. Make sure it is hooked up to bus: %d address: %xd", getBus(), getAddress()), e);
    }
}
Also used : LidarLiteDevice(com.robo4j.hw.rpi.i2c.lidar.LidarLiteDevice) ConfigurationException(com.robo4j.core.ConfigurationException) IOException(java.io.IOException)

Aggregations

LidarLiteDevice (com.robo4j.hw.rpi.i2c.lidar.LidarLiteDevice)2 ConfigurationException (com.robo4j.core.ConfigurationException)1 IOException (java.io.IOException)1