Modifier and Type | Method and Description |
---|---|
GenericGear |
backward()
Same as forward(), but move in reverse direction.
|
GenericGear |
backward(int duration)
Same as forward(int duration), but move in reverse direction.
|
GenericGear |
forward()
Starts the forward movement with preset speed.
|
GenericGear |
forward(int duration)
Starts the forward movement for the given duration (in ms) with preset speed.
|
int |
getLeftMotorCount()
Returns current value of the rotation counter of the left motor.
|
int |
getRightMotorCount()
Returns current value of the rotation counter of the right motor.
|
int |
getSpeed()
Returns the current speed (arbitrary units).
|
double |
getVelocity()
Returns the current velocity.
|
boolean |
isMoving()
Checks if one or both motors are rotating.
|
GenericGear |
left()
Starts turning left with left motor stopped and right motor at preset speed.
|
GenericGear |
left(int duration)
Starts turning left for the given duration (in ms) with preset speed.
|
GenericGear |
leftArc(double radius)
Starts turning to the left on an arc with given radius (in m).
|
GenericGear |
leftArc(double radius,
int duration)
Starts turning to the left on an arc with given radius (in m) for the given
duration (in ms) with preset speed.
|
GenericGear |
moveTo(int count)
Same as moveTo(int count, boolean blocking) with blocking = true.
|
GenericGear |
moveTo(int count,
boolean blocking)
Sets the rotation counter to zero and rotate both motors until the given count is reached.
|
void |
resetLeftMotorCount()
Resets the rotation counter of the left motor to zero.
|
void |
resetRightMotorCount()
Resets the rotation counter of the right motor to zero.
|
GenericGear |
right()
Same as left(), but turns in the opposite direction.
|
GenericGear |
right(int duration)
Same as left(int duration), but turning in the opposite direction.
|
GenericGear |
rightArc(double radius)
Same as leftArc(double radius), but turns in the right.
|
GenericGear |
rightArc(double radius,
int duration)
Same as leftArc(double radius, int duration), but turns to the right.
|
GenericGear |
setAcceleration(int acceleration)
Sets the acceleration rate of both motors in degrees/sec/sec
Smaller values make speed changes smoother.
|
GenericGear |
setSpeed(int speed)
Sets the speed to the given value (arbitrary units).
|
void |
setSpeedFactor(double value)
Sets the motor speed factor to given value.
|
GenericGear |
setVelocity(double velocity)
Sets the velocity to the given value.
|
double |
speedToVelocity(int speed)
Conversion from speed to velocity.
|
GenericGear |
stop()
Stops the gear.
|
GenericGear |
turnTo(int count)
Same as turnTo(int count, boolean blocking) with blocking = true.
|
GenericGear |
turnTo(int count,
boolean blocking)
Sets the rotation counter to zero and turn with the motors running in
opposite direction.
|
int |
velocityToSpeed(double velocity)
Conversion from velocity to speed.
|
public int getSpeed()
public double getVelocity()
public GenericGear setSpeed(int speed)
speed
- 0..100public GenericGear setAcceleration(int acceleration)
acceleration
- the new accelarationpublic GenericGear setVelocity(double velocity)
velocity
- in m/spublic GenericGear stop()
public GenericGear moveTo(int count, boolean blocking)
moveTo(int count)
public GenericGear moveTo(int count)
moveTo(int count, boolean blocking)
public GenericGear turnTo(int count)
turnTo(int count, boolean blocking)
public GenericGear turnTo(int count, boolean blocking)
turnTo(int count)
public GenericGear forward()
public GenericGear forward(int duration)
duration
- the duration (in ms)public GenericGear backward()
forward()
public GenericGear backward(int duration)
forward(int duration)
public GenericGear left()
public GenericGear left(int duration)
duration
- the duration (in ms)public GenericGear right()
left()
public GenericGear right(int duration)
left(int duration)
public GenericGear leftArc(double radius)
radius
- the radius of the arc (in m)public GenericGear leftArc(double radius, int duration)
radius
- the radius of the arc (in m)duration
- the duration (in ms)public GenericGear rightArc(double radius)
leftArc(double radius)
public GenericGear rightArc(double radius, int duration)
leftArc(double radius, int duration)
public boolean isMoving()
public void setSpeedFactor(double value)
value
- the velocity per speed unitpublic double speedToVelocity(int speed)
speed
- the speed as set in setSpeed()public int velocityToSpeed(double velocity)
velocity
- the velocity in m/spublic int getLeftMotorCount()
public int getRightMotorCount()
public void resetLeftMotorCount()
public void resetRightMotorCount()