ch.aplu.nxt
Class NxtRobot

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

public class NxtRobot
extends java.lang.Object
implements SharedConstants

Class that represents a NXT robot brick. Parts (e.g. motors, sensors) may be assembled into the robot to make it doing the desired job.


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
NxtRobot()
          Creates an instance of NxtRobot continues execution normally.
NxtRobot(boolean waitStart)
          Creates an instance of NxtRobot and and delays execution until the user presses the ENTER button.
 
Method Summary
 void addPart(Part part)
          Assembles the given part into the robot.
 void exit()
          Calls cleanup() of all sensors, stops any running motor and terminates the running program.
 double getBatteryLevel()
          Returns the battery level.
static java.lang.String getVersion()
          Returns library version information.
 void playTone(int frequency, int duration)
          Plays a tone of given frequency (in Hz) for the given duration (in ms).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NxtRobot

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

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

NxtRobot

public NxtRobot()
Creates an instance of NxtRobot continues execution normally.

Method Detail

addPart

public void addPart(Part part)
Assembles the given part into the robot. If already connected, initialize the part.

Parameters:
part - the part to assemble

getBatteryLevel

public double getBatteryLevel()
Returns the battery level.

Returns:
voltage (in Volt)

getVersion

public static java.lang.String getVersion()
Returns library version information.

Returns:
library version

exit

public void exit()
Calls cleanup() of all sensors, stops any running motor and terminates the running program.


playTone

public void playTone(int frequency,
                     int duration)
Plays a tone of given frequency (in Hz) for the given duration (in ms). The method returns immediately. In order to play a melody, the program should be delayed (using Tools.delay()) for an appropriate duration.

Parameters:
frequency - the frequency in Hertz
duration - the duration in milliseconds