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
-
Constructor Summary
Constructors Constructor Description DualMotor(MotorInterface leftMotor, MotorInterface rightMotor)
-
Method Summary
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
getLeftMotor()
MotorInterface
getRightMotor()
float[]
getValues()
void
reverse()
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 Details
-
DualMotor
-
-
Method Details
-
close
public void close()Description copied from interface:DeviceInterface
Close this device- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
-
getValues
- Throws:
RuntimeIOException
-
setValues
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
- Throws:
RuntimeIOException
-
backward
- Throws:
RuntimeIOException
-
rotateLeft
- Throws:
RuntimeIOException
-
rotateRight
- Throws:
RuntimeIOException
-
forwardLeft
- Throws:
RuntimeIOException
-
forwardRight
- Throws:
RuntimeIOException
-
backwardLeft
- Throws:
RuntimeIOException
-
backwardRight
- Throws:
RuntimeIOException
-
reverse
- Throws:
RuntimeIOException
-
circleLeft
public void circleLeft(float speed, float turnRate) -
circleRight
public void circleRight(float speed, float turnRate) -
stop
- Throws:
RuntimeIOException
-
getLeftMotor
-
getRightMotor
-