|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.geometry.SpatialObject
public class SpatialObject
Represents a geometric object that may be part of a scene graph.
A spatial object can have a parent object and child objects. Thus it can be placed in a tree structure which in most
cases is the scene graph.
Every spatial object has a root frame getRootFrame() that describes the position of the object in space.
Additionally objects can own any number of ObjectFrames that form a tree structure under the object's root
frame and determine the geometric structure of the object.
Spatial objects can optionally possess load data getLoadData() which allows to set mass, center of mass and
inertia of the object. Also optionally, it can possess information about the object's geometric form (
SpatialForm).
This class is thread-safe.
SpatialObjectUtils| Field Summary | |
|---|---|
static String |
PATH_SEPARATOR
Name separator for object path. |
| Constructor Summary | |
|---|---|
|
SpatialObject(String name)
Creates a new spatial object instance with given name. |
protected |
SpatialObject(String name,
String id)
Creates a new spatial object instance with given name. |
| Method Summary | |
|---|---|
void |
attachTo(ObjectFrame target)
Changes the parent of the objects root frame to the given frame and sets the transformation to Transformation.IDENTITY. |
void |
attachTo(ObjectFrame target,
Frame matchPosition)
Changes the parent of the objects root frame to the given frame and moves it to the matchingPosition in space. |
void |
attachTo(ObjectFrame target,
ITransformation rootDelta)
Changes the parent of objects root frame to the given frame and sets the given transformation. |
void |
attachWithCurrentPositionTo(ObjectFrame target)
Changes the parent of the objects root frame to the given frame and keeps the position in space of this object. |
ObjectFrame |
createFrame(String name,
IFrameConnection parentConnection)
Creates a new object frame that belongs to this object. |
ObjectFrame |
createFrame(String name,
ITransformation transformationFromParent)
Creates a new object frame that belongs to this object. |
ObjectFrame |
createFrame(String name,
ObjectFrame parent,
IFrameConnection parentConnection)
Creates a new object frame that belongs to this object. |
ObjectFrame |
createFrame(String name,
ObjectFrame parent,
ITransformation transformationFromParent)
Creates a new object frame that belongs to this object. |
ObjectFrame |
createFrameFrom(Frame source)
Creates a new object frame that belongs to this object. |
void |
detach()
Detaches the SpatialObject from its parent and sets this objects parent to null. |
protected SpatialObject |
findRootObject()
Searches the root SpatialObject in the object tree containing the element object. |
List<SpatialObject> |
getAllChildObjects()
Returns a list of all children of this object, plus all of the children's children and so on. |
List<ObjectFrame> |
getAllFrames()
Gets all frames belonging to this object. |
SpatialObject |
getChildObject(String path)
Gets the child object with the specified path. |
List<SpatialObject> |
getChildObjects()
Returns a list of all direct children of this object. |
ObjectFrame |
getDefaultMotionFrame()
Gets the current defaultMotionFrame. |
SpatialForm |
getForm()
Gets the spatial form of this object. |
ObjectFrame |
getFrame(String framePath)
Gets the object frame belonging to the object under the specified path. |
protected ReadWriteLock |
getFrameLock()
Returns a Lock object that can be used to lock all ObjectFrames owned by this SpatialObject. |
String |
getId()
Gets the attribute Id. |
LoadData |
getLoadData()
Gets the load data of this object. |
String |
getName()
Gets the name of the object. |
SpatialObject |
getParentObject()
Gets the parent of this object. |
ObjectFrame |
getRootFrame()
Gets the root frame of this object. |
Object |
getTag(String key)
Gets the data stored under the given key. |
IUserParameters |
getUserParameters()
Gets a collection of user parameters that belong to this object. |
boolean |
hasAncestor(SpatialObject obj)
Returns true if the given object is an ancestor (parent, grand parent, etc...) of this. |
boolean |
hasDescendant(SpatialObject obj)
Returns true if the given object is a descendant (child, grandchild, etc...) of this. |
IMotionContainer |
move(IMotion motion)
Moves this object according to the given motion. |
IMotionContainer |
move(IMotion motion,
IMotionContainerListener listener)
Moves this object according to the given motion. |
IMotionContainer |
moveAsync(IMotion motion)
Moves this object according to the given motion. |
IMotionContainer |
moveAsync(IMotion motion,
IMotionContainerListener listener)
Moves this frame according to the given motion. |
void |
removeForm()
Removes the spatial form from this object. |
void |
removeFrame(ObjectFrame frame)
Removes the specified object frame from the object and disconnects it from its parent frame. |
void |
setDefaultMotionFrame(ObjectFrame defaultMotionFrame)
Sets the defaultMotionFrame of the object. |
void |
setForm(SpatialForm form,
ObjectFrame reference)
Sets a spatial form for this object. |
protected void |
setId(String id)
Sets the attribute Id. |
void |
setLoadData(LoadData load)
Sets the load data of this object. |
void |
setName(String name)
Sets the name of the SpatialObject. |
void |
setTag(String key,
Object value)
Stores data under the given key. |
String |
toString()
|
protected SpatialObject |
tryGetChild(String path)
Gets the child object with the specified path. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String PATH_SEPARATOR
| Constructor Detail |
|---|
public SpatialObject(String name)
name - object name
protected SpatialObject(String name,
String id)
name - object nameuuid - object identification| Method Detail |
|---|
public String getName()
public ObjectFrame getRootFrame()
A spatial object always has a root frame (ObjectFrame) which cannot be removed.
This frame is the root of the frame tree that describes the geometric structure of the object. All frames owned
by this object (ObjectFrame.getOwner()) must be part of this tree.
public ObjectFrame createFrame(String name,
ITransformation transformationFromParent)
name - name of the new frame.transformationFromParent - transformation from this objects root frame to the new frame.
public ObjectFrame createFrame(String name,
ObjectFrame parent,
ITransformation transformationFromParent)
name - name of the new frame.parent - parent frame for the new frame. Parent frame must already belong to this object.transformationFromParent - transformation from the parent frame to the new frame.
public ObjectFrame createFrame(String name,
IFrameConnection parentConnection)
name - name of the new frame.parentConnection - frame connection that must provide the transformation from parent to the new frame.
public ObjectFrame createFrame(String name,
ObjectFrame parent,
IFrameConnection parentConnection)
name - name of the new frame.parent - parent frame for the new frame. Parent frame must already belong to this object.parentConnection - frame connection that must provide the transformation from parent to the new frame.
public ObjectFrame createFrameFrom(Frame source)
source - source frame
public void removeFrame(ObjectFrame frame)
frame - the frame to be removed.
IllegalArgumentException - in any of the following cases:
protected SpatialObject findRootObject()
SpatialObject in the object tree containing the element object.
SpatialObject of the object.
If the object does not have a parent, the object itself is returned.
IllegalArgumentException - if the given object is nullpublic ObjectFrame getFrame(String framePath)
For the following frame-chain path: ROOT->P1->P2
path looks like: /P1/P2
The leading forward slash is optional.
framePath - path to the frame
IllegalArgumentException - if no frame exists under the specified pathpublic List<ObjectFrame> getAllFrames()
public IUserParameters getUserParameters()
IUserParameterspublic SpatialObject getChildObject(String path)
path - path including name of the object to look for
IllegalArgumentException - if no object was found among the specified path and nameprotected SpatialObject tryGetChild(String path)
path - path including name of the object to look for
IllegalArgumentException - if no object was found among the specified path and namepublic List<SpatialObject> getChildObjects()
public List<SpatialObject> getAllChildObjects()
public SpatialObject getParentObject()
null if the object is the root object in a tree.public void setName(String name)
name - the new name to be set. May not be null or empty.
IllegalArgumentException - if the given name is null or empty
IllegalStateException - if another object under the same parent already has the given name. The name of this object remains
unchanged.protected ReadWriteLock getFrameLock()
ObjectFrames owned by this SpatialObject. Using
this lock, operations such as traversing frame trees, calculating connections between frames, adding child frames
etc. can be performed in a thread safe manner.
Note: this method only returns the Lock itself! This method does not perform any locking whatsoever. The actual locking will have to be performed by the caller on the returned lock object.
public LoadData getLoadData()
null if load data is not set.public void setLoadData(LoadData load)
load - the load data to be setpublic void attachTo(ObjectFrame target)
Transformation.IDENTITY.
This operation is only allowed if:
target - the new parent frame of this objects root frame
IllegalArgumentException - if any of the arguments is null
IllegalStateException - if the above conditions are not met
public void attachTo(ObjectFrame target,
ITransformation rootDelta)
target - the new parent frame of this objects root framerootDelta - the spatial transformation from the parent object to this object it is being attached to
IllegalArgumentException - if any of the arguments is null
IllegalStateException - if the above conditions are not met
public void attachTo(ObjectFrame target,
Frame matchPosition)
target - the new parent frame of this objects root framematchPosition - the position in space the object is moved to
IllegalArgumentException - if any argument is null, or if there is no connection or an unknown connection type
between the given matchPosition frame and this object's root frame
IllegalStateException - if the above conditions are not met, or if the relation between the involved frames could not be
determined
ThreadInterruptedException - if the thread was interrupted during execution. The thread interrupt flag will
be set if the thread was interrupted (that is, Thread.isInterrupted() will return
true)public void attachWithCurrentPositionTo(ObjectFrame target)
target - the new parent frame of this objects root frame
IllegalArgumentException - if the argument is null, or if there is no connection or an unknown connection type
between the given target frame and this object's root frame
IllegalStateException - if the above conditions are not met, or if the relation between the involved frames could not be
determined
ThreadInterruptedException - if the thread was interrupted during execution. The thread interrupt flag will
be set if the thread was interrupted (that is, Thread.isInterrupted() will return
true)public void detach()
public void setForm(SpatialForm form,
ObjectFrame reference)
form - the spatial form to be setreference - the reference frame for the form
IllegalArgumentException - if form or reference is null or reference doesn't belong to this object
IllegalStateException - if the reference frame of the form belongs to another object or if the form belongs already
to another objectpublic SpatialForm getForm()
public void removeForm()
public boolean hasDescendant(SpatialObject obj)
obj - the object for which to check whether it is a descendant of this
IllegalArgumentException - if the given object is nullpublic boolean hasAncestor(SpatialObject obj)
obj - the object for which to check whether it is an ancestor of this
IllegalArgumentException - if the given object is nullpublic String toString()
toString in class Objectpublic Object getTag(String key)
This 'tag' can be used to save additional information about the object and to retrieve it from the object.
key - The key. May not be null.
setTag(String, Object)
public void setTag(String key,
Object value)
This data can be retrieved later from the object.
key - The key. May not be null.value - The value. May not be null.getTag(String)public void setDefaultMotionFrame(ObjectFrame defaultMotionFrame)
DefaultMotionFrame can be set only once. If set a second time
IllegalStateException is thrown.
defaultMotionFrame - the default motion framepublic ObjectFrame getDefaultMotionFrame()
public IMotionContainer move(IMotion motion)
IMovable
The motion will be performed by a robot (or some other device) that should be found in the kinematic chain
between this frame and the world origin (or the destination of the specified motion). If such a robot is not
found - IllegalStateException will be thrown.
If the specified motion is a cartesian motion - it is this frame that will reach the destination and/or follow
the path defined by the motion. If the motion is joint specific - the motion directly affects the joints of the
robot connected with this frame.
move in interface IMovablemotion - the motion that should be executed
public IMotionContainer moveAsync(IMotion motion)
IMovable
The motion will be performed by a robot (or some other device) that should be found in the kinematic chain
between this frame and the world origin (or the destination of the specified motion). If such a robot is not
found - IllegalStateException will be thrown.
If the specified motion is a cartesian motion - it is this frame that will reach the destination and/or follow
the path defined by the motion. If the motion is joint specific - the motion directly affects the joints of the
robot connected with this frame.
This is an asynchronous call and will return immediately.
moveAsync in interface IMovablemotion - the motion that should be executed
public IMotionContainer move(IMotion motion,
IMotionContainerListener listener)
IMovable
The motion will be performed by a robot (or some other device) that should be found in the kinematic chain
between this frame and the world origin (or the destination of the specified motion). If such a robot is not
found - IllegalStateException will be thrown.
If the specified motion is a cartesian motion - it is this frame that will reach the destination and/or follow
the path defined by the motion. If the motion is joint specific - the motion directly affects the joints of the
robot connected with this frame.
move in interface IMovablemotion - the motion that should be executedlistener - listener for the motion container
public IMotionContainer moveAsync(IMotion motion,
IMotionContainerListener listener)
IMovable
The motion will be performed by a robot (or some other device) that should be found in the kinematic chain
between this frame and the world origin (or the destination of the specified motion). If such a robot is not
found - IllegalStateException will be thrown.
If the specified motion is a cartesian motion - it is this frame that will reach the destination and/or follow
the path defined by the motion. If the motion is joint specific - the motion directly affects the joints of the
robot connected with this frame.
This is an asynchronous call and will return immediately.
moveAsync in interface IMovablemotion - the motion that should be executedlistener - listener for the motion container
public String getId()
protected void setId(String id)
id - the value of attribute Id: unique identifier fulfilling XML naming requirements
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||