Package com.diozero.devices.motor
Class DualMotor
- java.lang.Object
-
- com.diozero.devices.motor.DualMotor
-
- All Implemented Interfaces:
DeviceInterface
,AutoCloseable
- Direct Known Subclasses:
CamJamKitDualMotor
,RyanteckDualMotor
,TB6612FNGDualMotorDriver
public class DualMotor extends Object implements DeviceInterface
Generic dual bi-directional motor driver. Assumes that the motors are arranged in a left / right orientation.
-
-
Constructor Summary
Constructors Constructor Description DualMotor(MotorInterface motorA, MotorInterface motorB)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
backward(float speed)
void
backwardLeft(float speed)
void
backwardRight(float speed)
void
circleLeft(float speed, float turnRate)
void
circleRight(float speed, float turnRate)
void
close()
Close this devicevoid
forward(float speed)
void
forwardLeft(float speed)
void
forwardRight(float speed)
MotorInterface
getMotorA()
MotorInterface
getMotorB()
float[]
getValues()
void
reverseDirection()
void
rotateLeft(float speed)
void
rotateRight(float speed)
void
setValues(float leftValue, float rightValue)
Set the speed and direction for both motors (clockwise / counter-clockwise)void
stop()
-
-
-
Constructor Detail
-
DualMotor
public DualMotor(MotorInterface motorA, MotorInterface motorB)
-
-
Method Detail
-
close
public void close()
Description copied from interface:DeviceInterface
Close this device- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
-
getValues
public float[] getValues() throws RuntimeIOException
- Throws:
RuntimeIOException
-
setValues
public void setValues(float leftValue, float rightValue) throws RuntimeIOException
Set the speed and direction for both motors (clockwise / counter-clockwise)- Parameters:
leftValue
- Range -1 .. 1. Positive numbers for clockwise, Negative numbers for counter clockwiserightValue
- Range -1 .. 1. Positive numbers for clockwise, Negative numbers for counter clockwise- Throws:
RuntimeIOException
- if an I/O error occurs
-
forward
public void forward(float speed) throws RuntimeIOException
- Throws:
RuntimeIOException
-
backward
public void backward(float speed) throws RuntimeIOException
- Throws:
RuntimeIOException
-
rotateLeft
public void rotateLeft(float speed) throws RuntimeIOException
- Throws:
RuntimeIOException
-
rotateRight
public void rotateRight(float speed) throws RuntimeIOException
- Throws:
RuntimeIOException
-
forwardLeft
public void forwardLeft(float speed) throws RuntimeIOException
- Throws:
RuntimeIOException
-
forwardRight
public void forwardRight(float speed) throws RuntimeIOException
- Throws:
RuntimeIOException
-
backwardLeft
public void backwardLeft(float speed) throws RuntimeIOException
- Throws:
RuntimeIOException
-
backwardRight
public void backwardRight(float speed) throws RuntimeIOException
- Throws:
RuntimeIOException
-
reverseDirection
public void reverseDirection() throws RuntimeIOException
- Throws:
RuntimeIOException
-
circleLeft
public void circleLeft(float speed, float turnRate)
-
circleRight
public void circleRight(float speed, float turnRate)
-
stop
public void stop() throws RuntimeIOException
- Throws:
RuntimeIOException
-
getMotorA
public MotorInterface getMotorA()
-
getMotorB
public MotorInterface getMotorB()
-
-