|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectohmm.OHMM
public class OHMM
OHMM host library.
An instance of this class encapsulates communication with the OHMM monitor firmware.
Several constructors are provided to allow the actual communication link to be implemented in different ways:
listPorts(java.io.PrintStream)
may be invoked to get a list of the port names that
the RXTX library believes to be available.
The core API maps to the functionality of the firmware monitor. For
example, lcdMsg(java.lang.String)
maps to the firmware monitor command msg.
Delays are added to no-response commands to throttle the maximum command
rate.
You can use this either as a subsystem within a larger Java system, or
you can use OHMMShell
as an interactive or scheme-scripted
interface to the hardware.
Bulk-receive methods such as allState(ohmm.OHMM.AllState)
are provided, and their
use is encouraged for repetitive polling, as they are significantly more
efficient than multiple lower-level calls. This is due not only to reduced
host-to-firmware protocol overhead but also to a reduction in the number of
host-to-firmware stream flushes that are required to complete the
transaction. Such flushes can be relatively expensive on some host
platforms.
Communication errors including timeouts are internally detected, and the
ErrorHandler
, if any, is notified.
The lower level send(...)
and recv*()
methods to send and
receive specific datatypes to the firmware are exposed for use if the
firmware is extended and for debugging.
ErrorHandler
, e.g.
ErrorHander h = new DefaultErrorHandler();
If you require special error handling one option is to subclass DefaultErrorHandler
. Convenience constructors such as OHMM(String)
are also provided that internally instantiate DefaultErrorHandler
.OHMM a = new OHMM(h, rxtxPortName);
where rxtxPortName
is the platform-dependent name of the virtual
serial port associated with the OHMM USB serial port. For example, on Linux,
this will be a string like /dev/ttyACM1.lcdMsg(java.lang.String)
to invoke monitor commands.close()
before application exit.
Nested Class Summary | |
---|---|
class |
OHMM.AllState
state data structure for allState(ohmm.OHMM.AllState) |
static class |
OHMM.AnalogChannel
Analog sensor channels. |
class |
OHMM.ArmState
state data structure for armState(ohmm.OHMM.ArmState) |
static class |
OHMM.AXReg
|
class |
OHMM.AXState
state data structure for axState(ohmm.OHMM.AXState) |
class |
OHMM.BatState
state data structure for batState(ohmm.OHMM.BatState) |
static class |
OHMM.DigitalPin
Digital sensor pins. |
class |
OHMM.DriveState
state data structure for driveState(ohmm.OHMM.DriveState) |
class |
OHMM.MotState
state data structure for motState(ohmm.OHMM.MotState) |
class |
OHMM.OHMMState
state data structure for ohmmState(ohmm.OHMM.OHMMState) |
class |
OHMM.SenseState
state data structure for senseState(ohmm.OHMM.SenseState) |
class |
OHMM.TaskState
state data structure for taskState(ohmm.OHMM.TaskState) |
Field Summary | |
---|---|
static int |
ARM_ACTIVE
status flag for status(int[]) |
static int |
ARM_AT_GOAL
status flag for status(int[]) |
static int |
ARM_ELBOW
Arm joint indices. |
static int |
ARM_ERR_AX
status flag for status(int[]) |
static int |
ARM_GRIPPER
Arm joint indices. |
static int |
ARM_SHOULDER
Arm joint indices. |
static int |
ARM_WRIST
Arm joint indices. |
protected double |
avgRecvWait
Avg time spent waiting to receive a single byte, in seconds. |
protected double |
avgSendWait
Avg time spent waiting to send a single byte, in seconds. |
static int |
AX_ERR_ANGLE_LIMIT
AX12 error flags |
static int |
AX_ERR_CHECKSUM
AX12 error flags |
static int |
AX_ERR_INSTRUCTION
AX12 error flags |
static int |
AX_ERR_OVERHEATING
AX12 error flags |
static int |
AX_ERR_OVERLOAD
AX12 error flags |
static int |
AX_ERR_RANGE
AX12 error flags |
static int |
AX_ERR_TIMEOUT
AX12 error flags |
static int |
AX_ERR_TRANSACTION
Bitmask of AX12 error flags which indicate a failed transaction. |
static int |
AX_ERR_VOLTAGE
AX12 error flags |
static int |
AX_ID_BCAST
AX12 broadcast ID. |
protected int |
bytesReceived
Total number of bytes received. |
protected int |
bytesSent
Total number of bytes sent. |
static int |
CMD_NAME_MAX
Max command name length. |
protected java.util.Map<java.lang.String,java.lang.Integer> |
codes
Command code cache. |
protected double |
commandDelay
Time to wait after a no-response command, in seconds. |
protected boolean |
debug
Whether to enable debug messages. |
static double |
DEF_COMMAND_DELAY
Default time to wait after a no-response command, in seconds. |
static double |
DEF_PROCESS_INIT_WAIT
Default time in seconds to wait for a com process to init. |
static double |
DEF_RECV_POLL_TIME
Default time to wait between checks for an available byte, in seconds. |
static double |
DEF_TIMEOUT_FILE
Default time to wait for a response from the firmware, in seconds, when using the file backend. |
static double |
DEF_TIMEOUT_PROXY
Default time to wait for a response from the firmware, in seconds, when using the command proxy. |
static double |
DEF_TIMEOUT_RXTX
Default time to wait for a response from the firmware, in seconds, when using the RXTX backend. |
static java.text.DecimalFormat |
DF2
For formatting with 2 decimal paces. |
static java.text.DecimalFormat |
DF4
For formatting with 4 decimal paces. |
static int |
DRIVE_CFG_INDEX_B
float index for driveGetCfg(float[]) |
static int |
DRIVE_CFG_INDEX_MA
float index for driveGetCfg(float[]) |
static int |
DRIVE_CFG_INDEX_MS
float index for driveGetCfg(float[]) |
static int |
DRIVE_CFG_INDEX_R
float index for driveGetCfg(float[]) |
static int |
DRIVE_CFG_INDEX_TOL
float index for driveGetCfg(float[]) |
static int |
DRIVE_CFG_LEN
max cfg floats for driveGetCfg(float[]) |
static int |
DRIVE_ERR_ODOM
status flag for status(int[]) |
static int |
DRIVE_ERR_TIMEOUT
status flag for status(int[]) |
protected ErrorHandler |
errorHandler
The currently installed error handler. |
protected byte[] |
flushBuf
Buffer where outgoing bytes are stored until they need to be flushed. |
protected int |
flushNext
Next unused byte in flushBuf . |
static int |
HOST_ERR_RECV
status flag for status(int[]) |
static int |
HOST_ERR_SEND
status flag for status(int[]) |
static double |
INIT_DELAY
Default time to wait during the init() delays, in seconds. |
static int |
INITIAL_FLUSH_BUF_LEN
Initial length of flushBuf . |
protected java.io.InputStream |
istream
Input stream from firmware. |
static int |
LCD_WIDTH
LCD width. |
static int |
LEFT
drive motor indices |
protected double |
maxRecvWait
Max time spent waiting to receive a single byte, in seconds. |
protected double |
maxSendWait
Max time spent waiting to send a single byte, in seconds. |
protected double |
minRecvWait
Min time spent waiting to receive a single byte, in seconds. |
protected double |
minSendWait
Min time spent waiting to send a single byte, in seconds. |
static int |
MOT_ERR_ENC_L
status flag for status(int[]) |
static int |
MOT_ERR_ENC_R
status flag for status(int[]) |
static int |
MOT_ERR_VEL_L
status flag for status(int[]) |
static int |
MOT_ERR_VEL_R
status flag for status(int[]) |
static int |
NUM_INIT_ZEROS
Number of zeros to send the firmware on init. |
protected int |
numTimeouts
Total number of timeouts. |
protected java.io.OutputStream |
ostream
Output stream to firmware. |
static int |
PID_FPF
Monitor fixed point PID implementation fraction bits. |
protected double |
recvPollTime
Time to wait between checks for an available byte, in seconds. |
protected boolean |
recvTimedOut
Whether the last recvByte(boolean) timed out. |
static int |
RIGHT
drive motor indices |
static int |
RXTX_BAUDRATE
Serial baudrate for RXTX. |
static int |
RXTX_OPEN_TIMEOUT_MS
Timeout in ms to wait to open a port with RXTX. |
static java.lang.String |
RXTX_PORT_OWNER_NAME
RXTX Port owner name. |
protected gnu.io.SerialPort |
rxtxSerialPort
RXTX serial port or null if not using RXTX. |
static int |
SCAL_N
LUT size for senseConfigAnalogLUT(int, int, int[], float[]) |
static int |
STATUS_INDEX_ARM
status index for status(int[]) |
static int |
STATUS_INDEX_BAT
status index for status(int[]) |
static int |
STATUS_INDEX_DRIVE
status index for status(int[]) |
static int |
STATUS_INDEX_HOST
status index for status(int[]) |
static int |
STATUS_INDEX_MOT
status index for status(int[]) |
static int |
STATUS_INDEX_TASK
status index for status(int[]) |
static int |
STATUS_LEN
max status bytes for status(int[]) |
private static java.lang.String |
svnid
|
static int |
TASK_ERR_COLLISION
status flag for status(int[]) |
static int |
TASK_ERR_MEM
status flag for status(int[]) |
protected double |
timeout
Time to wait for a response from the firmware, in seconds. |
protected double |
totalRecvWait
Total time spent waiting to receive bytes, in seconds. |
protected double |
totalSendWait
Total time spent waiting to send bytes, in seconds. |
static java.lang.String |
USAGE
makeOHMM(java.lang.String[]) Usage message. |
static Version |
VERSION
Version info for the host library. |
Constructor Summary | |
---|---|
OHMM(double initWait,
java.lang.String... cmdLine)
Covers OHMM(ErrorHandler, double, String...) with a new
DefaultErrorHandler . |
|
OHMM(ErrorHandler errorHandler,
double initWait,
java.lang.String... cmdLine)
Talk to the hardware via the specified process. |
|
OHMM(ErrorHandler errorHandler,
java.io.File port)
Talk to the hardware on the specified serial port, accessed as a file. |
|
OHMM(ErrorHandler errorHandler,
java.lang.String... cmdLine)
Covers OHMM(ErrorHandler, double, String...) with DEF_PROCESS_INIT_WAIT . |
|
OHMM(ErrorHandler errorHandler,
java.lang.String portName)
Similar to OHMM(ErrorHandler, File) , but uses RXTX library to
access the serial port. |
|
OHMM(java.io.File port)
Covers OHMM(ErrorHandler, File) with a new DefaultErrorHandler . |
|
OHMM(java.lang.String... cmdLine)
Covers OHMM(ErrorHandler, double, String...) with a new
DefaultErrorHandler and DEF_PROCESS_INIT_WAIT . |
|
OHMM(java.lang.String portName)
Covers OHMM(ErrorHandler, String) with a new DefaultErrorHandler . |
Method Summary | |
---|---|
OHMM.AllState |
allState()
covers allState(AllState) , always conses |
OHMM.AllState |
allState(OHMM.AllState state)
Runs monitor command "allst". |
boolean |
armActive()
Runs monitor command "aa". |
boolean |
armAtGoal()
Runs monitor command "aag". |
void |
armCal()
Runs monitor command "ac". |
void |
armEnable(boolean enable)
Runs monitor command "ae". |
int[] |
armGetAllCal()
Covers armGetAllCal(int[]) , always conses. |
int[] |
armGetAllCal(int[] offset)
Runs monitor command "agac". |
int[] |
armGetAllJoints()
Covers armGetAllJoints(int[]) , always conses. |
int[] |
armGetAllJoints(int[] counts)
Runs monitor command "agaj". |
float[] |
armGetAllJointsDeg()
Covers armGetAllJointsDeg(float[]) , always conses. |
float[] |
armGetAllJointsDeg(float[] angle)
Runs monitor command "agajd". |
float[] |
armGetAllJointsRad()
Covers armGetAllJointsRad(float[]) , always conses. |
float[] |
armGetAllJointsRad(float[] angle)
Runs monitor command "agajr". |
int |
armGetCal(int joint)
Runs monitor command "agc". |
float |
armGetGripper()
Runs monitor command "agg". |
int |
armGetJoint(int joint)
Runs monitor command "agj". |
float |
armGetJointDeg(int joint)
Runs monitor command "agjd". |
float |
armGetJointRad(int joint)
Runs monitor command "agjr". |
int[] |
armGetLoads()
Covers armGetLoads(int[]) , always conses. |
int[] |
armGetLoads(int[] load)
Runs monitor command "agl". |
int |
armGetNumAXErrors()
Runs monitor command "agne". |
int[] |
armGetTemps()
Covers armGetTemps(int[]) , always conses. |
int[] |
armGetTemps(int[] temp)
Runs monitor command "agt". |
void |
armHold(boolean hold)
Runs monitor command "ahld". |
void |
armHome()
Runs monitor command "ah". |
void |
armReinit()
Runs monitor command "ari". |
boolean |
armSetAllCal(int... offset)
Runs monitor command "asac". |
boolean |
armSetAllJoints(int... counts)
Runs monitor command "asaj". |
boolean |
armSetAllJointsDeg(float... angle)
Runs monitor command "asajd". |
boolean |
armSetAllJointsRad(float... angle)
Runs monitor command "asajd". |
boolean |
armSetCal(int joint,
int offset)
Runs monitor command "asc". |
boolean |
armSetGripper(float state)
Runs monitor command "asg". |
boolean |
armSetJoint(int joint,
int counts)
Runs monitor command "asj". |
boolean |
armSetJointDeg(int joint,
float angle)
Runs monitor command "asjd". |
boolean |
armSetJointRad(int joint,
float angle)
Runs monitor command "asjr". |
OHMM.ArmState |
armState()
covers armState(ArmState) , always conses |
OHMM.ArmState |
armState(OHMM.ArmState state)
Runs monitor command "armst". |
int |
axAction(int id)
Runs the monitor command "axact". |
static java.lang.String |
axErrToString(int err)
Convert an AX12 error code to a human readable string. |
void |
axESTOP()
Runs monitor command "axestop". |
int |
axGetLoad(int id)
Runs monitor command "axgl". |
int |
axGetNumOverflows()
Runs monitor command "axgno". |
int |
axGetNumRetries()
Runs monitor command "axgnr". |
int |
axGetNumTimeouts()
Runs monitor command "axgnt". |
int |
axGetPos(int id)
Runs monitor command "axgp". |
float |
axGetPosDeg(int id)
Runs monitor command "axgpd". |
float |
axGetPosRad(int id)
Runs monitor command "axgpr". |
int |
axGetTemp(int id)
Runs monitor command "axgt". |
float |
axGetVolts(int id)
Runs monitor command "axgv". |
int |
axPing(int id)
Runs the monitor command "axpng". |
int |
axRead(int id,
int reg)
Runs the monitor command "axrd". |
int |
axRead(int id,
OHMM.AXReg reg)
Like axRead(int, int) but takes an OHMM.AXReg . |
int |
axRead16(int id,
int reg)
Runs the monitor command "axrd16". |
int |
axRead16(int id,
OHMM.AXReg reg)
Like axRead16(int, int) but takes an OHMM.AXReg . |
int |
axRegSetGoal(int id,
int goal)
Like axSetGoal(int, int) but does a reg write. |
int |
axRegSetGoalDeg(int id,
float goal)
like axRegSetGoal(int, int) but in degrees |
int |
axRegSetGoalRad(int id,
float goal)
like axRegSetGoal(int, int) but in radians |
int |
axRegWrite(int id,
int reg,
int val)
Runs the monitor command "axrwr". |
int |
axRegWrite(int id,
OHMM.AXReg reg,
int val)
Like axRegWrite(int, int, int) but takes an OHMM.AXReg . |
int |
axRegWrite11(int id,
int reg,
int val)
Runs monitor command "axrwr11". |
int |
axRegWrite11(int id,
OHMM.AXReg reg,
int val)
Like axRegWrite11(int, int, int) but takes an OHMM.AXReg . |
void |
axReinit()
Runs the monitor command "axri". |
int |
axSetAngleLimits(int id,
int cwLimit,
int ccwLimit)
Runs monitor command "axsal". |
int |
axSetGoal(int id,
int goal)
Runs monitor command "axsg". |
int |
axSetGoalDeg(int id,
float goal)
like axSetGoal(int, int) but in degrees |
protected int |
axSetGoalImpl(java.lang.String cmd,
int id,
float goal)
comon impl of set goal (float) methods |
protected int |
axSetGoalImpl(java.lang.String cmd,
int id,
int goal)
comon impl of set goal (int) methods |
int |
axSetGoalRad(int id,
float goal)
like axSetGoal(int, int) but in radians |
OHMM.AXState |
axState()
covers axState(AXState) , always conses |
OHMM.AXState |
axState(OHMM.AXState state)
Runs monitor command "axst". |
int |
axTorqueEnable(int id,
boolean enable)
Runs monitor command "axte". |
int |
axWrite(int id,
int reg,
int val)
Runs monitor command "axwr". |
int |
axWrite(int id,
OHMM.AXReg reg,
int val)
Like axWrite(int, int, int) but takes an OHMM.AXReg . |
int |
axWrite11(int id,
int reg,
int val)
Runs monitor command "axwr11". |
int |
axWrite11(int id,
OHMM.AXReg reg,
int val)
Like axWrite11(int, int, int) but takes an OHMM.AXReg . |
protected int |
axWriteImpl(java.lang.String cmd,
int id,
int reg,
int val,
int len)
common impl of the ax write methods |
int |
batMillivolts()
Runs monitor command "bat". |
OHMM.BatState |
batState()
covers batState(BatState) , always conses |
OHMM.BatState |
batState(OHMM.BatState state)
Runs monitor command "batst". |
void |
close()
Close communications with the hardware. |
protected void |
dbg(java.lang.String prefix,
byte b)
Emit a debug message documenting a comms byte iff debug . |
int |
drainReceiveBuffer()
Drain any bytes waiting in the receive buffer from the firware. |
boolean |
driveArc(float l,
float d)
Runs monitor command "da". |
boolean |
driveArcDeg(float l,
float d)
Runs monitor command "dad". |
static java.lang.String |
driveCfgToString(float[] cfg)
Convert drive config to a human readable message. |
static java.lang.StringBuilder |
driveCfgToString(float[] cfg,
java.lang.StringBuilder sb)
helper for driveCfgToString(float[]) |
float[] |
driveGetCfg()
covers driveGetCfg(float[]) , always conses |
float[] |
driveGetCfg(float[] cfg)
Runs monitor command "dgcfg". |
float[] |
driveGetPose()
calls driveGetPose(float[]) , always conses |
float[] |
driveGetPose(float[] xyt)
Runs monitor command "dgp". |
int |
driveGetQueue()
Runs monitor command "dgq". |
float[] |
driveGetVL()
calls driveGetVL(float[]) , always conses |
float[] |
driveGetVL(float[] vl)
Runs monitor command "dgvl". |
float[] |
driveGetVW()
calls driveGetVW(float[]) , always conses |
float[] |
driveGetVW(float[] vw)
Runs monitor command "dgvw". |
boolean |
driveOrientationServo(float t)
Runs monitor command "dos". |
void |
drivePause()
Runs monitor command "dp". |
void |
driveReinit()
Runs monitor command "dri". |
void |
driveResetPose()
Runs monitor command "drp". |
void |
driveSetBaseline(float b)
Runs monitor command "dsbl". |
void |
driveSetMaxAccel(float a)
Runs monitor command "dsma". |
boolean |
driveSetMaxSpeed(float s)
Runs monitor command "dsms". |
void |
driveSetPosDGain(float g)
Runs the monitor command "dsdg". |
void |
driveSetPose(float x,
float y,
float t)
Runs monitor command "dsp". |
void |
driveSetPosIGain(float g)
Runs the monitor command "dsig". |
void |
driveSetPosPGain(float g)
Runs the monitor command "dspg". |
void |
driveSetTol(float t)
Runs monitor command "dstol". |
boolean |
driveSetVL(float v,
float l)
Runs monitor command "dsvl". |
boolean |
driveSetVW(float v,
float w)
Runs monitor command "dsvw". |
void |
driveSetWheelRadius(float r)
Runs monitor command "dswr". |
OHMM.DriveState |
driveState()
covers driveState(DriveState) , always conses |
OHMM.DriveState |
driveState(OHMM.DriveState state)
Runs monitor command "drvst". |
void |
driveStop()
Runs monitor command "dst". |
boolean |
driveStraight(float d)
Runs monitor command "df". |
boolean |
driveTurn(float d)
Runs monitor command "dt". |
boolean |
driveTurnDeg(float d)
Runs monitor command "dtd". |
void |
driveUnPause()
Runs monitor command "dup". |
void |
dumpStats()
dumpStats(PrintStream) to System.out |
void |
dumpStats(java.io.PrintStream s)
Dump a human-readable summary of the comm stats. |
byte |
echo(byte out)
Ask the firmware to echo a byte. |
float |
echo(float out)
Ask the firmware to echo a float. |
int |
echo(int nb,
int out)
Ask the firmware to echo an int. |
float |
echoFix(float out)
Ask the firmware to echo a fix. |
void |
estop()
Runs monitor command "estop". |
static java.lang.String |
fmt2(float f)
format f with 2 decimal places |
static java.lang.String |
fmt4(float f)
format f with 4 decimal places |
int |
freeRam()
Runs monitor command "fr". |
int |
getBytesReceived()
Get the total number of bytes received thus far. |
int |
getBytesSent()
Get the total number of bytes sent thus far. |
java.lang.Integer |
getCmdCode(java.lang.String name)
Get a binary command code corresponding to a monitor command name. |
double |
getCommandDelay()
Get the time to wait after a no-response command, in seconds. |
double |
getCurrentTime()
get the current time in seconds |
boolean |
getDebug()
Get whether to enable debug output to stderr. |
ErrorHandler |
getErrorHandler()
Get the error handler. |
java.lang.String |
getHostVersion()
get a human-readable string giving the OHMM host library version |
java.lang.String |
getMonitorVersion()
Runs monitor command "ver". |
int |
getNumTimeouts()
Get the total number of timeouts. |
double |
getRecvPollTime()
Get the time to wait between polls for a received byte, in seconds. |
double |
getTimeout()
Get the time to wait for a response from the firmware, in seconds. |
boolean |
init()
(Re)initialize communications. |
void |
lcdAlert(int sec,
java.lang.String msgTop,
java.lang.String msgBot)
Runs monitor command "alert". |
void |
lcdMsg(java.lang.String msg)
Runs monitor command "msg". |
void |
lcdMsgClr()
Runs monitor command "msgclr". |
void |
lcdSysMsg(int start,
int width,
java.lang.String msg)
Runs monitor command "sysmsg". |
void |
lcdSysMsgClr(int start,
int width)
Runs monitor command "sysmsgclr". |
static void |
listPorts()
listPorts(PrintStream) to System.out |
static void |
listPorts(java.io.PrintStream s)
Convenience method to query the list of available ports according to RXTX. |
static OHMM |
makeOHMM(java.lang.String[] argv)
Constructs an OHMM from command line parameters. |
void |
motFree()
Runs monitor command "mfr". |
byte |
motGetErrors()
Runs monitor command "mge". |
float[] |
motGetPos()
covers motGetPos(float[]) , always conses |
float[] |
motGetPos(float[] lr)
Runs the monitor command "mgp". |
int[] |
motGetPosCounts()
covers motGetPosCounts(int[]) , always conses |
int[] |
motGetPosCounts(int[] lr)
Runs the monitor command "mgc". |
float[] |
motGetVel()
covers motGetVel(float[]) , always conses |
float[] |
motGetVel(float[] lr)
Runs the monitor command "mgv". |
float[] |
motGetVelCmd()
covers motGetVelCmd(float[]) , always conses |
float[] |
motGetVelCmd(float[] lr)
Runs the monitor command "mgvc". |
void |
motKick(int l,
int r)
Runs monitor command "mk". |
void |
motReinit()
Runs monitor command "mri". |
void |
motSetDiffVelIGain(float g)
Runs the monitor command "msdi". |
boolean |
motSetVelCmd(float l,
float r)
Runs the monitor command "msv". |
void |
motSetVelDGain(float g)
Runs the monitor command "msvd". |
void |
motSetVelIGain(float g)
Runs the monitor command "msvi". |
void |
motSetVelPGain(float g)
Runs the monitor command "msvp". |
OHMM.MotState |
motState()
covers motState(MotState) , always conses |
OHMM.MotState |
motState(OHMM.MotState state)
Runs monitor command "motst". |
void |
noResponseDelay()
Delay by the current command delay. |
OHMM.OHMMState |
ohmmState()
covers ohmmState(OHMMState) , always conses |
OHMM.OHMMState |
ohmmState(OHMM.OHMMState state)
Runs monitor command "ohmst". |
boolean |
recvBoolean()
Get a boolean as a byte, 0 false, 1 true. |
byte |
recvByte()
Covers recvByte(boolean) , timeoutOk = false. |
byte |
recvByte(boolean timeoutOk)
Get a byte from the firmware. |
char |
recvChar()
Get an ASCII char. |
float |
recvFix(int f)
Get a 2 byte fixed point value, MSB first. |
float |
recvFloat()
Get a float, MSB first. |
int |
recvInt(int size)
Get an integer, MSB first. |
java.lang.String |
recvString()
Covers recvString(boolean) , does not whitespace terminate |
java.lang.String |
recvString(boolean wsTerminate)
Receive a null terminated string. |
void |
resetStats()
Reset all comm stats. |
void |
send(boolean b)
covers send(boolean, boolean) , always flushes |
void |
send(boolean b,
boolean flush)
Send a boolean to the firmware as a byte (0 or 1). |
void |
send(byte b)
covers send(byte, boolean) , always flushes |
void |
send(byte[] bytes)
covers send(byte[], boolean) , always flushes |
void |
send(byte[] bytes,
boolean flush)
Send an array of bytes to the firmware. |
void |
send(byte b,
boolean flush)
Send a byte to the firmware. |
void |
send(char c)
covers send(char, boolean) , always flushes |
void |
send(char c,
boolean flush)
Send an ASCII char to the firmware. |
void |
send(float f)
covers send(float, boolean) , always flushes |
void |
send(float f,
boolean flush)
Send a float to the firmware, MSB first. |
void |
send(int i,
int size)
covers send(int, int, boolean) , always flushes |
void |
send(int i,
int size,
boolean flush)
Send an int to the firmware, MSB first. |
void |
send(java.lang.String s)
covers send(String, boolean) , always flushes |
void |
send(java.lang.String s,
boolean flush)
Send a null terminated ASCII string to the firmware. |
void |
send(java.lang.String s,
int len)
covers send(String, int, boolean) , always flushes |
void |
send(java.lang.String s,
int n,
boolean flush)
Send fixed length ASCII string to the firmware. |
void |
sendCmdCode(java.lang.String cmdName)
covers sendCmdCode(String, boolean) , always flushes |
void |
sendCmdCode(java.lang.String cmdName,
boolean flush)
Convenience to getCmdCode(java.lang.String) and send(int, int, boolean) . |
void |
sendFix(float x,
int f)
covers sendFix(float, int, boolean) , always flushes |
void |
sendFix(float x,
int f,
boolean flush)
Send a 2 byte fixed point value to the firmware, MSB first. |
void |
sendFlush()
flush any pending writes |
void |
sendZeros(int n)
Send zeros. |
boolean |
senseConfigAnalog(int channel,
int numSamples)
Runs monitor command "sca". |
boolean |
senseConfigAnalog(OHMM.AnalogChannel channel,
int numSamples)
Covers senseConfigAnalog(int, int) |
boolean |
senseConfigAnalogIR(int channel,
int numSamples)
Runs monitor command "scair". |
boolean |
senseConfigAnalogIR(OHMM.AnalogChannel channel,
int numSamples)
Covers senseConfigAnalogIR(int, int) |
boolean |
senseConfigAnalogLUT(int channel,
int numSamples,
int[] lutA,
float[] lutO)
Runs monitor command "scal". |
boolean |
senseConfigAnalogLUT(OHMM.AnalogChannel channel,
int numSamples,
int[] lutA,
float[] lutO)
Covers senseConfigAnalogLUT(int, int, int[], float[]) |
boolean |
senseConfigDigital(int pin,
boolean pullup,
boolean invert)
Runs monitor command "scd". |
boolean |
senseConfigDigital(OHMM.DigitalPin pin,
boolean pullup,
boolean invert)
Covers senseConfigDigital(int, boolean, boolean) |
float |
senseReadAnalog(int channel)
Runs monitor command "sra". |
float |
senseReadAnalog(OHMM.AnalogChannel channel)
Covers senseReadAnalog(int) |
boolean |
senseReadDigital(int pin)
Runs monitor command "srd". |
boolean |
senseReadDigital(OHMM.DigitalPin pin)
Covers senseReadDigital(int) |
void |
senseReinit()
Runs monitor command "sri". |
OHMM.SenseState |
senseState()
covers senseState(SenseState) , always conses |
OHMM.SenseState |
senseState(OHMM.SenseState state)
Runs monitor command "snsst". |
void |
setCommandDelay(double commandDelay)
Set the time to wait after a no-response command, in seconds. |
void |
setDebug(boolean debug)
Set whether to enable debug output to stderr. |
void |
setErrorHandler(ErrorHandler errorHandler)
Set the error handler. |
void |
setRecvPollTime(double recvPollTime)
Set the time to wait between polls for a received byte, in seconds. |
void |
setTimeout(double timeout)
Set the time to wait for a response from the firmware, in seconds. |
void |
shtdn()
Runs monitor command "shtdn". |
void |
sleep(double seconds)
sleep at least the specfied time in seconds |
int[] |
status()
covers status(int[]) |
int[] |
status(int[] status)
Runs monitor command "status". |
static java.lang.String |
statusToString(int[] status)
Convert status bytes to a human readable message. |
static java.lang.StringBuilder |
statusToString(int[] status,
java.lang.StringBuilder sb)
helper for statusToString(int[]) |
OHMM.TaskState |
taskState()
covers taskState(TaskState) , always conses |
OHMM.TaskState |
taskState(OHMM.TaskState state)
Runs monitor command "tskst". |
int |
ticks()
Runs monitor command "tck". |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String svnid
public static final Version VERSION
Version info for the host library.
getHostVersion()
is a convenience; getMonitorVersion()
asks the firmware for its version, which may differ.
public static final java.text.DecimalFormat DF2
public static final java.text.DecimalFormat DF4
public static final double DEF_TIMEOUT_RXTX
Default time to wait for a response from the firmware, in seconds, when using the RXTX backend.
public static final double DEF_TIMEOUT_FILE
Default time to wait for a response from the firmware, in seconds, when using the file backend.
public static final double DEF_TIMEOUT_PROXY
Default time to wait for a response from the firmware, in seconds, when using the command proxy.
public static final double DEF_RECV_POLL_TIME
Default time to wait between checks for an available byte, in seconds.
public static final double DEF_COMMAND_DELAY
Default time to wait after a no-response command, in seconds.
public static final double DEF_PROCESS_INIT_WAIT
Default time in seconds to wait for a com process to init.
public static final int NUM_INIT_ZEROS
Number of zeros to send the firmware on init.
public static final double INIT_DELAY
Default time to wait during the init()
delays, in seconds.
public static final java.lang.String RXTX_PORT_OWNER_NAME
RXTX Port owner name.
public static final int RXTX_OPEN_TIMEOUT_MS
Timeout in ms to wait to open a port with RXTX.
public static final int RXTX_BAUDRATE
Serial baudrate for RXTX.
public static final int INITIAL_FLUSH_BUF_LEN
Initial length of flushBuf
.
public static final int CMD_NAME_MAX
Max command name length.
public static final int SCAL_N
senseConfigAnalogLUT(int, int, int[], float[])
public static final int LCD_WIDTH
public static final int PID_FPF
protected java.util.Map<java.lang.String,java.lang.Integer> codes
Command code cache.
public static final int STATUS_LEN
status(int[])
public static final int STATUS_INDEX_BAT
status(int[])
public static final int STATUS_INDEX_TASK
status(int[])
public static final int STATUS_INDEX_HOST
status(int[])
public static final int STATUS_INDEX_MOT
status(int[])
public static final int STATUS_INDEX_DRIVE
status(int[])
public static final int STATUS_INDEX_ARM
status(int[])
public static final int TASK_ERR_COLLISION
status(int[])
public static final int TASK_ERR_MEM
status(int[])
public static final int HOST_ERR_SEND
status(int[])
public static final int HOST_ERR_RECV
status(int[])
public static final int MOT_ERR_ENC_L
status(int[])
public static final int MOT_ERR_ENC_R
status(int[])
public static final int MOT_ERR_VEL_L
status(int[])
public static final int MOT_ERR_VEL_R
status(int[])
public static final int DRIVE_ERR_ODOM
status(int[])
public static final int DRIVE_ERR_TIMEOUT
status(int[])
public static final int ARM_ERR_AX
status(int[])
public static final int ARM_ACTIVE
status(int[])
public static final int ARM_AT_GOAL
status(int[])
public static final int DRIVE_CFG_LEN
driveGetCfg(float[])
public static final int DRIVE_CFG_INDEX_R
driveGetCfg(float[])
public static final int DRIVE_CFG_INDEX_B
driveGetCfg(float[])
public static final int DRIVE_CFG_INDEX_MS
driveGetCfg(float[])
public static final int DRIVE_CFG_INDEX_MA
driveGetCfg(float[])
public static final int DRIVE_CFG_INDEX_TOL
driveGetCfg(float[])
public static final int AX_ERR_TIMEOUT
public static final int AX_ERR_INSTRUCTION
public static final int AX_ERR_OVERLOAD
public static final int AX_ERR_CHECKSUM
public static final int AX_ERR_RANGE
public static final int AX_ERR_OVERHEATING
public static final int AX_ERR_ANGLE_LIMIT
public static final int AX_ERR_VOLTAGE
public static final int AX_ERR_TRANSACTION
public static final int AX_ID_BCAST
public static final int ARM_SHOULDER
public static final int ARM_ELBOW
public static final int ARM_WRIST
public static final int ARM_GRIPPER
public static final int LEFT
public static final int RIGHT
protected int flushNext
Next unused byte in flushBuf
.
protected byte[] flushBuf
Buffer where outgoing bytes are stored until they need to be flushed.
Will be grown as necessary.
protected gnu.io.SerialPort rxtxSerialPort
RXTX serial port or null if not using RXTX.
protected java.io.OutputStream ostream
Output stream to firmware.
protected java.io.InputStream istream
Input stream from firmware.
protected ErrorHandler errorHandler
The currently installed error handler.
protected boolean recvTimedOut
Whether the last recvByte(boolean)
timed out.
protected boolean debug
Whether to enable debug messages.
protected int bytesSent
Total number of bytes sent.
protected int bytesReceived
Total number of bytes received.
protected int numTimeouts
Total number of timeouts.
protected double minRecvWait
Min time spent waiting to receive a single byte, in seconds.
protected double maxRecvWait
Max time spent waiting to receive a single byte, in seconds.
protected double totalRecvWait
Total time spent waiting to receive bytes, in seconds.
protected double avgRecvWait
Avg time spent waiting to receive a single byte, in seconds.
protected double minSendWait
Min time spent waiting to send a single byte, in seconds.
protected double maxSendWait
Max time spent waiting to send a single byte, in seconds.
protected double totalSendWait
Total time spent waiting to send bytes, in seconds.
protected double avgSendWait
Avg time spent waiting to send a single byte, in seconds.
protected double timeout
Time to wait for a response from the firmware, in seconds.
protected double recvPollTime
Time to wait between checks for an available byte, in seconds.
protected double commandDelay
Time to wait after a no-response command, in seconds.
public static final java.lang.String USAGE
makeOHMM(java.lang.String[])
Usage message.
Constructor Detail |
---|
public OHMM(ErrorHandler errorHandler, java.io.File port)
Talk to the hardware on the specified serial port, accessed as a file.
errorHandler
- the ErrorHandler
, null if noneport
- the file representing the port connected to the hardware.
Must already be configured for correct data rate, format, etc.public OHMM(java.io.File port)
Covers OHMM(ErrorHandler, File)
with a new DefaultErrorHandler
.
public OHMM(ErrorHandler errorHandler, java.lang.String portName)
Similar to OHMM(ErrorHandler, File)
, but uses RXTX library to
access the serial port.
portName
- an os-dependent port name as used by RXTX. Use listPorts(java.io.PrintStream)
to show all available names on your system.public OHMM(java.lang.String portName)
Covers OHMM(ErrorHandler, String)
with a new DefaultErrorHandler
.
public OHMM(ErrorHandler errorHandler, double initWait, java.lang.String... cmdLine)
Talk to the hardware via the specified process.
errorHandler
- the ErrorHandler
, null if noneinitWait
- time in seconds to wait for the process to initcmdLine
- the command and its arguments to start the communication
processpublic OHMM(ErrorHandler errorHandler, java.lang.String... cmdLine)
public OHMM(double initWait, java.lang.String... cmdLine)
Covers OHMM(ErrorHandler, double, String...)
with a new
DefaultErrorHandler
.
public OHMM(java.lang.String... cmdLine)
Covers OHMM(ErrorHandler, double, String...)
with a new
DefaultErrorHandler
and DEF_PROCESS_INIT_WAIT
.
Method Detail |
---|
public boolean init()
(Re)initialize communications.
Clears the command code cache and resets stats.
This will block for at least INIT_DELAY
sec, and further by up
to twice timeout
sec if the monitor was already in quiet or
binary mode.
public void setErrorHandler(ErrorHandler errorHandler)
Set the error handler.
errorHandler
- the new error handler, null for nonepublic ErrorHandler getErrorHandler()
Get the error handler.
public void setDebug(boolean debug)
Set whether to enable debug output to stderr.
debug
- whether to enable debug output to stderrpublic boolean getDebug()
Get whether to enable debug output to stderr.
public void setTimeout(double timeout)
Set the time to wait for a response from the firmware, in seconds.
timeout
- the time to wait for a response from the firmware, in
secondspublic double getTimeout()
Get the time to wait for a response from the firmware, in seconds.
public void setRecvPollTime(double recvPollTime)
Set the time to wait between polls for a received byte, in seconds.
recvPollTime
- the time to wait between polls for a received byte, in
secondspublic double getRecvPollTime()
Get the time to wait between polls for a received byte, in seconds.
public void setCommandDelay(double commandDelay)
Set the time to wait after a no-response command, in seconds.
commandDelay
- the time to wait after a no-response command, in
secondspublic double getCommandDelay()
Get the time to wait after a no-response command, in seconds.
public java.lang.String getHostVersion()
public void estop()
public void shtdn()
public java.lang.String getMonitorVersion()
public int[] status(int[] status)
status
- up to STATUS_LEN
bytes of status is returned here,
or null to cons
STATUS_INDEX_*
.public int[] status()
status(int[])
public static java.lang.String statusToString(int[] status)
status
- up to STATUS_LEN
bytes
public static java.lang.StringBuilder statusToString(int[] status, java.lang.StringBuilder sb)
statusToString(int[])
public int ticks()
public OHMM.OHMMState ohmmState(OHMM.OHMMState state)
state
- the state is returned here, or null to cons
public OHMM.OHMMState ohmmState()
ohmmState(OHMMState)
, always conses
public OHMM.AllState allState(OHMM.AllState state)
state
- the state is returned here, or null to cons
public OHMM.AllState allState()
allState(AllState)
, always conses
public int freeRam()
public OHMM.TaskState taskState(OHMM.TaskState state)
state
- the state is returned here, or null to cons
public OHMM.TaskState taskState()
taskState(TaskState)
, always conses
public void lcdMsg(java.lang.String msg)
msg
- the message to display, up to the first LCD_WIDTH
chars are usedpublic void lcdSysMsg(int start, int width, java.lang.String msg)
start
- the start column in the range 0 to LCD_WIDTH
-1width
- the width in the range 1 to LCD_WIDTH
msg
- the message to display, up to the first width
chars are usedpublic void lcdAlert(int sec, java.lang.String msgTop, java.lang.String msgBot)
sec
- alert duration in seconds, max 255msgTop
- the message to display on the top line of the LCD, up to the
first LCD_WIDTH
chars are usedmsgBot
- the message to display on the bottom line of the LCD, up to
the first LCD_WIDTH
chars are usedpublic void lcdMsgClr()
public void lcdSysMsgClr(int start, int width)
start
- the start column in the range 0 to LCD_WIDTH
-1width
- the width in the range 1 to LCD_WIDTH
public int batMillivolts()
public OHMM.BatState batState(OHMM.BatState state)
state
- the state is returned here, or null to cons
public OHMM.BatState batState()
batState(BatState)
, always conses
public void senseReinit()
public boolean senseConfigDigital(int pin, boolean pullup, boolean invert)
pin
- the digital pin index, an OrangutanDigital
IO_<port><pin> valuepullup
- whether to enable the pullup resistorinvert
- whether to invert the reading
public boolean senseConfigDigital(OHMM.DigitalPin pin, boolean pullup, boolean invert)
senseConfigDigital(int, boolean, boolean)
public boolean senseConfigAnalog(int channel, int numSamples)
channel
- the analog channelnumSamples
- number of samples to average per reading
public boolean senseConfigAnalog(OHMM.AnalogChannel channel, int numSamples)
senseConfigAnalog(int, int)
public boolean senseConfigAnalogLUT(int channel, int numSamples, int[] lutA, float[] lutO)
channel
- the analog channelnumSamples
- number of samples to average per readinglutA
- SCAL_N
LUT abssissas in the range 0 to 1023lutO
- SCAL_N
LUT ordinates
public boolean senseConfigAnalogLUT(OHMM.AnalogChannel channel, int numSamples, int[] lutA, float[] lutO)
senseConfigAnalogLUT(int, int, int[], float[])
public boolean senseConfigAnalogIR(int channel, int numSamples)
channel
- the analog channelnumSamples
- number of samples to average per reading
public boolean senseConfigAnalogIR(OHMM.AnalogChannel channel, int numSamples)
senseConfigAnalogIR(int, int)
public boolean senseReadDigital(int pin)
pin
- the digital pin index, an OrangutanDigital
IO_<port><pin> value
public boolean senseReadDigital(OHMM.DigitalPin pin)
senseReadDigital(int)
public float senseReadAnalog(int channel)
channel
- the analog channel
public float senseReadAnalog(OHMM.AnalogChannel channel)
senseReadAnalog(int)
public OHMM.SenseState senseState(OHMM.SenseState state)
state
- the state is returned here, or null to cons
public OHMM.SenseState senseState()
senseState(SenseState)
, always conses
public void motReinit()
public byte motGetErrors()
public boolean motSetVelCmd(float l, float r)
l
- the left drive motor velocity in rev/secr
- the right drive motor velocity in rev/sec
public float[] motGetVelCmd(float[] lr)
lr
- the velocities are returned here, or null to cons
public float[] motGetVelCmd()
motGetVelCmd(float[])
, always conses
public float[] motGetVel(float[] lr)
lr
- the velocities are returned here, or null to cons
public float[] motGetVel()
motGetVel(float[])
, always conses
public void motFree()
public void motKick(int l, int r)
l
- direction to pulse the left motor, or 0 for noner
- direction to pulse the right motor, or 0 for nonepublic float[] motGetPos(float[] lr)
lr
- the positions are returned here, or null to cons
public float[] motGetPos()
motGetPos(float[])
, always conses
public int[] motGetPosCounts(int[] lr)
lr
- the positions are returned here, or null to cons
public int[] motGetPosCounts()
motGetPosCounts(int[])
, always conses
public void motSetVelPGain(float g)
g
- the gainpublic void motSetVelIGain(float g)
g
- the gainpublic void motSetVelDGain(float g)
g
- the gainpublic void motSetDiffVelIGain(float g)
g
- the gainpublic OHMM.MotState motState(OHMM.MotState state)
state
- the state is returned here, or null to cons
public OHMM.MotState motState()
motState(MotState)
, always conses
public void driveReinit()
public float[] driveGetVW(float[] vw)
vw
- velocities are returned here, or cons if null
public float[] driveGetVW()
driveGetVW(float[])
, always conses
public float[] driveGetVL(float[] vl)
vl
- velocities are returned here, or cons if null
public float[] driveGetVL()
driveGetVL(float[])
, always conses
public boolean driveSetVW(float v, float w)
v
- forward velocity in mm/sw
- rotational velocity in rad/s, CCW positivepublic boolean driveSetVL(float v, float l)
v
- forward velocity in mm/s or turn velocity in rad/s for turn in
placel
- turn radius in mm, CCW positivepublic float[] driveGetPose(float[] xyt)
xyt
- pose is returned here, or cons if null
Units correspond to args to driveSetPose(float, float, float)
.
public float[] driveGetPose()
driveGetPose(float[])
, always conses
public void driveSetPose(float x, float y, float t)
x
- pose x in mmy
- pose y in mmt
- pose theta in rad CCW positivepublic void driveResetPose()
public boolean driveStraight(float d)
d
- distance to travel in mm, positive forward
public boolean driveTurn(float d)
d
- amount of turn in radians, CCW positive
public boolean driveTurnDeg(float d)
d
- amount of turn in degrees, CCW positive
public boolean driveArc(float l, float d)
l
- signed arc radius in mmd
- signed drive distance in mm, or turn angle in rad for turn in
place
public boolean driveArcDeg(float l, float d)
l
- signed arc radius in mmd
- signed drive distance in mm, or turn angle in degrees for turn in
place
public boolean driveOrientationServo(float t)
t
- global goal orientation in rad or NaN to disable orientation servo
public int driveGetQueue()
public void drivePause()
public void driveUnPause()
public void driveStop()
public void driveSetPosPGain(float g)
g
- the gainpublic void driveSetPosIGain(float g)
g
- the gainpublic void driveSetPosDGain(float g)
g
- the gainpublic float[] driveGetCfg(float[] cfg)
cfg
- up to DRIVE_CFG_LEN
floats of config is returned here,
or null to cons
DRIVE_CFG_INDEX_*
.public float[] driveGetCfg()
driveGetCfg(float[])
, always conses
public static java.lang.String driveCfgToString(float[] cfg)
cfg
- up to DRIVE_CFG_LEN
bytes
public static java.lang.StringBuilder driveCfgToString(float[] cfg, java.lang.StringBuilder sb)
driveCfgToString(float[])
public void driveSetWheelRadius(float r)
r
- nonnegative wheel radius in mmpublic void driveSetBaseline(float b)
b
- nonnegative baseline between wheels in mmpublic boolean driveSetMaxSpeed(float s)
s
- positive maximum speed in mm/sec
public void driveSetMaxAccel(float a)
a
- positive max acceleration in mm/sec/sec, or
Float.POSITIVE_INFINITY
to skip accelerationpublic void driveSetTol(float t)
t
- tolerance in mmpublic OHMM.DriveState driveState(OHMM.DriveState state)
state
- the state is returned here, or null to cons
public OHMM.DriveState driveState()
driveState(DriveState)
, always conses
public static java.lang.String axErrToString(int err)
err
- the error code
public void axReinit()
public int axPing(int id)
id
- the AX12 id, less than AX_ID_BCAST
protected int axWriteImpl(java.lang.String cmd, int id, int reg, int val, int len)
public int axWrite(int id, int reg, int val)
id
- the AX12 id, less than 255reg
- the target registerval
- the new value
public int axWrite(int id, OHMM.AXReg reg, int val)
axWrite(int, int, int)
but takes an OHMM.AXReg
.
public int axRegWrite(int id, int reg, int val)
id
- the AX12 id, less than 255
public int axRegWrite(int id, OHMM.AXReg reg, int val)
axRegWrite(int, int, int)
but takes an OHMM.AXReg
.
public int axRead(int id, int reg)
id
- the AX12 id, less than 255reg
- the target register
public int axRead(int id, OHMM.AXReg reg)
axRead(int, int)
but takes an OHMM.AXReg
.
public int axAction(int id)
id
- the AX12 id, less than 255
public int axRead16(int id, int reg)
id
- the AX12 id, less than 255reg
- the target register
public int axRead16(int id, OHMM.AXReg reg)
axRead16(int, int)
but takes an OHMM.AXReg
.
public int axWrite11(int id, int reg, int val)
id
- the AX12 id, less than 255reg
- the target registerval
- the new value
public int axWrite11(int id, OHMM.AXReg reg, int val)
axWrite11(int, int, int)
but takes an OHMM.AXReg
.
public int axRegWrite11(int id, int reg, int val)
id
- the AX12 id, less than 255reg
- the target registerval
- the new value
axAction(int)
.public int axRegWrite11(int id, OHMM.AXReg reg, int val)
axRegWrite11(int, int, int)
but takes an OHMM.AXReg
.
public int axSetAngleLimits(int id, int cwLimit, int ccwLimit)
id
- the AX12 id, less than 255cwLimit
- clockwise limitccwLimit
- counterclockwise limit
public int axTorqueEnable(int id, boolean enable)
id
- the AX12 id, less than 255
public void axESTOP()
protected int axSetGoalImpl(java.lang.String cmd, int id, int goal)
protected int axSetGoalImpl(java.lang.String cmd, int id, float goal)
public int axSetGoal(int id, int goal)
id
- the AX12 id, less than 255goal
- goal position to set
public int axRegSetGoal(int id, int goal)
axSetGoal(int, int)
but does a reg write.
The new value will take effect on the next axAction(int)
.
public int axSetGoalDeg(int id, float goal)
axSetGoal(int, int)
but in degrees
public int axRegSetGoalDeg(int id, float goal)
axRegSetGoal(int, int)
but in degrees
public int axSetGoalRad(int id, float goal)
axSetGoal(int, int)
but in radians
public int axRegSetGoalRad(int id, float goal)
axRegSetGoal(int, int)
but in radians
public int axGetPos(int id)
id
- the AX12 id, less than AX_ID_BCAST
public float axGetPosDeg(int id)
id
- the AX12 id, less than AX_ID_BCAST
public float axGetPosRad(int id)
id
- the AX12 id, less than AX_ID_BCAST
public int axGetLoad(int id)
id
- the AX12 id, less than AX_ID_BCAST
public float axGetVolts(int id)
id
- the AX12 id, less than AX_ID_BCAST
public int axGetTemp(int id)
id
- the AX12 id, less than AX_ID_BCAST
public int axGetNumRetries()
axReinit()
public int axGetNumTimeouts()
axReinit()
public int axGetNumOverflows()
axReinit()
public OHMM.AXState axState(OHMM.AXState state)
state
- the state is returned here, or null to cons
public OHMM.AXState axState()
axState(AXState)
, always conses
public void armReinit()
public void armEnable(boolean enable)
public void armHold(boolean hold)
public void armHome()
public void armCal()
public boolean armSetJoint(int joint, int counts)
joint
- the joint index, ARM_SHOULDER
, ARM_ELBOW
,
ARM_WRIST
counts
- the joint angle in AX12 counts
public boolean armSetJointDeg(int joint, float angle)
armSetJoint(int, int)
but in degrees.
public boolean armSetJointRad(int joint, float angle)
armSetJoint(int, int)
but in radians.
public boolean armSetAllJoints(int... counts)
armSetJoint(int, int)
but sets all three joints.
public boolean armSetAllJointsDeg(float... angle)
armSetAllJoints(int...)
but in degrees.
public boolean armSetAllJointsRad(float... angle)
armSetAllJoints(int...)
but in radians.
public int armGetJoint(int joint)
joint
- the joint index, ARM_SHOULDER
, ARM_ELBOW
,
ARM_WRIST
public float armGetJointDeg(int joint)
armGetJoint(int)
but in degrees.
public float armGetJointRad(int joint)
armGetJoint(int)
but in radians.
public int[] armGetAllJoints(int[] counts)
counts
- the 3 angles are stored here, if not null, else cons
Like armGetJoint(int)
but gets all joints.public int[] armGetAllJoints()
armGetAllJoints(int[])
, always conses.
public float[] armGetAllJointsDeg(float[] angle)
armGetAllJoints(int[])
but in degrees.
public float[] armGetAllJointsDeg()
armGetAllJointsDeg(float[])
, always conses.
public float[] armGetAllJointsRad(float[] angle)
armGetAllJoints(int[])
but in radians.
public float[] armGetAllJointsRad()
armGetAllJointsRad(float[])
, always conses.
public boolean armSetGripper(float state)
state
- the griper state, 0.0 for closed, 1.0 for open
public float armGetGripper()
public boolean armSetCal(int joint, int offset)
joint
- ARM_SHOULDER
, ARM_ELBOW
, ARM_WRIST
, or ARM_GRIPPER
offset
- the calibration offset in AX12 counts
public int armGetCal(int joint)
joint
- ARM_SHOULDER
, ARM_ELBOW
, ARM_WRIST
, or ARM_GRIPPER
public boolean armSetAllCal(int... offset)
armSetCal(int, int)
but sets all 4 calibration values.
public int[] armGetAllCal(int[] offset)
offset
- the 4 offsets are stored here, if not null, else cons
public int[] armGetAllCal()
armGetAllCal(int[])
, always conses.
public int[] armGetTemps(int[] temp)
temp
- the 4 temps are stored here, if not null, else cons
public int[] armGetTemps()
armGetTemps(int[])
, always conses.
public int[] armGetLoads(int[] load)
load
- the 4 loads are stored here, if not null, else cons
public int[] armGetLoads()
armGetLoads(int[])
, always conses.
public boolean armActive()
public boolean armAtGoal()
public int armGetNumAXErrors()
armReinit()
.public OHMM.ArmState armState(OHMM.ArmState state)
state
- the state is returned here, or null to cons
public OHMM.ArmState armState()
armState(ArmState)
, always conses
public java.lang.Integer getCmdCode(java.lang.String name)
Get a binary command code corresponding to a monitor command name.
Memoized to minimize communication.
name
- the command name, at most CMD_NAME_MAX
chars
public byte echo(byte out)
Ask the firmware to echo a byte.
Any registered ErrorHandler
will be notified on timeout or I/O
error.
out
- the byte to echo
public int echo(int nb, int out)
Ask the firmware to echo an int.
Any registered ErrorHandler
will be notified on timeout or I/O
error.
nb
- number of bytes, see send(int, int, boolean)
out
- the int to echo
public float echo(float out)
Ask the firmware to echo a float.
Any registered ErrorHandler
will be notified on timeout or I/O
error.
out
- the float to echo
public float echoFix(float out)
Ask the firmware to echo a fix.
Any registered ErrorHandler
will be notified on timeout or I/O
error.
out
- the fix to echo, see sendFix(float, int, boolean)
public void sendCmdCode(java.lang.String cmdName, boolean flush)
getCmdCode(java.lang.String)
and send(int, int, boolean)
.
public void sendCmdCode(java.lang.String cmdName)
sendCmdCode(String, boolean)
, always flushes
public void send(java.lang.String s, int n, boolean flush)
Send fixed length ASCII string to the firmware.
Any registered ErrorHandler
will be notified on I/O error.
Exactly n bytes will always be sent. If s is too short, nulls will be sent to fill in the remaining space.
s
- the string to sendn
- the total number of characters to sendflush
- whether to flush this write as well as any that were
previously pending, at the last bytepublic void send(java.lang.String s, int len)
send(String, int, boolean)
, always flushes
public void send(java.lang.String s, boolean flush)
Send a null terminated ASCII string to the firmware.
Any registered ErrorHandler
will be notified on I/O error.
s
- the string to sendflush
- whether to flush this write as well as any that were
previously pending, at the last bytepublic void send(java.lang.String s)
send(String, boolean)
, always flushes
public void send(byte[] bytes, boolean flush)
Send an array of bytes to the firmware.
Any registered ErrorHandler
will be notified on I/O error.
bytes
- the bytes to sendflush
- whether to flush this write as well as any that were
previously pending, at the last bytepublic void send(byte[] bytes)
send(byte[], boolean)
, always flushes
public void send(char c, boolean flush)
Send an ASCII char to the firmware.
Any registered ErrorHandler
will be notified on I/O error.
c
- the char to sendflush
- whether to flush this write as well as any that were
previously pendingpublic void send(char c)
send(char, boolean)
, always flushes
public void send(boolean b, boolean flush)
Send a boolean to the firmware as a byte (0 or 1).
Any registered ErrorHandler
will be notified on I/O error.
b
- the boolean to sendflush
- whether to flush this write as well as any that were
previously pendingpublic void send(boolean b)
send(boolean, boolean)
, always flushes
public void sendFix(float x, int f, boolean flush)
Send a 2 byte fixed point value to the firmware, MSB first.
Any registered ErrorHandler
will be notified on I/O error.
x
- the value to sendf
- number of fraction bitsflush
- whether to flush this write as well as any that were
previously pending, at the last bytepublic void sendFix(float x, int f)
sendFix(float, int, boolean)
, always flushes
public void send(float f, boolean flush)
Send a float to the firmware, MSB first.
Any registered ErrorHandler
will be notified on I/O error.
f
- the float to sendflush
- whether to flush this write as well as any that were
previously pending, at the last bytepublic void send(float f)
send(float, boolean)
, always flushes
public void send(int i, int size, boolean flush)
Send an int to the firmware, MSB first.
Any registered ErrorHandler
will be notified on I/O error.
i
- the int to sendsize
- the number of LS bytes of i to send, leq 4flush
- whether to flush this write as well as any that were
previously pending, at the last bytepublic void send(int i, int size)
send(int, int, boolean)
, always flushes
public void send(byte b, boolean flush)
Send a byte to the firmware.
Any registered ErrorHandler
will be notified on I/O error.
b
- the byte to sendflush
- whether to flush this write as well as any that were
previously pendingpublic void send(byte b)
send(byte, boolean)
, always flushes
public void sendFlush()
public void sendZeros(int n)
Send zeros.
n
- number of zeros to sendpublic java.lang.String recvString(boolean wsTerminate)
Receive a null terminated string.
Any registered ErrorHandler
will be notified on timeout or I/O
error.
wsTerminate
- whether to terminate on whitespace or null; if not only
terminates on null
public java.lang.String recvString()
recvString(boolean)
, does not whitespace terminate
public char recvChar()
Get an ASCII char.
Any registered ErrorHandler
will be notified on timeout or I/O
error.
public boolean recvBoolean()
Get a boolean as a byte, 0 false, 1 true.
Any registered ErrorHandler
will be notified on timeout or I/O
error.
public float recvFix(int f)
Get a 2 byte fixed point value, MSB first.
Any registered ErrorHandler
will be notified on timeout or I/O
error.
f
- number of fraction bits
public float recvFloat()
Get a float, MSB first.
Any registered ErrorHandler
will be notified on timeout or I/O
error.
public int recvInt(int size)
Get an integer, MSB first.
Any registered ErrorHandler
will be notified on timeout or I/O
error.
size
- the number of bytes to expect in the int, absolute value at
most 4, sign extend iff neg
public byte recvByte(boolean timeoutOk)
Get a byte from the firmware.
timeoutOk
- iff false then any registered ErrorHandler
will
be notified on timeout
public byte recvByte()
Covers recvByte(boolean)
, timeoutOk = false.
public int drainReceiveBuffer()
Drain any bytes waiting in the receive buffer from the firware.
ErrorHandler
will be notified as well).public void noResponseDelay()
Delay by the current command delay.
public void close()
Close communications with the hardware.
It is ok to call this more than once.
public int getBytesSent()
Get the total number of bytes sent thus far.
public int getBytesReceived()
Get the total number of bytes received thus far.
public int getNumTimeouts()
Get the total number of timeouts.
public void resetStats()
Reset all comm stats.
public void dumpStats(java.io.PrintStream s)
Dump a human-readable summary of the comm stats.
public void dumpStats()
dumpStats(PrintStream)
to System.out
public static void listPorts(java.io.PrintStream s)
Convenience method to query the list of available ports according to RXTX.
public static void listPorts()
listPorts(PrintStream)
to System.out
public static OHMM makeOHMM(java.lang.String[] argv) throws java.io.IOException
Constructs an OHMM from command line parameters.
See USAGE
.
java.io.IOException
public void sleep(double seconds) throws java.lang.InterruptedException
java.lang.InterruptedException
public double getCurrentTime()
protected void dbg(java.lang.String prefix, byte b)
Emit a debug message documenting a comms byte iff debug
.
public static java.lang.String fmt2(float f)
public static java.lang.String fmt4(float f)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |