Simox  2.3.50
VirtualRobot::LinkedCoordinate Class Reference

This class provides intelligent coordinates for the virtual robot. More...

Public Member Functions

 LinkedCoordinate (const RobotPtr &virtualRobot)
 
 LinkedCoordinate (const LinkedCoordinate &other)
 
LinkedCoordinateoperator= (const LinkedCoordinate &other)
 
virtual ~LinkedCoordinate ()
 
void set (const RobotNodePtr &frame, const Eigen::Matrix4f &pose=Eigen::Matrix4f::Identity())
 
void set (const RobotNodePtr &frame, const Eigen::Vector3f &position)
 
void set (const std::string &frame, const Eigen::Matrix4f &pose=Eigen::Matrix4f::Identity())
 
void set (const std::string &frame, const Eigen::Vector3f &position)
 
RobotNodePtr getFrame () const
 
void changeFrame (const std::string &frame)
 
void changeFrame (const RobotNodePtr &frame)
 
Eigen::Matrix4f getInFrame (const std::string &frame) const
 
Eigen::Matrix4f getInFrame (const RobotNodePtr &frame) const
 
Eigen::Matrix4f getPose () const
 
Eigen::Vector3f getPosition () const
 

Static Public Member Functions

static Eigen::Matrix4f getCoordinateTransformation (const RobotNodePtr &origin, const RobotNodePtr &destination, const RobotPtr &robot)
 Computes the transformation matrix that represents a coordinate transformation. More...
 

Protected Attributes

RobotPtr robot
 
Eigen::Matrix4f pose
 
RobotNodePtr frame
 

Detailed Description

This class provides intelligent coordinates for the virtual robot.

The intelligent coordinates (and poses!) are connected to the virtual robot and are aware of the reference frame they have been defined in. In addition, they allow coordinate transformations using the current state of the robot.

Todo:

Let instances conveniently be created by RobotNode and Robot instances.

Look for convenient converter functions. For instance, QuaternionToMatrix4f.

Compile and design test cases. For instance, the transformation between to successing joints should be easy to confirm if there is a getTransformFromParent().

Check if the order of const and throw is okay.

Constructor & Destructor Documentation

VirtualRobot::LinkedCoordinate::LinkedCoordinate ( const RobotPtr virtualRobot)
inline

Creates a new intelligent coordinate.

Parameters
virtualRobotPointer to the virtual robot the coordinate is connected to.
LinkedCoordinate::LinkedCoordinate ( const LinkedCoordinate other)
LinkedCoordinate::~LinkedCoordinate ( )
virtual

Member Function Documentation

void LinkedCoordinate::changeFrame ( const std::string &  frame)

Sets a new reference frame and performs a coordinate transformation into this new frame.

Parameters
frameThe name of the robot node that defines the new reference.

If iCoord::set has not been called before, the pose is set to the unit marix.

void LinkedCoordinate::changeFrame ( const RobotNodePtr frame)

Sets a new reference frame and performs a coordinate transformation into this new frame.

Parameters
frameA reference to the robot node that defines the new reference.

If iCoord::set has not been called before, the pose is set to the unit marix.

Exceptions
VirtualRobotExceptionAn exception is thrown if frame is NULL.
Eigen::Matrix4f LinkedCoordinate::getCoordinateTransformation ( const RobotNodePtr origin,
const RobotNodePtr destination,
const RobotPtr robot 
)
static

Computes the transformation matrix that represents a coordinate transformation.

RobotNodePtr VirtualRobot::LinkedCoordinate::getFrame ( ) const
inline

Returns a RobotNodePtr that contains the frame of reference the coordinate is defined in.

Returns
The reference or an empty RobotNodePtr is none has been defined.

The actual matrix then can be obtained by calling RobotNode::getGlobalPose().

Eigen::Matrix4f LinkedCoordinate::getInFrame ( const std::string &  frame) const

Performs only a coordinate transformation into a new frame of reference.

Parameters
frameThe name of the robot node that defines the new reference.

If iCoord::set has not been called before, the pose is set to the unit marix.

Returns
A homogeneous matrix of the pose
See also
getPose()
Eigen::Matrix4f LinkedCoordinate::getInFrame ( const RobotNodePtr frame) const

Performs only a coordinate transformation into a new frame of reference.

Parameters
frameA reference to the robot node that defines the new reference.

If iCoord::set has not been called before, the pose is set to the unit marix.

Returns
A homogeneous matrix of the pose
See also
getPose()

If you are only interested in the translational part use iCoord::getPosition() or Matrix4f::block<3,1>(0,3).

Exceptions
VirtualRobotExceptionAn exception is thrown if frame is NULL.
Eigen::Matrix4f VirtualRobot::LinkedCoordinate::getPose ( ) const
inline

Returns the actual pose stored in this object.

If you are only interested in the translational part use iCoord::getPosition() or Matrix4f::block<3,1>(0,3).

Eigen::Vector3f VirtualRobot::LinkedCoordinate::getPosition ( ) const
inline

Conveniently returns the translational part of the actual pose stored in this object.

LinkedCoordinate & LinkedCoordinate::operator= ( const LinkedCoordinate other)
void LinkedCoordinate::set ( const RobotNodePtr frame,
const Eigen::Matrix4f &  pose = Eigen::Matrix4f::Identity() 
)

Sets the frame of reference and the pose relative to it.

Parameters
frameThe name of the robot node that defines the reference frame of the coordinate.
poseA homogeneous matrix that defines the pose relative to the frame of reference. If omitted, it defaults to the identity matrix.
Exceptions
VirtualRobotExceptionAn exception is thrown if frame does not belong to the robot or the reference is empty.

If you want to use a different format for the pose you can use these helper functions

See also
EulerToMatrix4x4 and
QuaternionsToMatrix4x4
void LinkedCoordinate::set ( const RobotNodePtr frame,
const Eigen::Vector3f &  position 
)

Sets the frame of reference and the coordinate relative to it.

Parameters
frameThe name of the robot node that defines the reference frame of the coordinate.
positionA translational vector defines the position relative to the frame of reference.
Exceptions
VirtualRobotExceptionAn exception is thrown if frame does not belong to the robot.

A homogeneous vector can be converted using Eigen::Vector4f::head<3>().

void LinkedCoordinate::set ( const std::string &  frame,
const Eigen::Matrix4f &  pose = Eigen::Matrix4f::Identity() 
)

Sets the frame of reference and the pose relative to it.

Parameters
frameThe name of the robot node that defines the reference frame of the coordinate.
poseA homogeneous matrix that defines the pose relative to the frame of reference. If omitted, it defaults to the identity matrix.
Exceptions
VirtualRobotExceptionAn exception is thrown if frame does not belong to the robot or the reference is empty.
See also
set(Eigen::Matrix4x4,const RobotNodePtr &)
void LinkedCoordinate::set ( const std::string &  frame,
const Eigen::Vector3f &  position 
)

Sets the frame of reference and the coordinate relative to it.

Parameters
frameThe name of the robot node that defines the reference frame of the coordinate.
positionThe pose relative to the frame of reference.
Exceptions
VirtualRobotExceptionAn exception is thrown if frame does not belong to the robot.

A homogeneous vector can be previously converted using Eigen::Vector4f::head<3>().

Field Documentation

RobotNodePtr VirtualRobot::LinkedCoordinate::frame
protected
Eigen::Matrix4f VirtualRobot::LinkedCoordinate::pose
protected
RobotPtr VirtualRobot::LinkedCoordinate::robot
protected