Package com.pocolifo.robobase.motor
Class Motor
- java.lang.Object
-
- com.pocolifo.robobase.motor.Motor
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Direct Known Subclasses:
Wheel
public class Motor extends java.lang.Object implements java.lang.AutoCloseable
Represents a motor. This class is needed becauseDcMotor
misses some metrics, like the tick count of the motor. The tick count is necessary to use motor encoders (i.e. moving the wheels exactly 1 meter forward).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the internalDcMotor
device.void
drive(double speed)
Starts moving the motor at a given speed.void
stopMoving()
Stop the movement of the motor.
-
-
-
Field Detail
-
motor
public final com.qualcomm.robotcore.hardware.DcMotor motor
TheDcMotor
associated with this motor.
-
tickCount
public final int tickCount
The amount of motor ticks that make one full revolution of the motor. It's different for every motor, you may need to search up what the tick count is for your motor.
-
-
Method Detail
-
drive
public void drive(double speed)
Starts moving the motor at a given speed.- Parameters:
speed
- Determines the speed at which the motor should move.
-
stopMoving
public void stopMoving()
Stop the movement of the motor.
-
close
public void close()
Closes the internalDcMotor
device. THIS SHOULD BE CALLED WHEN MOTORS ARE DONE BEING USED!- Specified by:
close
in interfacejava.lang.AutoCloseable
-
-