Package me.autobot.lib.robot.motors
Class HoverboardWheel
java.lang.Object
me.autobot.lib.robot.Device
me.autobot.lib.robot.Motor
me.autobot.lib.robot.motors.HoverboardWheel
- All Implemented Interfaces:
Logger
A hoverboard wheel motor.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionHoverboardWheel
(int identifier, int address) Creates a new HoverboardWheel with the given I2C address (and default I2C bus).HoverboardWheel
(int identifier, int address, int bus) Creates a new HoverboardWheel with the given I2C address and bus. -
Method Summary
Modifier and TypeMethodDescriptionvoid
connectToSerial
(String port) Do not use this method, use the one with the directionPin and speedPin instead.void
connectToSerial
(String port, int directionPin, int speedPin) Connects the motor to the serial port.protected void
Reports the speed of the motor to the connection.void
setMaxSpeed
(double maxSpeed) Sets the maximum speed of the motor.void
setSpeed
(double speed) Sets the speed of the motor.protected void
writeToPWMPin
(int index, byte[] value) Writes a byte list to a specific pin.protected void
writeToPWMPin
(int index, float value) Writes a float to a specific pin.Methods inherited from class me.autobot.lib.robot.Motor
brake, connectToI2C, emergencyStop, getAddress, getBus, getIdentifier, inSimulation, invert, isInverted, stop
Methods inherited from class me.autobot.lib.robot.Device
emergencyStopAll, enableSimulation, getCurrent, getParent, getProperties, getProperty, getVoltage, registerDevice, setParent, setProperty
-
Constructor Details
-
HoverboardWheel
public HoverboardWheel(int identifier, int address) Creates a new HoverboardWheel with the given I2C address (and default I2C bus).- Parameters:
identifier
- The identifier of the motor.address
- The address of the motor.
-
HoverboardWheel
public HoverboardWheel(int identifier, int address, int bus) Creates a new HoverboardWheel with the given I2C address and bus.- Parameters:
identifier
- The identifier of the motor.address
- The address of the motor.bus
- The bus of the motor.
-
-
Method Details
-
connectToSerial
Do not use this method, use the one with the directionPin and speedPin instead.- Overrides:
connectToSerial
in classMotor
- Parameters:
port
- The port to connect to.
-
connectToSerial
Connects the motor to the serial port.- Parameters:
port
- The port to connect to. Example: "/dev/cu.wchusbserial.10"directionPin
- The pin to use for the direction.speedPin
- The pin to use for the speed.
-
setSpeed
public void setSpeed(double speed) Sets the speed of the motor. -
reportSpeed
protected void reportSpeed()Reports the speed of the motor to the connection.- Overrides:
reportSpeed
in classMotor
-
writeToPWMPin
protected void writeToPWMPin(int index, float value) Writes a float to a specific pin.- Parameters:
index
- The index of the pin to write to.value
- The float to write to the pin.
-
writeToPWMPin
protected void writeToPWMPin(int index, byte[] value) Writes a byte list to a specific pin. Should be 4 bytes long (a float!)- Parameters:
index
- The index of the pin to write to.value
- The byte list (length=4) to write to the pin.
-
setMaxSpeed
public void setMaxSpeed(double maxSpeed) Sets the maximum speed of the motor.- Parameters:
maxSpeed
- The maximum speed of the motor.
-