Search in sources :

Example 1 with MotorProvider

use of com.robo4j.hw.lego.provider.MotorProvider in project robo4j by Robo4J.

the class BasicSonicUnit method onInitialization.

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    setState(LifecycleState.UNINITIALIZED);
    target = configuration.getString("target", null);
    if (target == null) {
        throw ConfigurationException.createMissingConfigNameException("target");
    }
    String sensorType = configuration.getString("sonicSensorPort", DigitalPortEnum.S3.getType());
    SensorProvider provider = new SensorProvider();
    sensor = new SensorWrapper<>(provider, DigitalPortEnum.getByType(sensorType), SensorTypeEnum.SONIC);
    String servoPort = configuration.getString("sonicServoPort", AnalogPortEnum.A.getType());
    Character servoType = configuration.getCharacter("sonicServoType", MotorTypeEnum.MEDIUM.getType());
    MotorProvider motorProvider = new MotorProvider();
    servo = new MotorWrapper<>(motorProvider, AnalogPortEnum.getByType(servoPort), MotorTypeEnum.getByType(servoType));
    unitActive.set(true);
    servoRight.set(true);
    setState(LifecycleState.INITIALIZED);
}
Also used : SensorProvider(com.robo4j.hw.lego.provider.SensorProvider) MotorProvider(com.robo4j.hw.lego.provider.MotorProvider)

Example 2 with MotorProvider

use of com.robo4j.hw.lego.provider.MotorProvider in project robo4j by Robo4J.

the class BasicSonicServoUnit method onInitialization.

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    setState(LifecycleState.UNINITIALIZED);
    target = configuration.getString("target", null);
    if (target == null) {
        throw ConfigurationException.createMissingConfigNameException("target");
    }
    String sensorType = configuration.getString("sonicSensorPort", DigitalPortEnum.S3.getType());
    SensorProvider provider = new SensorProvider();
    sensor = new SensorWrapper<>(provider, DigitalPortEnum.getByType(sensorType), SensorTypeEnum.SONIC);
    String servoPort = configuration.getString("sonicServoPort", AnalogPortEnum.A.getType());
    Character servoType = configuration.getCharacter("sonicServoType", MotorTypeEnum.MEDIUM.getType());
    MotorProvider motorProvider = new MotorProvider();
    servo = new MotorWrapper<>(motorProvider, AnalogPortEnum.getByType(servoPort), MotorTypeEnum.getByType(servoType));
    unitActive.set(true);
    servoRight.set(true);
    setState(LifecycleState.INITIALIZED);
}
Also used : SensorProvider(com.robo4j.hw.lego.provider.SensorProvider) MotorProvider(com.robo4j.hw.lego.provider.MotorProvider)

Example 3 with MotorProvider

use of com.robo4j.hw.lego.provider.MotorProvider in project robo4j by Robo4J.

the class GripperController method onInitialization.

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    setState(LifecycleState.UNINITIALIZED);
    String motorPort = configuration.getString(MOTOR_PORT, AnalogPortEnum.A.getType());
    Character motorType = configuration.getCharacter(MOTOR_TYPE, MotorTypeEnum.NXT.getType());
    MotorProvider motorProvider = new MotorProvider();
    gripperMotor = new MotorWrapper<>(motorProvider, AnalogPortEnum.getByType(motorPort), MotorTypeEnum.getByType(motorType));
    setState(LifecycleState.INITIALIZED);
}
Also used : MotorProvider(com.robo4j.hw.lego.provider.MotorProvider)

Example 4 with MotorProvider

use of com.robo4j.hw.lego.provider.MotorProvider in project robo4j by Robo4J.

the class SingleMotorUnit method onInitialization.

/**
 * @param configuration
 *            the {@link Configuration} provided.
 * @throws ConfigurationException
 *             exception
 */
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    setState(LifecycleState.UNINITIALIZED);
    String motorPort = configuration.getString("motorPort", AnalogPortEnum.A.getType());
    Character motorType = configuration.getCharacter("motorType", MotorTypeEnum.NXT.getType());
    MotorProvider motorProvider = new MotorProvider();
    motor = new MotorWrapper<>(motorProvider, AnalogPortEnum.getByType(motorPort), MotorTypeEnum.getByType(motorType));
    setState(LifecycleState.INITIALIZED);
}
Also used : MotorProvider(com.robo4j.hw.lego.provider.MotorProvider)

Example 5 with MotorProvider

use of com.robo4j.hw.lego.provider.MotorProvider in project robo4j by Robo4J.

the class SimpleTankUnit method onInitialization.

/**
 * @param configuration
 *            the {@link Configuration} provided.
 * @throws ConfigurationException
 *             exception
 */
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    setState(LifecycleState.UNINITIALIZED);
    speed = configuration.getInteger(PROPERTY_SPEED, LegoPlatformMessage.DEFAULT_SPEED);
    String leftMotorPort = configuration.getString(PROPERTY_LEFT_MOTOR_PORT, AnalogPortEnum.B.getType());
    Character leftMotorType = configuration.getCharacter(PROPERTY_LEFT_MOTOR_TYPE, MotorTypeEnum.NXT.getType());
    String rightMotorPort = configuration.getString(PROPERTY_RIGHT_MOTOR_PORT, AnalogPortEnum.C.getType());
    Character rightMotorType = configuration.getCharacter(PROPERTY_RIGHT_MOTOR_TYPE, MotorTypeEnum.NXT.getType());
    MotorProvider motorProvider = new MotorProvider();
    rightMotor = new MotorWrapper<>(motorProvider, AnalogPortEnum.getByType(rightMotorPort), MotorTypeEnum.getByType(rightMotorType));
    rightMotor.setSpeed(speed);
    leftMotor = new MotorWrapper<>(motorProvider, AnalogPortEnum.getByType(leftMotorPort), MotorTypeEnum.getByType(leftMotorType));
    leftMotor.setSpeed(speed);
    setState(LifecycleState.INITIALIZED);
}
Also used : MotorProvider(com.robo4j.hw.lego.provider.MotorProvider)

Aggregations

MotorProvider (com.robo4j.hw.lego.provider.MotorProvider)5 SensorProvider (com.robo4j.hw.lego.provider.SensorProvider)2