|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrbrain.Pose
public class Pose
Bioloid pose.
A pose contains values for a collection of AXRegister
s for a set
of dynamixels. The register collection is the same across all dynamixels,
and must consist of registers for only one dynamixel type (e.g. AX12Register
or AXS1Register
). Neither the register collection nor
the set of dynamixels are mutable, but the values
of the registers
are. The recommended synchronization object for value mutation is
the Pose object itself.
The collections of registers
and axIDs
need not
be ordered or contiguous; however axIDs
does need to be
unique.
BRBrain
read and write formats will be computed, respectively, as
the shortest contiguous span including all registers (read format), and as
the longest contiguous span of writable RAM registers included in registers
starting from the lowest-address such register in registers
(write format). It is also possible to specify arguments to the
constructor which override the default write format; in that case the
specified write span must be a writeable subset of registers
.
Methods readFrom(int[], int)
/writeTo(int[], int)
are
providing for gathering/scattering the pose values
from/to an
BRBrain
read/write block.
Methods readFrom(PoseTokenizer)
, readFrom(InputStream)
,
and writeTo(PrintWriter)
are also provided for parsing and writing
the pose to character streams in lisp sexp format with semicolon
comments.
Copyright (C) 2007 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Nested Class Summary | |
---|---|
static class |
Pose.PoseTokenizer
specialized tokenizer for poses, see Pose class header doc |
Field Summary | |
---|---|
int[] |
axIDs
the set of axIDs; do not mutate |
java.util.Map<java.lang.Integer,java.lang.Integer> |
axIDToIndex
Unmodifiable inverse mapping of dynamixel id to dynamixel index, see values . |
private static java.lang.String |
cvsid
|
static int |
PRESERVE_SPEED_POSITION_EPSILON
Position difference below which to preserve previous speed in setMovingSpeedFrom(brbrain.Pose, int) . |
int |
readNum
the number of regs in the BRBrain read format |
AXRegister |
readStart
the first reg in the BRBrain read format |
AXRegister[] |
registers
the set of registers; do not mutate |
java.util.Map<AXRegister,int[]> |
values
The register values, indexed first by register and second by dynamixel index. |
static int |
WRITE_FIELD_WIDTH
width in characters of register values written to an output stream |
int |
writeNum
the number of regs in the BRBrain write format, or 0 if none |
AXRegister |
writeStart
the first reg in the BRBrain write format, or null if none |
Constructor Summary | |
---|---|
Pose(int[] axIDs,
AXRegister[] registers)
see class header doc; uses default write span |
|
Pose(int[] axIDs,
AXRegister[] registers,
AXRegister writeStart,
int writeNum)
See class header doc. |
|
Pose(int firstAXID,
int lastAXID,
AXRegister[] registers)
see class header doc; uses default write span |
|
Pose(int firstAXID,
int lastAXID,
AXRegister[] registers,
AXRegister writeStart,
int writeNum)
see class header doc |
|
Pose(Pose otherPose)
covers Pose(Pose, boolean) , always copies values |
|
Pose(Pose otherPose,
boolean copyValues)
make a pose with same format and maybe values as another |
Method Summary | |
---|---|
int |
getMSMorphTimeFrom(Pose otherPose)
Compute the expected morph time in milliseconds starting from otherPose. |
int |
getRegisterValue(int axID,
AXRegister register)
read a register value safely |
static int[] |
makeIDs(int firstAXID,
int lastAXID)
Makes a contiguous array of ids in the range [firstAXID, lastAXID]. |
void |
readFrom(java.io.InputStream is)
covers readFrom(PoseTokenizer) , conses the tokenizer |
void |
readFrom(int[] data)
covers readFrom(int[], int) , starts at 0 |
void |
readFrom(int[] data,
int startIndex)
Gather values from an BRBrain read block; see class
header doc. |
void |
readFrom(Pose.PoseTokenizer t)
Parse values in lisp sexp format. |
protected void |
readFrom(Pose.PoseTokenizer t,
AXRegister r,
int[] data)
parse one register list |
void |
readFrom(Pose otherPose)
read values from other pose |
boolean |
sameFormat(Pose otherPose)
Check if this Pose is the same as otherPose except, possibly, for the contents of the values . |
void |
setGoalPositionFromPresent()
Set AX12Register.AX12_GOAL_POSITION from AX12Register.AX12_PRESENT_POSITION . |
void |
setMovingSpeedFrom(Pose otherPose,
int msMorphTime)
Set the AX12Register.AX12_MOVING_SPEED of this Pose given the
desired morph time in milliseconds starting from otherPose. |
void |
setRegisterValue(AXRegister register,
int value)
write same register value for all dynamixels safely |
void |
setRegisterValue(AXRegister register,
Pose otherPose)
copy register value for all dynamixels safely |
void |
setRegisterValue(int axID,
AXRegister register,
int value)
write a register value safely |
void |
writeHeaderTo(java.io.OutputStream s)
covers writeHeaderTo(PrintWriter) |
void |
writeHeaderTo(java.io.PrintWriter w)
write a header comment with the dynamixel IDs |
void |
writeTo(int[] data)
covers writeTo(int[], int) , starts at 0 |
void |
writeTo(int[] data,
int startIndex)
Scatter values to an BRBrain write block; see class
header doc. |
void |
writeTo(java.io.OutputStream s)
covers writeTo(PrintWriter) |
void |
writeTo(Pose otherPose)
write values to other pose |
void |
writeTo(java.io.PrintWriter w)
write values in the format readFrom(brbrain.Pose) expects |
protected void |
writeTo(java.io.PrintWriter w,
AXRegister r,
int[] data)
write one register list |
protected void |
writeTo(java.io.PrintWriter w,
int v)
write one int left padded with spaces to WRITE_FIELD_WIDTH |
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 cvsid
public static final int PRESERVE_SPEED_POSITION_EPSILON
Position difference below which to preserve previous speed in setMovingSpeedFrom(brbrain.Pose, int)
.
public static final int WRITE_FIELD_WIDTH
public final int[] axIDs
public final AXRegister[] registers
public final AXRegister readStart
BRBrain
read format
public final AXRegister writeStart
BRBrain
write format, or null if none
public final int readNum
BRBrain
read format
public final int writeNum
BRBrain
write format, or 0 if none
public java.util.Map<AXRegister,int[]> values
The register values, indexed first by register and second by dynamixel index.
The map itself is not mutable (TBD), but the contents of the value arrays are. The containing Pose is the recommended synchronization object.
Dynamixel indices are the zero-based index of the dynamixel ID in
axIDs
, and dynamixel index i is not necessarily the same
as axIDs
[i]. See axIDToIndex
.
public java.util.Map<java.lang.Integer,java.lang.Integer> axIDToIndex
Unmodifiable inverse mapping of dynamixel id to dynamixel index, see
values
.
Constructor Detail |
---|
public Pose(Pose otherPose, boolean copyValues)
values
as another
public Pose(Pose otherPose)
Pose(Pose, boolean)
, always copies values
public Pose(int[] axIDs, AXRegister[] registers, AXRegister writeStart, int writeNum)
See class header doc.
writeStart
- overrides the default iff non-nullwriteNum
- overrides the default iff non-negativepublic Pose(int[] axIDs, AXRegister[] registers)
public Pose(int firstAXID, int lastAXID, AXRegister[] registers, AXRegister writeStart, int writeNum)
public Pose(int firstAXID, int lastAXID, AXRegister[] registers)
Method Detail |
---|
public static int[] makeIDs(int firstAXID, int lastAXID)
Makes a contiguous array of ids in the range [firstAXID, lastAXID].
public boolean sameFormat(Pose otherPose)
Check if this Pose is the same as otherPose except, possibly,
for the contents of the values
.
public int getRegisterValue(int axID, AXRegister register)
public void setRegisterValue(int axID, AXRegister register, int value)
public void setRegisterValue(AXRegister register, int value)
public void setRegisterValue(AXRegister register, Pose otherPose)
public int getMSMorphTimeFrom(Pose otherPose)
Compute the expected morph time in milliseconds starting from otherPose.
This Pose and otherPose must have the same axIDs
and
must both include AX12Register.AX12_GOAL_POSITION
. This Pose must
also include AX12Register.AX12_MOVING_SPEED
. The morph time is
the maximum time it would take any dynamixel to move from the other pose
to this pose at the given speed.
public void setGoalPositionFromPresent()
public void setMovingSpeedFrom(Pose otherPose, int msMorphTime)
Set the AX12Register.AX12_MOVING_SPEED
of this Pose given the
desired morph time in milliseconds starting from otherPose.
Recriprocal to getMSMorphTimeFrom(brbrain.Pose)
. The AX12Register.AX12_MOVING_SPEED
is computed for all dynamixels which
change goal position more than PRESERVE_SPEED_POSITION_EPSILON
so
that they all move for the entire duration of the morph.
public void readFrom(Pose otherPose)
values
from other pose
public void writeTo(Pose otherPose)
values
to other pose
public void readFrom(int[] data, int startIndex)
public void readFrom(int[] data)
readFrom(int[], int)
, starts at 0
public void writeTo(int[] data, int startIndex)
public void writeTo(int[] data)
writeTo(int[], int)
, starts at 0
public void readFrom(Pose.PoseTokenizer t) throws java.io.IOException
Parse values
in lisp sexp format.
The values are parsed as a list of register lists in the order of
registers
, with each register list containing the register value
for each dynamixel in the order of axIDs
.
Lisp semicolon comments are ignored.
java.io.IOException
public void readFrom(java.io.InputStream is) throws java.io.IOException
readFrom(PoseTokenizer)
, conses the tokenizer
java.io.IOException
protected void readFrom(Pose.PoseTokenizer t, AXRegister r, int[] data) throws java.io.IOException
java.io.IOException
public void writeTo(java.io.PrintWriter w) throws java.io.IOException
values
in the format readFrom(brbrain.Pose)
expects
java.io.IOException
public void writeTo(java.io.OutputStream s) throws java.io.IOException
writeTo(PrintWriter)
java.io.IOException
protected void writeTo(java.io.PrintWriter w, AXRegister r, int[] data) throws java.io.IOException
java.io.IOException
protected void writeTo(java.io.PrintWriter w, int v) throws java.io.IOException
WRITE_FIELD_WIDTH
java.io.IOException
public void writeHeaderTo(java.io.PrintWriter w) throws java.io.IOException
java.io.IOException
public void writeHeaderTo(java.io.OutputStream s) throws java.io.IOException
writeHeaderTo(PrintWriter)
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |