AUTh-ARL Core Stack  0.7
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
arl::robot::Model Class Reference

Defines an abstract model for a robot storing information like DOFs, kinematics etc. More...

#include <model.h>

Inheritance diagram for arl::robot::Model:

Public Member Functions

 Model ()
 An empty constructor. More...
 
 Model (const std::string &n)
 A basic constructor parsing the name of the model. More...
 
std::string getName ()
 Returns the name of the model. More...
 
unsigned int getNrOfChains ()
 Returns the total number of the chains of the model. More...
 
unsigned int getNrOfMainChains ()
 Returns the number of the main chains of the model. More...
 
std::string getChainName (unsigned int chain)
 Returns the name of a chain. More...
 
std::vector< std::string > getChainNames ()
 Returns the names of every chain of the model. More...
 
unsigned int getNrOfJoints ()
 Returns the total number of the joints (total DOFs) of the robot model. More...
 
unsigned int getNrOfJoints (int chain)
 Returns the number of the joints of a specific chain. More...
 
std::vector< std::string > getJointNames ()
 Returns the names of total joints of the robot model. More...
 
std::vector< std::string > getJointNames (unsigned int chain)
 Returns the names of joints of one chain. More...
 
std::string getJointName (unsigned int joint)
 Returns the name of a joint of the whole robot. More...
 
std::string getJointName (unsigned int chain, unsigned int joint)
 Returns the name of a joint existing in a given chain. More...
 
std::pair< double, double > getJointLimit (unsigned int chain, unsigned int joint)
 Returns the limit of a joint existing in a given chain. More...
 
double getJointVelocityLimit (unsigned int joint)
 Returns the velocity limit of a joint existing in the complete list joints. More...
 
std::pair< double, double > getJointLimit (unsigned int joint)
 Returns the limit of a joint existing in the complete list joints. More...
 
std::vector< std::pair< double,
double > > 
getJointLimits (unsigned int chain)
 Returns the limits of joints of one chain. More...
 
unsigned int getGlobalIndex (int chain, unsigned int joint)
 Returns the index of a joint existing in a given main chain. This index is out of the total main joints of the robot. More...
 
std::vector< std::pair< double,
double > > 
getJointLimits ()
 Returns the limits of total joints of the robot model. More...
 
void test ()
 Tests if a model has initialized properly. Call it in your implemented derived class constructor. More...
 

Public Attributes

std::map< std::string, int > chain_index
 
std::vector
< KDL::ChainFkSolverPos_recursive > 
fk_solver
 A number of KDL forward kinematic solvers, one for each chain. More...
 
std::vector
< KDL::ChainJntToJacSolver > 
jac_solver
 A number of KDL Jacobian solvers, one for each chain. Calculates the base Jacobian matrix of the chain. More...
 
std::vector< KDL::Chain > chain
 A number of KDL Chains storing the kinematics of each chain. More...
 

Protected Attributes

std::vector< std::vector
< unsigned int > > 
global_index
 An array storing the global indeces. Should be filled by every model which derives from this class. More...
 
std::string name
 The name of this Model. More...
 
unsigned int num_chains_exclusive
 The number of the mutually exclusive chains. More...
 
std::vector< std::string > chain_name
 The names of the chains of this Model. More...
 
std::vector< std::vector
< std::string > > 
joint_name
 The joint names of this Model. More...
 
std::vector< std::pair< double,
double > > 
joint_limit
 The joint limits of this Model. More...
 
std::vector< double > velocity_limit
 The joint velocity limits of this Model. More...
 
std::vector< std::vector
< std::string > > 
link_name
 The link names of this Model. More...
 

Detailed Description

Defines an abstract model for a robot storing information like DOFs, kinematics etc.

The Model of a robot contains the following things:

  • A number of kinematic chains. For example a bimanual robot can have two main chains which are the two arms and a number of other chains. The other chains could be chains from the base of the robot to each joint which can be utilized for reading the Cartesian pose of the each joint in real time.
  • The number of the main chains. As main chains we define the chains which do not share any common joints between them and also the sum of their joints are the total number of dinstict DOFs of the robot. In the bimanual arm example these are the two arms of the robot.
  • The names of the chains and their joints. The convention is that we store firstly the main chains and then the rest of the chains. If for example a model has 10 chains and 3 main chains, the indeces 0, 1, 2 denote the three main chains.
  • The kinematics of each chain stored as KDL::Chain.
  • Forward and inversed kinematics solvers for calculating FKs and Jacobian matrices

A class which derives from Model should always define the following:

  • The number of the main chains
  • The names of each chain. First the names of the main chains and then the rest of them.
  • The names of each joint of each chain.
  • Fill the global indecies (global_index) array

A class which derives from Model could define, if desired, the following:

  • The kinematic chains as KDL::Chains
  • The Forward Kinematic solvers
  • Jacobian and Inverse Kinematic solvers

Upon availability of a URDF model of the robot someone can parse the URDF to Model class.

Constructor & Destructor Documentation

arl::robot::Model::Model ( )

An empty constructor.

arl::robot::Model::Model ( const std::string &  n)
explicit

A basic constructor parsing the name of the model.

Member Function Documentation

std::string arl::robot::Model::getChainName ( unsigned int  chain)

Returns the name of a chain.

Attention
In case it is given a non-existent chain for this robot model, this function will return an empty string and it will print a ROS_ERROR.
Parameters
chainThe desired chain
Returns
The name of the chain
See Also
getChainNames()

Here is the call graph for this function:

std::vector< std::string > arl::robot::Model::getChainNames ( )

Returns the names of every chain of the model.

Returns
The names of the chains
See Also
getChainName(int chain)
unsigned int arl::robot::Model::getGlobalIndex ( int  chain,
unsigned int  joint 
)

Returns the index of a joint existing in a given main chain. This index is out of the total main joints of the robot.

Parameters
chainThe chain of the desired joint
jointThe desired joint
Returns
The index of the joint

Here is the call graph for this function:

std::pair< double, double > arl::robot::Model::getJointLimit ( unsigned int  chain,
unsigned int  joint 
)

Returns the limit of a joint existing in a given chain.

The following call will return a pair containing the lower and upper limit of the 2nd joint of the 3rd chain:

limit = model.getJointLimit(2, 3);
Attention
In case it is given a non-existent joint/chain combination for this robot model, this function will return a pair with first value -M_PI and second value M_PI and it will print a ROS_ERROR.
Parameters
chainThe chain of the desired joint
jointThe desired joint
Returns
The limit of the joint
See Also
getJointLimit(unsigned int)
getJointLimits(unsigned int)
getJointLimits()

Here is the call graph for this function:

std::pair< double, double > arl::robot::Model::getJointLimit ( unsigned int  joint)

Returns the limit of a joint existing in the complete list joints.

This means that needs to be given an index from the total number of joints of this model as given by Model::getNrOfJoints().

Attention
Returns a pair of nan values with a ROS error in case of a non existing joint/chain combination.
Returns a pair of -pi, pi values with a ROS warning in case of an undefined existing joint/chain combination.
Parameters
jointThe desired joint
Returns
The limit of the joint
See Also
getJointLimit(unsigned int, unsigned int)
getJointLimits(unsigned int)
getJointLimits()
getNrOfJoints()

Here is the call graph for this function:

std::vector< std::pair< double, double > > arl::robot::Model::getJointLimits ( unsigned int  chain)

Returns the limits of joints of one chain.

Returns the limits of the joints of the one chain of the robot as a standard vector of pairs (min, max). The size of this vector will match the output of Model::getNrOfJoints(unsigned int chain).

Attention
In case it is given a non-existent chain it will print a ROS_ERROR and returns a pair of nan values.
Parameters
chainThe desired chain
Returns
The limits of the joints
See Also
getJointLimit(unsigned int, unsigned int)
getJointLimit(unsigned int)
getJointLimits()
getNrOfJoints(unsigned int)

Here is the call graph for this function:

std::vector< std::pair< double, double > > arl::robot::Model::getJointLimits ( )

Returns the limits of total joints of the robot model.

Returns the limits of the joints of the whole robot as a standard vector of pairs (min, max). The size of this vector will match the output of Model::getNrOfJoints(). The sequence of the limits will follow the sequence of the joints and the sequence of the mutually exclusive chains stored in this Model.

Returns
The limits of the joints of the robot.
See Also
getJointLimit(unsigned int, unsigned int)
getJointLimit(unsigned int)
getJointLimits(unsigned int)
getNrOfJoints()

Here is the call graph for this function:

std::string arl::robot::Model::getJointName ( unsigned int  joint)

Returns the name of a joint of the whole robot.

This means that needs to be given an index from the total number of joints of this model as given by Model::getNrOfJoints().

Attention
Returns an empty string with a ROS error in case of a non existing joint.
Parameters
jointThe desired joint
Returns
The name of the joint
See Also
getJointName(unsigned int)
getJointName(unsigned int)
getJointNames(unsigned int)
getNrOfJoints()

Here is the call graph for this function:

std::string arl::robot::Model::getJointName ( unsigned int  chain,
unsigned int  joint 
)

Returns the name of a joint existing in a given chain.

The following call will return the name of the 2nd joint of the 3rd chain:

name = model.getJointName(2, 3);
Attention
In case it is given a non-existent joint/chain combination for this robot model, this function will return 0 and it will print a ROS_ERROR.
Parameters
chainThe chain of the desired joint
jointThe desired joint
Returns
The name of the joint
See Also
getJointName(unsigned int)
getJointNames(unsigned int)
getJointNames()

Here is the call graph for this function:

std::vector< std::string > arl::robot::Model::getJointNames ( )

Returns the names of total joints of the robot model.

Returns the names of the joints of the whole robot as a standard vector of strings. The size of this vector will match the output of Model::getNrOfJoints(). The sequence of the names will follow the sequence of the joints and the sequench of the mutually exclusive chains stored in this Model.

Returns
The names of the joint of the robot.
See Also
getJointName(unsigned int)
getJointName(unsigned int)
getJointNames(unsigned int)
getNrOfJoints()
std::vector< std::string > arl::robot::Model::getJointNames ( unsigned int  chain)

Returns the names of joints of one chain.

Returns the names of the joints of the one chain of the robot as a standard vector of strings. The size of this vector will match the output of Model::getNrOfJoints(unsigned int chain).

Attention
In case it is given a non-existent chain it will print a ROS_ERROR and returns an empty string.
Parameters
chainThe desired chain
Returns
The name of the joints
See Also
getJointName(unsigned int)
getJointName(unsigned int)
getJointNames(unsigned int)
getNrOfJoints()

Here is the call graph for this function:

double arl::robot::Model::getJointVelocityLimit ( unsigned int  joint)

Returns the velocity limit of a joint existing in the complete list joints.

This means that needs to be given an index from the total number of joints of this model as given by Model::getNrOfJoints().

Parameters
jointThe desired joint
Returns
The velocity limit of the joint
std::string arl::robot::Model::getName ( )

Returns the name of the model.

Returns
The name of the model
unsigned int arl::robot::Model::getNrOfChains ( )

Returns the total number of the chains of the model.

Returns
The number of the chains
unsigned int arl::robot::Model::getNrOfJoints ( )

Returns the total number of the joints (total DOFs) of the robot model.

As the total number of the main chains, i.e. all the distinct joints of this model because some models may have multiple chains which share joints between them.

Returns
The total number of the joints of the robot
See Also
getNrOfJoints(unsigned int)
unsigned int arl::robot::Model::getNrOfJoints ( int  chain)

Returns the number of the joints of a specific chain.

