ch.aplu.nxt
Class TurtleRobot
java.lang.Object
ch.aplu.nxt.NxtRobot
ch.aplu.nxt.TurtleRobot
- All Implemented Interfaces:
- SharedConstants
public class TurtleRobot
- extends NxtRobot
Implementation of the basic Logo turtle movements.
Fields inherited from interface ch.aplu.nxt.SharedConstants |
ABOUT, ANGLE, ANGLESTEPSMODE, BOOLEANMODE, BOOT, BRAKE, CELSIUSMODE, CLOSE, CUSTOM, DEBUG_LEVEL_HIGH, DEBUG_LEVEL_LOW, DEBUG_LEVEL_MEDIUM, DEBUG_LEVEL_OFF, DELETE, DELETE_USER_FLASH, DIRECT_COMMAND_NOREPLY, DIRECT_COMMAND_REPLY, FAHRENHEITMODE, FIND_FIRST, FIND_NEXT, GET_BATTERY_LEVEL, GET_CURRENT_PROGRAM_NAME, GET_DEVICE_INFO, GET_FIRMWARE_VERSION, GET_INPUT_VALUES, GET_OUTPUT_STATE, HIGH_SPEED_BUFFER, KEEP_ALIVE, LIGHT_ACTIVE, LIGHT_INACTIVE, LOWSPEED, LOWSPEED_9V, LS_GET_STATUS, LS_READ, LS_WRITE, MESSAGE_READ, MESSAGE_WRITE, MODEMASK, MOTOR_RUN_STATE_IDLE, MOTOR_RUN_STATE_RAMPDOWN, MOTOR_RUN_STATE_RAMPUP, MOTOR_RUN_STATE_RUNNING, MOTORON, NO_OF_SENSOR_TYPES, NO_SENSOR, NXJ_FIND_FIRST, NXJ_FIND_NEXT, OPEN_APPEND_DATA, OPEN_READ, OPEN_READ_LINEAR, OPEN_WRITE, OPEN_WRITE_DATA, OPEN_WRITE_LINEAR, PCTFULLSCALEMODE, PERIODCOUNTERMODE, PLAY_SOUND_FILE, PLAY_TONE, POLL, POLL_BUFFER, POLL_LENGTH, RAWMODE, READ, REFLECTION, REGULATED, REGULATION_MODE_IDLE, REGULATION_MODE_MOTOR_SPEED, REGULATION_MODE_MOTOR_SYNC, REPLY_COMMAND, RESET_MOTOR_POSITION, RESET_SCALED_INPUT_VALUE, SET_BRICK_NAME, SET_INPUT_MODE, SET_OUTPUT_STATE, SLOPEMASK, SOUND_DB, SOUND_DBA, START_PROGRAM, STOP_PROGRAM, STOP_SOUND_PLAYBACK, SWITCH, SYSTEM_COMMAND_NOREPLY, SYSTEM_COMMAND_REPLY, TEMPERATURE, TITLE, TITLEMP, TRANSITIONCNTMODE, VERSION, WRITE |
Constructor Summary |
TurtleRobot()
Same as TurtleRobot(btName), but ask for Bluetooth name |
TurtleRobot(java.lang.String btName)
Same as TurtleRobot(btName, true) |
TurtleRobot(java.lang.String btName,
boolean showPane)
Creates a turtle instance using a NXT brick with given Bluetooth name. |
Methods inherited from class ch.aplu.nxt.NxtRobot |
addPart, connect, connect, connect, disconnect, exit, fileExists, findFirst, findNext, getAbout, getBatteryLevel, getBtAddress, getBtAddressLong, getBtName, getDebugLevel, getFriendlyName, getInputStream, getInputValues, getOutputState, getOutputStream, getProperties, getStreamConnection, getVersion, isConnected, keepAlive, playConnectMelody, playDisconnectMelody, playTone, readData, requestData, sendData, setChannel, setInputMode, setOutputState, startProgram |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TurtleRobot
public TurtleRobot(java.lang.String btName,
boolean showPane)
- Creates a turtle instance using a NXT brick with given Bluetooth name.
A connection trial is engaged while an information box is shown.
If the connection fails, the calling thread will be put in a wait state and the program hangs.
The user can then terminate the application by closing the information pane.
established at this time.
If showConsole = true, the turtle commands are displayed in a console window.
If btName = null, a input dialog is displayed where the Bluetooth name can be entered.
- Parameters:
btName
- the Bluetooth friendly name, e.g. NXTshowPane
- if true, an information pane is showed, where the turtle commands are listed
TurtleRobot
public TurtleRobot(java.lang.String btName)
- Same as TurtleRobot(btName, true)
- Parameters:
btName
- the Bluetooth friendly name, e.g. NXT
TurtleRobot
public TurtleRobot()
- Same as TurtleRobot(btName), but ask for Bluetooth name
getGear
public Gear getGear()
- Returns the gear used as component of the turtle.
- Returns:
- the reference of the Gear instance
setTurtleSpeed
public TurtleRobot setTurtleSpeed(int speed)
- Sets the turtle speed to the given value.
The TurtleRotationSpeed remains unchanged.
The speed will be changed to the new value at the next movement call only.
- Parameters:
speed
- 0..100
- Returns:
- the object reference to allow method chaining
getTurtleSpeed
public int getTurtleSpeed()
- Returns the current turtle speed.
- Returns:
- speed 0..100
forward
public TurtleRobot forward(int steps)
- Moves the turtle forward the given number of steps.
The methods blocks until the turtle is at the final position.
The actual distance depends on the "TurtleStepFactor"
as defined in the nxtlib.properties file.
The turtle speed corresponds to the "TurtleSpeed"
as defined in the nxtlib.properties file.
- Parameters:
steps
- the number of steps to go.
- Returns:
- the object reference to allow method chaining
backward
public TurtleRobot backward(int steps)
- Moves the turtle backward the given number of steps.
The methods blocks until the turtle is at the final position.
The actual distance depends on the "TurtleStepFactor"
as defined in the nxtlib.properties file.
The turtle speed corresponds to the "TurtleSpeed"
as defined in the nxtlib.properties file.
- Parameters:
steps
- the number of steps to go.
- Returns:
- the object reference to allow method chaining
left
public TurtleRobot left(int angle)
- Turns the turtle to the left for the given angle.
The methods blocks until the turtle is at the final position.
Due to the construction of the NXT the accuracy is limited.
It depends on the "TurtleRotationFactor" and the "TurtleRotationSpeed"
as defined in the nxtlib.properties file.
- Parameters:
angle
- the angle in degree to rotate.
- Returns:
- the object reference to allow method chaining
right
public TurtleRobot right(int angle)
- Turns the turtle to the right for the given angle.
The methods blocks until the turtle is at the final position.
Due to the construction of the NXT the accuracy is limited.
It depends on the "TurtleRotationFactor" and the "TurtleRotationSpeed"
as defined in the nxtlib.properties file.
- Parameters:
angle
- the angle in degree to rotate.
- Returns:
- the object reference to allow method chaining