ch.aplu.nxt
Class TurtleRobot

java.lang.Object
  extended by ch.aplu.nxt.NxtRobot
      extended by ch.aplu.nxt.TurtleRobot
All Implemented Interfaces:
SharedConstants
Direct Known Subclasses:
TurtleCrawler

public class TurtleRobot
extends NxtRobot

Implementation of the basic Logo turtle movements.


Field Summary
 
Fields inherited from interface ch.aplu.nxt.SharedConstants
ABOUT, ACCELEROMETERPOLLDELAY, ANGLE, ANGLESTEPSMODE, AXELENGTH, BOOLEANMODE, BOOT, BRAKE, BRAKEDELAY, CELSIUSMODE, CLOSE, COLORPOLLDELAY, COMPASSPOLLDELAY, CRAWLERROTATIONFACTOR, CRAWLERROTATIONSPEED, CRAWLERSPEED, CRAWLERSTEPFACTOR, CUSTOM, DEBUG_LEVEL_HIGH, DEBUG_LEVEL_LOW, DEBUG_LEVEL_MEDIUM, DEBUG_LEVEL_OFF, DEBUGLEVEL, DELETE, DELETE_USER_FLASH, DIRECT_COMMAND_NOREPLY, DIRECT_COMMAND_REPLY, FAHRENHEITMODE, FIND_FIRST, FIND_NEXT, GEARSPEED, GET_BATTERY_LEVEL, GET_CURRENT_PROGRAM_NAME, GET_DEVICE_INFO, GET_FIRMWARE_VERSION, GET_INPUT_VALUES, GET_OUTPUT_STATE, GYROPOLLDELAY, HIGH_SPEED_BUFFER, INFRAREDSEEKERPOLLDELAY, KEEP_ALIVE, LIGHT_ACTIVE, LIGHT_INACTIVE, LIGHTPOLLDELAY, LOWSPEED, LOWSPEED_9V, LS_GET_STATUS, LS_READ, LS_WRITE, MESSAGE_READ, MESSAGE_WRITE, MODEMASK, MOTIONDETECTORPOLLDELAY, MOTOR_RUN_STATE_IDLE, MOTOR_RUN_STATE_RAMPDOWN, MOTOR_RUN_STATE_RAMPUP, MOTOR_RUN_STATE_RUNNING, MOTORON, MOTORSPEED, MOTORSPEEDFACTOR, MOTORSPEEDMULTIPLIER, NO_OF_SENSOR_TYPES, NO_SENSOR, 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, PROTOTYPEPOLLDELAY, RAWMODE, READ, REFLECTION, REGULATED, REGULATION_MODE_IDLE, REGULATION_MODE_MOTOR_SPEED, REGULATION_MODE_MOTOR_SYNC, REPLY_COMMAND, RESET_MOTOR_POSITION, RESET_SCALED_INPUT_VALUE, RFIDPOLLDELAY, SENSOREVENTDELAY, SET_BRICK_NAME, SET_INPUT_MODE, SET_OUTPUT_STATE, SLOPEMASK, SOUND_DB, SOUND_DBA, SOUNDPOLLDELAY, START_PROGRAM, STOP_PROGRAM, STOP_SOUND_PLAYBACK, SWITCH, SYSTEM_COMMAND_NOREPLY, SYSTEM_COMMAND_REPLY, TEMPERATURE, TITLE, TITLEMP, TOUCHPOLLDELAY, TRANSITIONCNTMODE, TURTLEROTATIONFACTOR, TURTLEROTATIONSPEED, TURTLESPEED, TURTLESTEPFACTOR, ULTRASONICPOLLDELAY, VERSION, WRITE
 
Constructor Summary
TurtleRobot()
          Creates a TurtleRobot instance.
TurtleRobot(boolean waitStart)
          Creates TurtleRobot instance and delays execution until the user presses the ENTER button.
 
Method Summary
 TurtleRobot backward(int steps)
          Moves the turtle backward the given number of steps.
 TurtleRobot forward(int steps)
          Moves the turtle forward the given number of steps.
 Gear getGear()
          Returns the gear used as component of the turtle.
 int getTurtleSpeed()
          Returns the current turtle speed.
 TurtleRobot left(int angle)
          Turns the turtle to the left for the given angle.
 TurtleRobot right(int angle)
          Turns the turtle to the right for the given angle.
 TurtleRobot setTurtleSpeed(int speed)
          Sets the turtle speed to the given value.
 
Methods inherited from class ch.aplu.nxt.NxtRobot
addPart, exit, getBatteryLevel, getVersion, playTone
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TurtleRobot

public TurtleRobot(boolean waitStart)
Creates TurtleRobot instance and delays execution until the user presses the ENTER button.

Parameters:
waitStart - if true, the execution is stopped until the ENTER button is hit.

TurtleRobot

public TurtleRobot()
Creates a TurtleRobot instance.

Method Detail

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