public class iRobotCreate extends Agent
RobotSimulator
instead of the real thing. Modifier and Type | Class and Description |
---|---|
(package private) class |
iRobotCreate.CommandQMonitor |
TransientAgent.NewAgentLispCommand
AbstractProcess.Subthread
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
protected long |
angleAcc |
protected boolean |
breathing |
protected boolean |
buttonAdvance |
protected int |
buttonColor |
protected int |
buttonIntensity |
protected boolean |
buttonPlay |
protected byte |
C_ModeOperatingDefault |
(package private) iRobotCreate.CommandQMonitor |
commandQMonitor |
protected long |
distanceAcc |
(package private) InputStream |
inStream
The input stream
|
(package private) String |
inStreamName |
private static CasaLispOperator |
IROBOT__BREATHING |
private static CasaLispOperator |
IROBOT__DEMO
Lisp operator: (iRobot.demo)
Runs the robot's internal demos 0-9. |
private static CasaLispOperator |
IROBOT__DOCK
Lisp operator: (iRobot.dock)
Dock the robot in it's recharger. |
private static CasaLispOperator |
IROBOT__DRIVE
Lisp operator: (iRobot.drive)
Drive the robot at VELOCITY along curve RADIUS. |
private static CasaLispOperator |
IROBOT__EXECUTE
Lisp operator: (iRobot.execute)
Same as execute-raw, but understands prefix 'p' to be a pause in milliseconds. |
private static CasaLispOperator |
IROBOT__EXECUTE_RAW
Lisp operator: (iRobot.execute-raw)
Send bytes to the robot as a command. |
private static CasaLispOperator |
IROBOT__LED
Lisp operator: (iRobot.LED)
Set the LEDs on the robot. |
private static CasaLispOperator |
IROBOT__MODE
Lisp operator: (iRobot.mode)
Change the robot's MODE. |
private static CasaLispOperator |
IROBOT__MOVEBY
Lisp operator: (iRobot.moveby)
move the robot by DISTANCE in mm (-ve is backwards). |
private static CasaLispOperator |
IROBOT__RESET
Lisp operator: (iRobot.reset)
Reset the robot. |
private static CasaLispOperator |
IROBOT__ROTATE_DEG
Lisp operator: (iRobot.rotate-deg)
Rotate the robot by am ANGLE in degrees (-ve is clockwise). |
private static CasaLispOperator |
IROBOT__ROTATE_MM
Lisp operator: (iRobot.rotate-mm)
Rotate the robot by DISTANCE in mm (-ve is clockwise). |
protected long |
lastBreath |
private short[] |
lastReadings |
(package private) OutputStream |
outStream
The output stream
|
(package private) String |
outStreamName |
protected int |
readFailures |
protected boolean |
robotReady
Used to prevent this agent from making status queries to the robot (for example, when
the robot is in one of it's WAIT states and can't respond anyway).
|
(package private) RobotSimulator |
robotSim
The simulated robot, if there is one
|
protected gnu.io.SerialPort |
rxtxPort |
int |
SENSOR_READ_INTERVAL |
int |
SENSOR_READ_WAITTIME |
protected short[] |
sensorCache
updateSensorPackets(byte) writes the status from the robot into this structure, which
can be conveniently accessed later by other methods. |
protected long[] |
sensorCacheLastUpdate |
(package private) SerialIO |
serialInterface
The abstraction of serial I/O
|
(package private) boolean |
shouldStop |
(package private) boolean |
sim
True if this is a simulation
|
protected long |
successfullReads |
(package private) short |
velocity
The desired velocity from the last 137 (Drive) command.
|
protected boolean |
windows |
agentConstructorComplete, properties
cacheKB, CDInvitedTo, CDinvitee, conversationData, defaultOntologyClassName, DEFER_ACTION, DROP_ACTION, kBase, ListOfArgs, ontologyEngineCreateMethod, ontologyEngineLoadMethod, policies, policiesAlwaysApply, policiesLastResort, primaryUI, proxy, UIs, usingProxy
huntForPort, initParams, ontology, ontologyShared, options, securityFilter, trace, TRACE_MONITOR, TRACE_OFF, TRACE_ON, TRACE_TO_FILE, TRACE_UNDEFINED, uniqueThreadName, waitingForAgentToStart
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
iRobotCreate(ParamsMap params,
AgentUI ui)
Typical Agent constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
assertFormula(String sensorName,
long val,
long time) |
protected boolean |
breathing() |
protected void |
checkSensors()
Check to see if bump or overcurrent sensors have been activated
and if so, stop the robot (see
stopMotors() ). |
private void |
closeBTIO() |
static byte[] |
concat(byte[] bytes,
short[] shorts) |
static byte[] |
concat(short[] shorts,
byte[] bytes) |
void |
dock() |
void |
doDemo(byte demoNumber) |
protected void |
doRobotStuff()
If
robotReady is not true,
call updateSensorPackets(byte) with appropriate codes to refresh
sensorCache with the real data from the robot and then call
checkSensors() to let the agent decide on behaviour with the new
data. |
protected void |
drive(short velocity)
Sends the commands to drive the robot straight ahead (see
drive(short, short) ). |
protected void |
drive(short velocity,
short radius)
Drives the robot forward: first changes mode to the SAFE state and
then issues a DRIVE command.
|
protected void |
drive(short velocity,
short radius,
boolean bypassQ)
|
protected void |
drive(short velocity,
short radius,
boolean bypassQ,
boolean flush)
Drives the robot forward: first changes mode to the SAFE state and
then issues a DRIVE command.
|
Status |
executeP(String arg)
Sends commands in arg to the robot.
|
void |
executeRaw(byte... bytes)
Sends argument bytes to the robot.
|
void |
executeRaw(String args)
Sends commands in arg to the robot.
|
protected void |
executeRawBypass(byte... bytes)
Uses
iRobotCreate.CommandQMonitor.bypass(byte...) to bypass the queued order of commands and send
bytes to the robot directly. |
protected void |
executeRawBypassAndFlush(byte... bytes)
Uses
iRobotCreate.CommandQMonitor.bypass(byte...) to bypass the queued order of commands and send
bytes to the robot directly, flushing the queue of all pending commands. |
protected void |
finishRun()
Subclasses may override this method to cleanup after the
message loop exits and the agent is about to terminate.
|
static String |
formatBytes(byte[] arg)
Format arg appropriately for printing.
|
static String |
formatUnsigned(byte arg)
Format arg appropriately for printing.
|
static String |
formatUnsigned(short arg)
Format arg appropriately for printing.
|
Object |
getExtraSensor(int i)
Return the ith element of the extra sensor data to be displayed in
the "iRobot Create" tab (status/sensor table) in the default interface
|
int |
getExtraSensorCount() |
String |
getExtraSensorName(int i)
Return the name of the ith element of the extra sensor data to be displayed in
the "iRobot Create" tab (status/sensor table) in the default interface
|
static byte[] |
getInterpretedBytes(String arg)
Given a string of the form
{ ["s"]d* }* (where d is a digit),
return the byte array where
d* is interpreted as a byte and
sd* is interpreted
as a short to be packed as two sequential bytes (high byte first). |
protected int |
getMode() |
protected int |
getSensorBumps()
Gets the robot's status for it's bump sensors against the (hopefully
recently updated cache (
sensorCache ). |
protected int |
getSensorCliff()
Gets the robot's status for it's 4 cliff sensors against the (hopefully
recently updated cache (
sensorCache ). |
protected int |
getSensorWheelOvercurrent()
Gets the robot's status for it's wheel overcurrent sensors against the (hopefully
recently updated cache (
sensorCache ). |
private static String[] |
getTokens(String arg)
Breaks up arg on the spaces and ensures there are no empty strings
in the resulting String array.
|
protected void |
initializeThread(ParamsMap params,
AgentUI ui)
This method is called when the agent is initialized, but before it really gets going.
|
protected void |
loadScript2RobotAndPlayIt(String script,
long expectedPlayTime) |
static void |
main(String[] args) |
protected TransientAgentInternalFrame |
makeDefaultInternalFrame(TransientAgent agent,
String title,
Container aFrame)
Create the default internal Frame (usually) with tabs for this agent type.
|
static short |
makeShort(byte high,
byte low)
Makes a short out if two bytes.
|
protected long |
moveBy(short mm) |
private void |
openBTIO(ParamsMap params,
AgentUI ui) |
private InputStream |
openInputStream() |
private OutputStream |
openOutputStream() |
protected void |
pendingFinishRun()
This method is called when the agent is about to shut down, so we should shut down
the robot.
|
PerformDescriptor |
perform_setMode(MLMessage message) |
protected int |
readSensor(byte code,
byte[] buf)
Send the sensors request to the robot and read back the result.
|
protected int |
readSensorList(byte[] codes,
byte[] buf)
Send the QueryList request to the robot and read back the result.
|
long |
resetAngleAcc() |
long |
resetDistanceAcc() |
void |
resetRobot() |
protected long |
rotate(short mm) |
protected long |
rotateAngle(short degrees) |
protected long |
rotateAngle(short degrees,
int velocity) |
protected void |
setMode(byte mode) |
byte[] |
shortsToBytes(short[] shorts)
Send argumtns shorts to the robot by breaking it up into bytes and sending them.
|
protected void |
startupActions()
Reset (or set up) the Create robot (whether its the real thing or a simulation) by
send START, putting it in SAFE mode, playing a song and doing a little light show.
|
void |
stopMotors()
Stops the motors on the robot immediately, and flushes any commands waiting in the command queue
|
protected void |
updateKB() |
protected void |
updateSensorPacketList(byte... codes)
Given the argument
codes , reads the appropriate coded sensor datum
from the robot and place the output in sensorCache as shorts (even though some
of the data is only bytes) in the appropriate place in the sensorCache array. |
protected void |
updateSensorPackets(byte code)
Given the argument
code , reads the appropriate coded sensor datum or data group
from the robot and place the output in sensorCache as shorts (even though some
of the data is only bytes) in the appropriate place in the sensorCache array. |
protected void |
writeRobotStream(byte... bytes) |
destroyDataObject, finalize, getAgentOptions, getBooleanProperty, getCASAFilename, getCreateDate, getDataObject, getDataObjectInputStream, getDataObjectOutputStream, getDoubleProperty, getFloatProperty, getIntegerProperty, getLongProperty, getOptions, getStringProperty, hasProperty, initializeAfterRegistered, isPersistent, makeDefaultGUI, makeOptions, putDataObject, putDataObject, readPersistent, ready, realizeAgentBehaviourFromOptions, removeProperty, setBooleanProperty, setDoubleProperty, setFloatProperty, setIntegerProperty, setLongProperty, setOptions, setPersistent, setStringProperty, updateOptions, writePersistent
abclEval, abclEval, abclEval, accept_deleteCD, accept_exit, accept_forward_message, accept_LAC_closing, accept_new_MenuItem, accept_update, acceptDefault, addConversation, addJoinedCooperationDomain, addMembers, addSubscribeEvents, assembleDefault, assert_, assert_, authorizedByProxy, authorizeMessage, chooseSC, concludeDefault, consider_execute, consider_invite_to_cd, consider_new_MenuItem, consider_ping, consider_query_if, consider_query_ref, considerDefault, createCasaLispOperators, dispatchMsgHandlerMethod, doAddObserver, doAdvertise, doCDGetHistory_sync, doCDGetMembers, doCDPutData, doCDSubscribeMembership, doFindInstances_sync, doGetCooperationDomains, doGetOnology, doInviteToCD, doJoinCD, doPing_sync, doPing, doRegisterAgentInstance, doRegisterAgentInstance, doResolveURL, doSearchYP, doUnadvertise, doUnregisterAgentInstance, doUnregisterAgentType, doWithdrawCD, evaluateDefault, evesdrop, executeCommand, findFileResourcePath, findFileResourcePath, getAgentForThread, getAlwaysApplyPolicies, getBanner, getCachedKnowledgeBase, getChosenCommitment, getCommitmentProcessor, getConversation, getConversations, getConversationsReport, getDefaultBanner, getDefFileSystemLocations, getEventForThread, getField, getInstancesFound, getJoinedCooperationDomain, getJoinedCooperationDomains, getKnowledgeBase, getLACURL, getLastResortPolicies, getMembers, getMsgForThread, getObjectsForThread, getOntology, getOntologyEngine, getOntologyFileSuffix, getPolicies, getPrimaryUI, getProxy, getSCStore, getSerializedOntology, getStrategy, getStrategyGUI, getSubscribeEvents, getSubscribeEvents, getTermsFromContent, getUI, getUIForThread, getUIs, getUnfulfilledSocialCommitments, getUnfulfilledSocialCommitments, handleErrorReplies, handleEvent, handleLACClosing, hasActiveCommitments, hasConversation, hasStrategyGUI, initializePolicies, initJADE, initUI, isEventQueueReady, isRegistered, isRegisteredWithLAC, isStoppable, isTrusted, isTrusted, isUsingProxy, kb_get_value, makeDefaultInterface, makeDefaultTextInterface, monitorDefault, notifySendingMessage, optionsToString, parseJADENode, pendingFinishRun_unregisterAgentInstance, pendingFinishRun_withdrawFromAllCDs, perform_execute, perform_FIPAStyle, perform_get_name, perform_get_ontology, perform_invite_to_cd, perform_method_call, perform_query_if, perform_query_if, perform_query_ref, perform_query_ref, performDefault, processCommitment, processCommitments, processObserverNotification, putExtendedOntology, putPolicy, putPolicyAlwaysApply, putPolicyLastResort, putReplacementOntology, putUI, query_ref, query_toString, query, queryIf, queryRef_toIntegerList, queryRef_toString, queryRef_toStringList, queryRef_toTermList, queryRef, queryRef, queryRefAIDs, queryRefURLs, querywithFilter, recursiveParent, recursivePermutations, release_execute, release_FIPAStyle, release_get_agents_registered, release_get_agents_running, release_get_members, release_get_ontology, release_join_cd, release_ping, release_query_if, release_query_ref, release_resolve_url, release_unregister_agentType, release_unregister_instance, release_withdraw_cd, releaseDefault, removeConversation, removeCooperationDomains, removeJoinedCooperationDomain, removeSubscribeEvents, requestInstances, resolveConnectException, retrieveReturnedData, saveReturnedData, searchOntology, searchOntology1, setBanner, setCommitmentProcessor, setField, setInstancesFound, setOntology, shouldDoExecuteRequest, template_handleNewOntologyInfo, update, updateConversationProtocolType, verifyCD, verifyDefault, verifyMessage
addObserver, addObserver, addObserver, addObserver, addTraceTags, addTransformation, bump, clearAllTraceTags, closePort, compareTo, countObservers, defer, defer, deleteObserver, deleteObserver, deleteObservers, dequeueEvent, equals, eventBufferLoopBody, eventBufferLoopPeriodic, eventQueuePeek, existed, exit, fixupMessage, getAgent, getAgentName, getEventQueue, getInitParams, getNewMessage, getNewMessage, getPort, getSocketServer, getTrace, getTraceTags, getTransformationFor, getUniqueRequestID, getURL, getUseAckProtocol, getUsePriority, hasChanged, hasOpenPort, in, initializeConstructor, initializeURL, isA, isA, isA, isA, isAAct, isAAct, isAgentThread, isAPerformative, isAPerformative, isExiting, isInitialized, isLoggingTag, isObserveMessages, isPaused, isThisMyAddress, isTracing, loadClass, makeSubthread, makeSubthread, makeTraceParam, notifyObservers, notifyObservers, notifyObserversWithNoArg, notifyObserversWithTop, out, println, println, println, println, println, queueEvent, queueEventIf, removeTraceTags, resetRuntimeOptionsFromCommandLine, resetSecurityPackage, resetTraceOptions, revTransform, revTransform, run, sendMessage, sendMessage, sendMessageAndWait, sendQueryAndWait, sendRequestAndWait, sendRequestAndWait, setAllTraceTags, setObserveMessages, setPause, setTraceTags, setTracing, setURL, setUseAckProtocol, setUsePriority, startSocketServer, startTraceMonitor, step, transform, transform, unhandledMessage
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
getClass, hashCode, notify, notifyAll, wait, wait, wait
doAdvertise, doCDGetHistory_sync, doCDGetMembers, doCDPutData, doFindInstances_sync, doGetCooperationDomains, doGetOnology, doInviteToCD, doJoinCD, doPing_sync, doPing, doRegisterAgentInstance, doRegisterAgentInstance, doSearchYP, doUnadvertise, doUnregisterAgentInstance, doUnregisterAgentType, doWithdrawCD, executeCommand, getInstancesFound, getJoinedCooperationDomains, getLACURL, getMembers, getOntology, getSerializedOntology, getStrategyGUI, hasStrategyGUI, isAAct, isInitialized, isRegistered, makeDefaultInterface, putExtendedOntology, putReplacementOntology, putUI, release_get_ontology, removeCooperationDomains, requestInstances
addObserver, addObserver, closePort, deleteObserver, deleteObserver, exit, getAgentName, getName, getNewMessage, getPort, getStrategy, getTrace, getUniqueRequestID, getURL, getUseAckProtocol, hasOpenPort, isA, isAPerformative, isExiting, isLoggingTag, isStoppable, isTracing, println, println, println, sendMessage, setTracing, setUseAckProtocol, startTraceMonitor
addObserver, addObserver, countObservers, deleteObservers, hasChanged, notifyObservers, notifyObservers, notifyObserversWithNoArg, notifyObserversWithTop
abclEval, abclEval, abclEval, addTransformation, bump, chooseSC, defer, dequeueEvent, dispatchMsgHandlerMethod, evesdrop, getKnowledgeBase, getName, getSCStore, getSubscribeEvents, getTransformationFor, getUniqueRequestID, getURL, getUseAckProtocol, isA, isA, isA, isA, isAPerformative, isAPerformative, isLoggingTag, notifyObservers, println, println, println, queueEvent, queueEventIf, revTransform, revTransform, sendMessage, transform, transform
public int SENSOR_READ_INTERVAL
public int SENSOR_READ_WAITTIME
protected byte C_ModeOperatingDefault
SerialIO serialInterface
RobotSimulator robotSim
OutputStream outStream
String outStreamName
InputStream inStream
String inStreamName
boolean sim
short velocity
protected gnu.io.SerialPort rxtxPort
protected boolean windows
protected boolean robotReady
boolean shouldStop
protected short[] sensorCache
updateSensorPackets(byte)
writes the status from the robot into this structure, which
can be conveniently accessed later by other methods.protected long[] sensorCacheLastUpdate
protected long distanceAcc
protected long angleAcc
protected int readFailures
protected long successfullReads
private short[] lastReadings
private static final CasaLispOperator IROBOT__EXECUTE_RAW
private static final CasaLispOperator IROBOT__EXECUTE
private static final CasaLispOperator IROBOT__RESET
private static final CasaLispOperator IROBOT__DEMO
private static final CasaLispOperator IROBOT__DOCK
private static final CasaLispOperator IROBOT__ROTATE_MM
private static final CasaLispOperator IROBOT__ROTATE_DEG
private static final CasaLispOperator IROBOT__MOVEBY
private static final CasaLispOperator IROBOT__DRIVE
protected int buttonColor
protected int buttonIntensity
protected boolean buttonPlay
protected boolean buttonAdvance
private static final CasaLispOperator IROBOT__LED
private static final CasaLispOperator IROBOT__BREATHING
protected long lastBreath
protected boolean breathing
iRobotCreate.CommandQMonitor commandQMonitor
private static final CasaLispOperator IROBOT__MODE
public iRobotCreate(ParamsMap params, AgentUI ui) throws Exception
Qualifiers
has extensions:
CommandLine2 | |
---|---|
input | Specifies the input file name (may be a device spec) |
output | Specifies the output file name (may be a device spec) |
sim | U specifies not to use the simulator; sim may be set to "true" or "false" |
x | Specifies the initial x coordinate of the robot (simulation only). If there is some other object at this coordinate, the robot will be randomly placed anyway. |
y | Specifies the initial y coordinate of the robot (simulation only). If there is some other object at this coordinate, the robot will be randomly placed anyway. |
angle | Specifies the initial angle of the robot (simulation only) |
RobotSimulator
instead of the real thing unless sim is not set to true (sim) has not affect
if input and output are the same). If input and
output are the same, it should be serial device file description
connected to a real robot.IPSocketException
- if we can't get an IPSocketFileNotFoundException
- if we can't open the files specified by the I and O command line argumentsInstantiationException
Exception
private InputStream openInputStream() throws Exception
FileNotFoundException
Exception
private OutputStream openOutputStream() throws Exception
FileNotFoundException
Exception
protected void initializeThread(ParamsMap params, AgentUI ui)
startupActions()
and set {link robotReady
to true.initializeThread
in class TransientAgent
casa.Agent#init()
public int getExtraSensorCount()
public Object getExtraSensor(int i)
i
- the index of the sensor information to be displayedpublic String getExtraSensorName(int i)
i
- the index of the sensor information name to be displayedprotected void startupActions()
protected void pendingFinishRun()
pendingFinishRun
in class Agent
Agent.pendingFinishRun()
private void closeBTIO()
protected void doRobotStuff()
robotReady
is not true,
call updateSensorPackets(byte)
with appropriate codes to refresh
sensorCache
with the real data from the robot and then call
checkSensors()
to let the agent decide on behaviour with the new
data. Also, always check readFailures
: if it's greater than 10, reset
the robot (resetRobot()
).protected void checkSensors()
stopMotors()
). Subclasses
should override to proved more interesting behaviour.protected int getSensorBumps()
sensorCache
). The integer
return will be in the range 0-3:
protected int getSensorWheelOvercurrent()
sensorCache
). The integer
return will be in the range 0, 8, 16 or 24 (bits 3 and 4 set):
protected int getSensorCliff()
sensorCache
). The integer
return will be in the range have the lower four bits set or clear (and
the rest clear):
public void stopMotors()
public void doDemo(byte demoNumber)
public void dock()
protected void drive(short velocity, short radius)
iRobotCommands.P_Straight
and iRobotCommands.P_Straight2
)
iRobotCommands.P_TurnInPlaceClockwise
)
iRobotCommands.P_TurnInPlaceCounterClockwise
)
velocity
- The velocity to drive forward (-500 to +500) in mm/sec.radius
- The radius to drive in (-2000 to +2000) in mm.protected void drive(short velocity, short radius, boolean bypassQ)
velocity
- The velocity to drive forward (-500 to +500) in mm/sec.radius
- The radius to drive in (-2000 to +2000) in mm.bypassQ
- bypasses the command queue to execute this command immediatelyprotected void drive(short velocity, short radius, boolean bypassQ, boolean flush)
iRobotCommands.P_Straight
and iRobotCommands.P_Straight2
)
iRobotCommands.P_TurnInPlaceClockwise
)
iRobotCommands.P_TurnInPlaceCounterClockwise
)
velocity
- The velocity to drive forward (-500 to +500) in mm/sec.radius
- The radius to drive in (-2000 to +2000) in mm.bypassQ
- bypasses the command queue to execute this command immediatelyflush
- flushes the command queue before executing this commandprotected void drive(short velocity)
drive(short, short)
).velocity
- The velocity to drive forward (-500 to +500) in mm/sec.protected void updateSensorPackets(byte code)
code
, reads the appropriate coded sensor datum or data group
from the robot and place the output in sensorCache
as shorts (even though some
of the data is only bytes) in the appropriate place in the sensorCache
array. (Note
that since codes 0-6 are group codes, index 0-6 of sensorCache
will always be 0.)code
- The code (single or group code) of the sensor packet to request from the robot.protected void updateKB()
private void assertFormula(String sensorName, long val, long time)
protected void updateSensorPacketList(byte... codes)
codes
, reads the appropriate coded sensor datum
from the robot and place the output in sensorCache
as shorts (even though some
of the data is only bytes) in the appropriate place in the sensorCache
array. (Note
that since codes 0-6 are group codes, index 0-6 of sensorCache
will always be 0.)codes
- The list of the sensor packet codes to request from the robot.public long resetDistanceAcc()
public long resetAngleAcc()
protected int readSensor(byte code, byte[] buf)
code
- The sensor (individual or group) to command to send to the sensorbuf
- The byte buffer to read the result back; this buffer should be EXACTLY the length of the reply to code (see iRobotCommands.BytesPerPacket
).protected int readSensorList(byte[] codes, byte[] buf)
codes
- The list of sensors that we want to readbuf
- The byte buffer to read the result back; this buffer should be EXACTLY the length of the reply to code (see iRobotCommands.BytesPerPacket
).public void resetRobot()
public Status executeP(String arg)
arg
- a string to interpret and sendpublic void executeRaw(String args)
args
- a string to interpret and sendprotected boolean breathing()
public void executeRaw(byte... bytes)
bytes
- the bytes to send to the robotprotected void executeRawBypass(byte... bytes)
iRobotCreate.CommandQMonitor.bypass(byte...)
to bypass the queued order of commands and send
bytes to the robot directly.bytes
- protected void executeRawBypassAndFlush(byte... bytes)
iRobotCreate.CommandQMonitor.bypass(byte...)
to bypass the queued order of commands and send
bytes to the robot directly, flushing the queue of all pending commands.bytes
- public byte[] shortsToBytes(short[] shorts)
shorts
- the shorts (16 bit) to send to the robotpublic static byte[] concat(byte[] bytes, short[] shorts)
bytes
- shorts
- public static byte[] concat(short[] shorts, byte[] bytes)
shorts
- bytes
- protected void loadScript2RobotAndPlayIt(String script, long expectedPlayTime) throws ParseException
script
- the script to be interpreted according to getInterpretedBytes(String)
expectedPlayTime
- The expected play time of the scriptParseException
- if the script is malformed#loadScript2Robot(String)
,
#playScript(long)
public static String formatBytes(byte[] arg)
arg
- the bytes to printpublic static String formatUnsigned(byte arg)
arg
- the byte to printpublic static String formatUnsigned(short arg)
arg
- the byte to printpublic static short makeShort(byte high, byte low)
high
- the byte to be used as the high byte of the shortlow
- the byte to be used as the low byte of the shortpublic static byte[] getInterpretedBytes(String arg) throws ParseException
{ ["s"]d* }*(where d is a digit), return the byte array where
d*
is interpreted as a byte and
sd*
is interpreted
as a short to be packed as two sequential bytes (high byte first). For example,
"134 s256" would be translated to the byte array {134, 1, 0}arg
- the bytes in text formParseException
- if the argument in malformedprotected long rotate(short mm)
protected long rotateAngle(short degrees)
protected long rotateAngle(short degrees, int velocity)
protected long moveBy(short mm)
private static String[] getTokens(String arg)
arg
- the String to break upprotected TransientAgentInternalFrame makeDefaultInternalFrame(TransientAgent agent, String title, Container aFrame)
makeDefaultInternalFrame
in class Agent
agent
- the owner agenttitle
- the title of the windowaFrame
- the owner frame in which this window is to be embeddedprotected int getMode()
protected void setMode(byte mode)
public PerformDescriptor perform_setMode(MLMessage message)
public static void main(String[] args)
protected void finishRun()
AbstractProcess
notifyObservers(state.STATE_EXITED)
.finishRun
in class AbstractProcess