Search in sources :

Example 1 with GyroL3GD20Device

use of com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device in project robo4j by Robo4J.

the class GyroL3GD20Unit method onInitialization.

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    super.onInitialization(configuration);
    sensitivity = Sensitivity.valueOf(configuration.getString(PROPERTY_KEY_SENSITIVITY, "DPS_245"));
    period = configuration.getInteger(PROPERTY_KEY_PERIOD, 10);
    highPassFilter = configuration.getBoolean(PROPERTY_KEY_HIGH_PASS_FILTER, true);
    try {
        gyro = new CalibratedGyro(new GyroL3GD20Device(getBus(), getAddress(), sensitivity, highPassFilter));
    } 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 : CalibratedGyro(com.robo4j.hw.rpi.i2c.gyro.CalibratedGyro) ConfigurationException(com.robo4j.core.ConfigurationException) IOException(java.io.IOException) GyroL3GD20Device(com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device)

Example 2 with GyroL3GD20Device

use of com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device in project robo4j by Robo4J.

the class GyroL3GD20Test method main.

public static void main(String[] args) throws IOException, InterruptedException {
    System.out.println("Initializing...");
    GyroL3GD20Device device = new GyroL3GD20Device(Sensitivity.DPS_245);
    while (true) {
        System.out.println(device.read());
        Thread.sleep(200);
    }
}
Also used : GyroL3GD20Device(com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device)

Example 3 with GyroL3GD20Device

use of com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device in project robo4j by Robo4J.

the class CalibratedGyroTest method main.

public static void main(String[] args) throws IOException, InterruptedException {
    System.out.println("Initializing...");
    GyroL3GD20Device device = new GyroL3GD20Device(Sensitivity.DPS_245);
    CalibratedGyro gyro = new CalibratedGyro(device);
    System.out.println("Keep the device still, and press enter to start calibration.");
    System.in.read();
    System.out.println("Calibrating...");
    gyro.calibrate();
    System.out.println("Calibration done!");
    while (true) {
        System.out.println(gyro.read());
        Thread.sleep(200);
    }
}
Also used : GyroL3GD20Device(com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device)

Aggregations

GyroL3GD20Device (com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device)3 ConfigurationException (com.robo4j.core.ConfigurationException)1 CalibratedGyro (com.robo4j.hw.rpi.i2c.gyro.CalibratedGyro)1 IOException (java.io.IOException)1