Attention
In case it is given a non-existent chain for this robot model it will return zero and it will print a ROS_ERROR in the console.
Parameters
chainThe index of the kinematic chain
Returns
The number of the joints
See Also
getNrOfJoints()

Here is the call graph for this function:

unsigned int arl::robot::Model::getNrOfMainChains ( )

Returns the number of the main chains of the model.

Returns
The number of the main chains
void arl::robot::Model::test ( )

Tests if a model has initialized properly. Call it in your implemented derived class constructor.

Here is the call graph for this function:

Member Data Documentation

std::vector<KDL::Chain> arl::robot::Model::chain

A number of KDL Chains storing the kinematics of each chain.

std::map<std::string, int> arl::robot::Model::chain_index
std::vector<std::string> arl::robot::Model::chain_name
protected

The names of the chains of this Model.

The joint names as a tandard vector of strings. For example the chain_name.at(2) should contain the name of the 2nd chain of the model

Attention
It is of paramount importance to be filled by any class which inherits from Model, because other function depends on the consistency of this variable. It should contain the name of every chain that the model defines.
std::vector<KDL::ChainFkSolverPos_recursive> arl::robot::Model::fk_solver

A number of KDL forward kinematic solvers, one for each chain.

std::vector<std::vector<unsigned int> > arl::robot::Model::global_index
protected

An array storing the global indeces. Should be filled by every model which derives from this class.

std::vector<KDL::ChainJntToJacSolver> arl::robot::Model::jac_solver

A number of KDL Jacobian solvers, one for each chain. Calculates the base Jacobian matrix of the chain.

std::vector<std::pair<double, double> > arl::robot::Model::joint_limit
protected

The joint limits of this Model.

The joint limit as a standard vector of double pairs. For example the joint_limit.at(1).first should contain the lower (min) limit of the 2nd joint of the robot (considered as global index) of the whereas limit.at(2).second should contain the upper (max) limit of the same joint.

Attention
It is of paramount importance to be filled by any class which inherits from Model, because other function depends on the consistency of this variable. It should contain the lower and upper joint limits of every joint of every chain that the model defines.
std::vector<std::vector<std::string> > arl::robot::Model::joint_name
protected

The joint names of this Model.

The joint names as a 2D standard vector of strings. For example the joint_name.at(1).at(2) should contain the name of the 2nd joint of the 1st defined chain.

Attention
It is of paramount importance to be filled by any class which inherits from Model, because other function depends on the consistency of this variable. It should contain the name of every joint of every chain that the model defines.
std::vector<std::vector<std::string> > arl::robot::Model::link_name
protected

The link names of this Model.

The link names as a 2D standard vector of strings. For example the link_name.at(1).at(2) should contain the name of the 2nd link of the 1st defined chain.

std::string arl::robot::Model::name
protected

The name of this Model.

The name as a standard string. It should be filled by any class which inherits from Model.

unsigned int arl::robot::Model::num_chains_exclusive
protected

The number of the mutually exclusive chains.

Mutually exclusive chains will not share common joints between them. The mutually exclussive chains are a subset of the total chains of the model. For instance a class which inherits from Model and defines a model for the 7DOF KUKA LWR4+ arm can have 1 chain which is exclusive and contains the 7 joints and a number of other chains depended on the usage of the class. The rest of the chains can be 7 other chains from the base of the robot to each joint of the robot and can be used for example in order to have the task pose of each joint of the robot. A robot with two arms can have two mutually exclusive chains (the two arms) or a robotic hand can have a number of mutually exclusive chains equal to its fingers.

Attention
It is of paramount importance to be filled by any class which inherits from Model, because other function depends on the consistency of this variable.
std::vector<double> arl::robot::Model::velocity_limit
protected

The joint velocity limits of this Model.

The joint limit as a standard vector of double. For example the velocity_limit.at(i) contains the speed limit of the joint i, and with i a global joint index

Attention
It is of paramount importance to be filled by any class which inherits from Model, because other function depends on the consistency of this variable.