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.AutoCloseableRepresents a motor. This class is needed becauseDcMotormisses 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 voidclose()Closes the internalDcMotordevice.voiddrive(double speed)Starts moving the motor at a given speed.voidstopMoving()Stop the movement of the motor.
-
-
-
Field Detail
-
motor
public final com.qualcomm.robotcore.hardware.DcMotor motor
TheDcMotorassociated 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 internalDcMotordevice. THIS SHOULD BE CALLED WHEN MOTORS ARE DONE BEING USED!- Specified by:
closein interfacejava.lang.AutoCloseable
-
-