public class Gear extends Part
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ABOUT |
static byte |
ANGLE |
static byte |
ANGLESTEPSMODE |
static double |
AXE_LENGTH
Axe length (in m) used by Gear.leftArc(), Gear.rightArc()
|
static byte |
BOOLEANMODE |
static byte |
BOOT |
static byte |
BRAKE |
static byte |
CELSIUSMODE |
static byte |
CLOSE |
static int |
COMPASS_SENSOR_POLL_DELAY |
static double |
CRAWLER_ROTATION_FACTOR
Factor between crawler robot angle (in degrees) and motor rotation count
|
static int |
CRAWLER_ROTATION_SPEED
Turtle crawler speed for rotations
|
static int |
CRAWLER_SPEED
Turtle crawler speed for straight movements
|
static double |
CRAWLER_STEP_FACTOR
Factor between turtle crawler steps and motor rotation count
|
static byte |
CUSTOM |
static byte |
DELETE |
static byte |
DELETE_USER_FLASH |
static byte |
DIRECT_COMMAND_NOREPLY |
static byte |
DIRECT_COMMAND_REPLY |
static byte |
FAHRENHEITMODE |
static byte |
FIND_FIRST |
static byte |
FIND_NEXT |
static int |
GEAR_ACCELERATION_DELAY
Time to wait between increasing/decreasing speed steps in Gear.moveTo()
|
static int |
GEAR_BRAKE_DELAY
Time to wait between succeeding movement calls before stop
|
static int |
GEAR_SPEED
Default gear speed
|
static byte |
GET_BATTERY_LEVEL |
static byte |
GET_CURRENT_PROGRAM_NAME |
static byte |
GET_DEVICE_INFO |
static byte |
GET_FIRMWARE_VERSION |
static byte |
GET_INPUT_VALUES |
static byte |
GET_OUTPUT_STATE |
static byte |
HIGH_SPEED_BUFFER |
static byte |
KEEP_ALIVE |
static byte |
LIGHT_ACTIVE |
static byte |
LIGHT_INACTIVE |
static int |
LIGHT_SENSOR_POLL_DELAY |
static byte |
LOWSPEED |
static byte |
LOWSPEED_9V |
static byte |
LS_GET_STATUS |
static byte |
LS_READ |
static byte |
LS_WRITE |
static byte |
MESSAGE_READ |
static byte |
MESSAGE_WRITE |
static byte |
MODEMASK |
static int |
MOTION_DETECTOR_POLL_DELAY |
static byte |
MOTOR_RUN_STATE_IDLE |
static byte |
MOTOR_RUN_STATE_RAMPDOWN |
static byte |
MOTOR_RUN_STATE_RAMPUP |
static byte |
MOTOR_RUN_STATE_RUNNING |
static int |
MOTOR_SPEED
Default motor speed
|
static double |
MOTOR_SPEED_FACTOR
Factor between speed and velocity (in m/s): velocity = MotorSpeedFactor * speed
|
static byte |
MOTORON |
static byte |
NO_OF_SENSOR_TYPES |
static byte |
NO_SENSOR |
static byte |
NXJ_FIND_FIRST |
static byte |
NXJ_FIND_NEXT |
static byte |
OPEN_APPEND_DATA |
static byte |
OPEN_READ |
static byte |
OPEN_READ_LINEAR |
static byte |
OPEN_WRITE |
static byte |
OPEN_WRITE_DATA |
static byte |
OPEN_WRITE_LINEAR |
static byte |
PCTFULLSCALEMODE |
static byte |
PERIODCOUNTERMODE |
static byte |
PLAY_SOUND_FILE |
static byte |
PLAY_TONE |
static byte |
POLL |
static byte |
POLL_BUFFER |
static byte |
POLL_LENGTH |
static byte |
RAWMODE |
static byte |
READ |
static byte |
REFLECTION |
static byte |
REGULATED |
static byte |
REGULATION_MODE_IDLE |
static byte |
REGULATION_MODE_MOTOR_SPEED |
static byte |
REGULATION_MODE_MOTOR_SYNC |
static byte |
REPLY_COMMAND |
static byte |
RESET_MOTOR_POSITION |
static byte |
RESET_SCALED_INPUT_VALUE |
static byte |
SET_BRICK_NAME |
static byte |
SET_INPUT_MODE |
static byte |
SET_OUTPUT_STATE |
static byte |
SLOPEMASK |
static byte |
SOUND_DB |
static byte |
SOUND_DBA |
static int |
SOUND_SENSOR_POLL_DELAY
Wait time (in ms) between polling the sensor value when registering an event handler
|
static byte |
START_PROGRAM |
static byte |
STOP_PROGRAM |
static byte |
STOP_SOUND_PLAYBACK |
static byte |
SWITCH |
static byte |
SYSTEM_COMMAND_NOREPLY |
static byte |
SYSTEM_COMMAND_REPLY |
static byte |
TEMPERATURE |
static int |
TOUCH_SENSOR_POLL_DELAY |
static byte |
TRANSITIONCNTMODE |
static double |
TURTLE_ROTATION_FACTOR
Factor between turtle angle (in degrees) and motor rotation count
|
static int |
TURTLE_ROTATION_SPEED
Turtle speed for rotations
|
static int |
TURTLE_SPEED
Turtle speed for straight movements
|
static double |
TURTLE_STEP_FACTOR
Factor between turtle steps and motor rotation count
|
static int |
ULTRASONIC_SENSOR_POLL_DELAY |
static java.lang.String |
VERSION |
static byte |
WRITE |
Constructor and Description |
---|
Gear()
Creates a gear instance with left motor plugged into port A, right motor plugged into port B.
|
Gear(MotorPort port1,
MotorPort port2)
Creates a gear instance with left motor plugged into port1, right motor plugged into port2.
|
Modifier and Type | Method and Description |
---|---|
void |
addMotionListener(MotionListener motionListener)
Register the given motion listener.
|
Gear |
backward()
Same as forward(), but move in reverse direction.
|
Gear |
backward(int duration)
Same as forward(int duration), but move in reverse direction.
|
Gear |
forward()
Starts the forward movement with preset speed.
|
Gear |
forward(int duration)
Starts the forward movement for the given duration (in ms) with preset speed.
|
Motor |
getMotLeft()
Returns left motor of the gear.
|
Motor |
getMotRight()
Returns right motor of the gear.
|
int |
getSpeed()
Returns the current speed (arbitrary units).
|
double |
getVelocity()
Returns the current velocity.
|
Gear |
left()
Starts turning left with left motor stopped and right motor at preset speed.
|
Gear |
left(int duration)
Starts turning left for the given duration (in ms) with preset speed.
|
Gear |
leftArc(double radius)
Starts turning to the left on an arc with given radius (in m).
|
Gear |
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.
|
Gear |
moveTo(int count)
Same as moveTo(int count, boolean blocking) with blocking = true.
|
Gear |
moveTo(int count,
boolean blocking)
Sets the rotation counter to zero and rotate both motors until the given count is reached.
|
Gear |
right()
Same as left(), but turning in the opposite direction.
|
Gear |
right(int duration)
Same as left(int duration), but turning in the opposite direction.
|
Gear |
rightArc(double radius)
Same as leftArc(double radius), but turns in the right.
|
Gear |
rightArc(double radius,
int duration)
Same as leftArc(double radius, int duration), but turns to the right.
|
Gear |
setSpeed(int speed)
Sets the speed to the given value (arbitrary units).
|
Gear |
setVelocity(double velocity)
Sets the velocity to the given value.
|
Gear |
stop()
Stops the gear.
|
Gear |
turnTo(int count)
Same as turnTo(int count, boolean blocking) with blocking = true.
|
Gear |
turnTo(int count,
boolean blocking)
Sets the rotation counter to zero and turn with the motors running in
opposite direction.
|
public static final int MOTOR_SPEED
public static final double MOTOR_SPEED_FACTOR
public static final int GEAR_SPEED
public static final int GEAR_BRAKE_DELAY
public static final int GEAR_ACCELERATION_DELAY
public static final double AXE_LENGTH
public static final int TURTLE_SPEED
public static final double TURTLE_STEP_FACTOR
public static final int TURTLE_ROTATION_SPEED
public static final double TURTLE_ROTATION_FACTOR
public static final int CRAWLER_SPEED
public static final double CRAWLER_STEP_FACTOR
public static final int CRAWLER_ROTATION_SPEED
public static final double CRAWLER_ROTATION_FACTOR
public static final int SOUND_SENSOR_POLL_DELAY
public static final int LIGHT_SENSOR_POLL_DELAY
public static final int TOUCH_SENSOR_POLL_DELAY
public static final int ULTRASONIC_SENSOR_POLL_DELAY
public static final int MOTION_DETECTOR_POLL_DELAY
public static final int COMPASS_SENSOR_POLL_DELAY
public static final java.lang.String ABOUT
public static final java.lang.String VERSION
public static final byte DIRECT_COMMAND_REPLY
public static final byte SYSTEM_COMMAND_REPLY
public static final byte REPLY_COMMAND
public static final byte DIRECT_COMMAND_NOREPLY
public static final byte SYSTEM_COMMAND_NOREPLY
public static final byte OPEN_READ
public static final byte OPEN_WRITE
public static final byte READ
public static final byte WRITE
public static final byte CLOSE
public static final byte DELETE
public static final byte FIND_FIRST
public static final byte FIND_NEXT
public static final byte GET_FIRMWARE_VERSION
public static final byte OPEN_WRITE_LINEAR
public static final byte OPEN_READ_LINEAR
public static final byte OPEN_WRITE_DATA
public static final byte OPEN_APPEND_DATA
public static final byte BOOT
public static final byte SET_BRICK_NAME
public static final byte GET_DEVICE_INFO
public static final byte DELETE_USER_FLASH
public static final byte POLL_LENGTH
public static final byte POLL
public static final byte POLL_BUFFER
public static final byte HIGH_SPEED_BUFFER
public static final byte START_PROGRAM
public static final byte STOP_PROGRAM
public static final byte PLAY_SOUND_FILE
public static final byte PLAY_TONE
public static final byte SET_OUTPUT_STATE
public static final byte SET_INPUT_MODE
public static final byte GET_OUTPUT_STATE
public static final byte GET_INPUT_VALUES
public static final byte RESET_SCALED_INPUT_VALUE
public static final byte MESSAGE_WRITE
public static final byte RESET_MOTOR_POSITION
public static final byte GET_BATTERY_LEVEL
public static final byte STOP_SOUND_PLAYBACK
public static final byte KEEP_ALIVE
public static final byte LS_GET_STATUS
public static final byte LS_WRITE
public static final byte LS_READ
public static final byte GET_CURRENT_PROGRAM_NAME
public static final byte MESSAGE_READ
public static final byte MOTORON
public static final byte BRAKE
public static final byte REGULATED
public static final byte REGULATION_MODE_IDLE
public static final byte REGULATION_MODE_MOTOR_SPEED
public static final byte REGULATION_MODE_MOTOR_SYNC
public static final byte MOTOR_RUN_STATE_IDLE
public static final byte MOTOR_RUN_STATE_RAMPUP
public static final byte MOTOR_RUN_STATE_RUNNING
public static final byte MOTOR_RUN_STATE_RAMPDOWN
public static final byte NO_SENSOR
public static final byte SWITCH
public static final byte TEMPERATURE
public static final byte REFLECTION
public static final byte ANGLE
public static final byte LIGHT_ACTIVE
public static final byte LIGHT_INACTIVE
public static final byte SOUND_DB
public static final byte SOUND_DBA
public static final byte CUSTOM
public static final byte LOWSPEED
public static final byte LOWSPEED_9V
public static final byte NO_OF_SENSOR_TYPES
public static final byte RAWMODE
public static final byte BOOLEANMODE
public static final byte TRANSITIONCNTMODE
public static final byte PERIODCOUNTERMODE
public static final byte PCTFULLSCALEMODE
public static final byte CELSIUSMODE
public static final byte FAHRENHEITMODE
public static final byte ANGLESTEPSMODE
public static final byte SLOPEMASK
public static final byte MODEMASK
public static final byte NXJ_FIND_FIRST
public static final byte NXJ_FIND_NEXT
public Gear(MotorPort port1, MotorPort port2)
port1
- MotorPort.A or MotorPort.B or MotorPort.C (not both the same)port2
- MotorPort.A or MotorPort.B or MotorPort.C (not both the same)public Gear()
public int getSpeed()
public double getVelocity()
public Gear setSpeed(int speed)
speed
- 0..100public Gear setVelocity(double velocity)
velocity
- in m/spublic Gear stop()
public Gear moveTo(int count, boolean blocking)
addMotionListener(MotionListener motionListener)
,
moveTo(int count)
public Gear moveTo(int count)
moveTo(int count, boolean blocking)
public Gear turnTo(int count)
turnTo(int count, boolean blocking)
public Gear turnTo(int count, boolean blocking)
turnTo(int count)
public void addMotionListener(MotionListener motionListener)
motionListener
- the MotionListener to be registeredpublic Gear forward()
public Gear forward(int duration)
duration
- the duration (in ms)public Gear backward()
forward()
public Gear backward(int duration)
forward(int duration)
public Gear left()
public Gear left(int duration)
duration
- the duration (in ms)public Gear right(int duration)
left(int duration)
public Gear leftArc(double radius)
radius
- the radius of the arc (in m)public Gear leftArc(double radius, int duration)
radius
- the radius of the arc (in m)duration
- the duration (in ms)public Gear rightArc(double radius)
leftArc(double radius)
public Gear rightArc(double radius, int duration)
leftArc(double radius, int duration)
public Motor getMotRight()
public Motor getMotLeft()