|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrbrain.AXRegister
public abstract class AXRegister
Represents the Dynamixel AX registers in a high-level way.
Multi-byte registers are handled as single values, write control and value clamping is provided, encoding and decoding from the 11 bit sign magnitude representation used by some AX-12 registers is handled, and translation to and from natural fractional units is included.
Copyright (C) 2008 Marsette A. Vona, III
Field Summary | |
---|---|
static int |
E_ANGLE_LIMIT
Dynamixel error bit (goal pos out of range) |
static int |
E_CHECKSUM
Dynamixel error bit (comm failure) |
static int |
E_INPUT_VOLTAGE
Dynamixel error bit |
static int |
E_INSTRUCTION
Dynamixel error bit (invalid instruction) |
static int |
E_OVERHEATING
Dynamixel error bit |
static int |
E_OVERLOAD
Dynamixel error bit (insufficient torque) |
static int |
E_RANGE
Dynamixel error bit (write parameter out of range) |
int |
max
maximum valid write value of this register, if writeable |
static int |
MAX_DYNAMIXEL_ID
maximum Dynamixel ID |
int |
min
minimum valid write value of this register, if writeable |
java.lang.String |
naturalUnitsLabel
human-readable label for the natural units, if any |
float |
naturalUnitsPerCount
multiplier taking natural units to int register counts |
int |
ordinal
zero-based index of this register in the register bank |
java.lang.String |
prettyName
pretty human-readable register name |
static int |
RAM_START_ADDRESS
start address of RAM |
boolean |
signMagnitude11Bit
Whether this is a 2-byte little endian reg with a 10 bit magnitude and the sign in bit 11. |
int |
startAddr
start (byte) address of this register in the AX-12 register space |
private static java.lang.String |
svnid
|
boolean |
useNaturalUnitsByDefault
whether to prefer natural or raw units by default |
int |
width
byte width of this register |
boolean |
writeable
whether this register can be written |
Constructor Summary | |
---|---|
protected |
AXRegister(int ordinal,
java.lang.String prettyName,
int startAddr,
int width,
boolean signMagnitude11Bit,
float naturalUnitsPerCount,
java.lang.String naturalUnitsLabel,
boolean useNaturalUnitsByDefault)
read-only reg with all options |
protected |
AXRegister(int ordinal,
java.lang.String prettyName,
int startAddr,
int width,
int min,
int max,
boolean signMagnitude11Bit,
float naturalUnitsPerCount,
java.lang.String naturalUnitsLabel,
boolean useNaturalUnitsByDefault)
writeable reg with all options |
Method Summary | |
---|---|
int |
check(float value)
covers check(int) , converts fromNaturalUnits(float) |
int |
check(int value)
Check if an integer write value is within the closed interval [ min , max ]. |
static void |
checkSpan(AXRegister start,
int n)
verify that (start, n) is a valid span of registers |
float |
clamp(float value)
Covers clamp(int) , converts fromNaturalUnits(float) and
toNaturalUnits(int) . |
int |
clamp(int value)
Clamp an integer write value to the closed interval [ min ,
max ]. |
static boolean |
containsReadOnlyRegs(AXRegister start,
int n)
check whether a span of registers contains any which are read-only |
int |
decode(int value)
Encode an integer read value from the register bits. |
static AXRegister[] |
dup(AXRegister[] from,
AXRegister[] to)
Covers dup(AXRegister[], AXRegister[], int) , copies all. |
static AXRegister[] |
dup(AXRegister[] from,
AXRegister[] to,
int n)
duplicate first n element of from into to, reallocating as necessary |
int |
encode(int value)
Encode an integer write value into the bits to write to the register. |
static AXRegister[] |
ensureCapacity(AXRegister[] a,
int n)
make sure a is at least length n |
static java.lang.String |
errorsToString(int errors)
Covers errorsToString(int, StringBuffer) |
static java.lang.StringBuffer |
errorsToString(int errors,
java.lang.StringBuffer buf)
Compose a human-readable string of AX-12 errors from a Dynamixel error bitfield. |
int |
fromNaturalUnits(float value)
Convert a register int value from natural units. |
protected abstract java.lang.String |
getDynamixelType()
get an identifier for registers of this Dynamixel type |
abstract int |
getNumRegisters()
get the total number of registers in this Dynamixel type |
abstract AXRegister |
getRelativeRegister(int offset)
get the register with the given relative ordinal |
static float |
interp(float abscissa,
float valueAtLowEnd,
float abscissaAtLowEnd,
float valueAtHighEnd,
float abscissaAtHighEnd)
Linearly interpolate between the points (abscissaAtLowEnd, valueAtLowEnd) and (abscissaAtHighEnd, valueAtHighEnd). |
boolean |
isBoolean()
check if this is a boolean valued register |
boolean |
isRAM()
true iff register is in RAM |
AXRegister |
nextRegister()
get the next register after this one |
AXRegister |
prevRegister()
get register before this one |
static AXRegister[] |
span(AXRegister start)
covers span(AXRegister, int) , spans till end |
static AXRegister[] |
span(AXRegister start,
AXRegister[] span)
covers span(AXRegister, int, AXRegister[]) , spans till end |
static AXRegister[] |
span(AXRegister start,
int n)
covers span(AXRegister, int, AXRegister[]) , always conses |
static AXRegister[] |
span(AXRegister start,
int n,
AXRegister[] span)
Return span of n regs from start. |
java.lang.String |
toIdentifierString()
returns the Java identifier for this register |
float |
toNaturalUnits(int value)
Convert a register int value to natural units. |
java.lang.String |
toString()
returns prettyName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String svnid
public static final int MAX_DYNAMIXEL_ID
public static final int RAM_START_ADDRESS
public static final int E_INPUT_VOLTAGE
public static final int E_ANGLE_LIMIT
public static final int E_OVERHEATING
public static final int E_RANGE
public static final int E_CHECKSUM
public static final int E_OVERLOAD
public static final int E_INSTRUCTION
public final int ordinal
public final java.lang.String prettyName
public final int startAddr
public final int width
public final boolean writeable
public final int min
public final int max
public final java.lang.String naturalUnitsLabel
public final boolean useNaturalUnitsByDefault
public final boolean signMagnitude11Bit
Whether this is a 2-byte little endian reg with a 10 bit magnitude and the sign in bit 11.
When the sign bit is set the value is interpreted as negative or clocwise.
public final float naturalUnitsPerCount
Constructor Detail |
---|
protected AXRegister(int ordinal, java.lang.String prettyName, int startAddr, int width, int min, int max, boolean signMagnitude11Bit, float naturalUnitsPerCount, java.lang.String naturalUnitsLabel, boolean useNaturalUnitsByDefault)
protected AXRegister(int ordinal, java.lang.String prettyName, int startAddr, int width, boolean signMagnitude11Bit, float naturalUnitsPerCount, java.lang.String naturalUnitsLabel, boolean useNaturalUnitsByDefault)
Method Detail |
---|
public static void checkSpan(AXRegister start, int n)
public static boolean containsReadOnlyRegs(AXRegister start, int n)
public static AXRegister[] dup(AXRegister[] from, AXRegister[] to, int n)
public static AXRegister[] dup(AXRegister[] from, AXRegister[] to)
Covers dup(AXRegister[], AXRegister[], int)
, copies all.
public static AXRegister[] ensureCapacity(AXRegister[] a, int n)
public static AXRegister[] span(AXRegister start, int n, AXRegister[] span)
Return span of n regs from start.
Span is returned in span iff it's big enough, else a new array.
If n is less than 0 then the span includes all subsequent registers.
public static AXRegister[] span(AXRegister start, int n)
span(AXRegister, int, AXRegister[])
, always conses
public static AXRegister[] span(AXRegister start, AXRegister[] span)
span(AXRegister, int, AXRegister[])
, spans till end
public static AXRegister[] span(AXRegister start)
span(AXRegister, int)
, spans till end
public static float interp(float abscissa, float valueAtLowEnd, float abscissaAtLowEnd, float valueAtHighEnd, float abscissaAtHighEnd)
Linearly interpolate between the points (abscissaAtLowEnd, valueAtLowEnd) and (abscissaAtHighEnd, valueAtHighEnd).
public static final java.lang.StringBuffer errorsToString(int errors, java.lang.StringBuffer buf)
Compose a human-readable string of AX-12 errors from a Dynamixel error bitfield.
errors
- the bitpacked error valuebuf
- the buffer to append, or null to make one
public static final java.lang.String errorsToString(int errors)
errorsToString(int, StringBuffer)
public boolean isRAM()
public int check(int value)
Check if an integer write value is within the closed interval [min
, max
].
value
- the value to check
public int check(float value)
check(int)
, converts fromNaturalUnits(float)
public int clamp(int value)
Clamp an integer write value to the closed interval [min
,
max
].
value
- the value to clamp
public float clamp(float value)
Covers clamp(int)
, converts fromNaturalUnits(float)
and
toNaturalUnits(int)
.
public int encode(int value)
Encode an integer write value into the bits to write to the register.
Handles conversion to signMagnitude11Bit
as appropriate.
value
- the value to encode
public int decode(int value)
Encode an integer read value from the register bits.
Handles conversion from signMagnitude11Bit
as
appropriate.
value
- the value to decode
public float toNaturalUnits(int value)
Convert a register int value to natural units.
Default impl just multiplies by naturalUnitsPerCount
.
value
- the int value to convert
public int fromNaturalUnits(float value)
Convert a register int value from natural units.
Default impl just divides by naturalUnitsPerCount
.
value
- the natural value to convert
public boolean isBoolean()
public abstract AXRegister getRelativeRegister(int offset)
public abstract int getNumRegisters()
public AXRegister nextRegister()
public AXRegister prevRegister()
public java.lang.String toString()
prettyName
toString
in class java.lang.Object
protected abstract java.lang.String getDynamixelType()
public java.lang.String toIdentifierString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |