cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Static Protected Attributes | Friends | List of all members
prmTransformationManager Class Reference

#include <prmTransformationManager.h>

Inheritance diagram for prmTransformationManager:
cmnGenericObject

Public Types

typedef std::list
< prmTransformationBasePtr
NodeListType
 

Static Public Member Functions

static void Clear ()
 
static bool NodeCreatesCycle (const prmTransformationBasePtr &attachPoint, const prmTransformationBasePtr &newFrame)
 
static bool NodeCreatesCycle (const std::string &pName, const prmTransformationBasePtr &newFrame)
 
static vctFrm3 WRTReference (const prmTransformationBasePtr &tipFrame, const prmTransformationBasePtr &refFrame)
 
static unsigned int ReplaceReference (const prmTransformationBasePtr &nodePtr, const prmTransformationBasePtr &newReference)
 
static unsigned int ReplaceReference (const prmTransformationBasePtr &nodePtr, const std::string &parentName)
 
static void ToStreamDot (std::ostream &outputStream)
 
static void ToStreamDotHelper (std::ostream &outputStream, prmTransformationBasePtr parent)
 
static bool FindPath (const prmTransformationBasePtr &target, const prmTransformationBasePtr &reference)
 
static bool FindPathConnectedTree (const prmTransformationBasePtr &target, const prmTransformationBasePtr &reference)
 
static prmTransformationBasePtr GetTransformationNodePtr (const std::string pName)
 
static void PathToStreamDot (std::ostream &outputStream)
 

Static Public Attributes

static prmTransformationFixed TheWorld
 

Static Protected Member Functions

static bool Attach (const prmTransformationBasePtr &attachPoint, const prmTransformationBasePtr &newFrame)
 
static bool Attach (const std::string &parentName, const prmTransformationBasePtr &newFrame)
 
static bool Detach (const prmTransformationBasePtr &frame)
 

Static Protected Attributes

static NodeListType Path
 
static NodeListType VisitedNodes
 
static NodeListType VisitedNodes2
 

Friends

class prmTransformationBase
 

Detailed Description

This class is intended to support computation of relationships between different coordinate systems in a CIS system. The tree consists of nodes (various coordinate systems ) and the edges (static or dynamic transformations between the connected coordinate systems). Transformations between coordinate systems are retrieved using a user provided command.

See Also
mtsCommandRead.

Examples:

setup joints transformation vctFrm3 setupPos; setupPos.Translation() = vct3(10.0, 4.0, 3.0); prmTransformationFixed setupFrame("Setup frame", setupPos);

robot transformation prmTransformationDynamic robotFrame("Robot frame", setupFrame, robot.GetCommandRead("GetTipPosition"));

add a camera defined in world frame vctFrm3 cameraPos; cameraPos.Translation() = vct3(-10.0, 3.4, 5.34); vctRandom(cameraPos.Rotation()); // artificial move! prmTransformationFixed cameraFrame("Camera frame", cameraPos);

Get the position of the camera wrt to the robot std::cout << prmWRTReference(cameraFrame, robotFrame) << std::endl;

Compute the robot motion wrt its base so that the tip moves in the x direction of the camera. vctFrm3 moveWRTCamera; PositionCartesianArg goalArgs;

move.Translation() = vct3(1.0, 0.0, 0.0); vctFrm3 moveWRTRobot = prmWRTReference(cameraFrame, setupFrame) * move; goalArgs.SetGoal(moveWRTRobot); myRobot.MovePositionCart(goalArgs);

Note
There can only be one transformation manager per application, hence this class is implemented as a singleton.

Member Typedef Documentation

Member Function Documentation

static bool prmTransformationManager::Attach ( const prmTransformationBasePtr attachPoint,
const prmTransformationBasePtr newFrame 
)
staticprotected

Add the frame to the tree in the transformation manager. This method is private and can only be accessed by the "friend" class prmTransformationBase.

Parameters
attachPointprmTransformationBasePtr pointer to the new frame
newFrameprmTransformationBasePtr pointer to parent in the tree
Returns
bool success/failure boolean status.
static bool prmTransformationManager::Attach ( const std::string &  parentName,
const prmTransformationBasePtr newFrame 
)
staticprotected
static void prmTransformationManager::Clear ( )
static

A method to clean up a transformation tree. Deletes all nodes and restores clean state. This should never need to be used as every node should attach or detach itself. It is primarily meant for testing and debugging purposes.

static bool prmTransformationManager::Detach ( const prmTransformationBasePtr frame)
staticprotected

Remove the frame from the tree Internally calls ReplaceReference(frame, theWorld).

Parameters
frameprmTransformationBase* pointer to the frame to be discarded.
Returns
bool success/failure code (When do we define status codes?)
static bool prmTransformationManager::FindPath ( const prmTransformationBasePtr target,
const prmTransformationBasePtr reference 
)
static

Helper function for computing transformations. Traverses the tree and stores the path between target and reference in path

Returns
bool true if path exists
static bool prmTransformationManager::FindPathConnectedTree ( const prmTransformationBasePtr target,
const prmTransformationBasePtr reference 
)
static

Helper function for computing transformations. In contrast to above, this assumes a path exists and only merges two traversals from target/reference to tree root

Returns
bool true if path exists
static prmTransformationBasePtr prmTransformationManager::GetTransformationNodePtr ( const std::string  pName)
static

Helper function for attaching with names

static bool prmTransformationManager::NodeCreatesCycle ( const prmTransformationBasePtr attachPoint,
const prmTransformationBasePtr newFrame 
)
static

Test if attaching a reference frame at a particular node will introduce a circular dependency. The implementation is a simple depth first search, that returns true if a node is revisited more than once.

Parameters
attachPointprmTransformationBasePr new parent
newFrameprmTransformationBasePtr candidate frame
Returns
bool true if a newFrame node is already present in the tree AND is an ancestor of the attachPoint.
static bool prmTransformationManager::NodeCreatesCycle ( const std::string &  pName,
const prmTransformationBasePtr newFrame 
)
static
static void prmTransformationManager::PathToStreamDot ( std::ostream &  outputStream)
static

Print the path for last reference computation to a graphviz dot file

Returns
void
static unsigned int prmTransformationManager::ReplaceReference ( const prmTransformationBasePtr nodePtr,
const prmTransformationBasePtr newReference 
)
static

Update all frames using a given frame as reference.

May be useful before a call to prmTransformationManager::Detach or its equivalent prmTransformationBase::~prmTransformationBase

Parameters
currentReferenceprmTransformationBase* old Reference frame
newReferenceprmTransformationBase* new Reference frame
Returns
number of frames modified.
static unsigned int prmTransformationManager::ReplaceReference ( const prmTransformationBasePtr nodePtr,
const std::string &  parentName 
)
static
static void prmTransformationManager::ToStreamDot ( std::ostream &  outputStream)
static

Print the tree to a graphviz dot file

If you have graphviz then "dot -Tjpg -o tree.jpg tree.dot" where tree.dot is the output of this function will print a tree representation of the transformation tree.

Parameters
outputStreamstd::ostream stream to dump dot file
Returns
void
static void prmTransformationManager::ToStreamDotHelper ( std::ostream &  outputStream,
prmTransformationBasePtr  parent 
)
static

Helper function for printing the tree to a graphviz dot file

Returns
void
static vctFrm3 prmTransformationManager::WRTReference ( const prmTransformationBasePtr tipFrame,
const prmTransformationBasePtr refFrame 
)
static

Compute the transformation between two frames (WRT = With Respect To). The computation will use registered get mtsCommandRead methods for the nodes on the path from node refFrame to node tipFrame. The implementation is a breadth first search from refFrame to tipFrame.

Parameters
tipFrameprmTransformationBasePtr the frame transform to be computed
refFrameprmTransformationBasePtr the reference frame chosen
Returns
vctFrame3 homogenous transform representing current relationship between tipFrame and refFrame.

Friends And Related Function Documentation

friend class prmTransformationBase
friend

Member Data Documentation

NodeListType prmTransformationManager::Path
staticprotected

List of modes on the last transformation computed.

prmTransformationFixed prmTransformationManager::TheWorld
static

Frame used as reference for all other frames, root of the tree. All other frames are attached/detached by application code.

NodeListType prmTransformationManager::VisitedNodes
staticprotected

Tree traversal helper

NodeListType prmTransformationManager::VisitedNodes2
staticprotected

The documentation for this class was generated from the following file: