ORCA: Optimization-based framework for Robotic Control Applications
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
orca::robot::RobotModel Class Reference

The robot model class allow to make kinematics and dynamics computations. More...

#include <RobotModel.h>

+ Inheritance diagram for orca::robot::RobotModel:
+ Collaboration diagram for orca::robot::RobotModel:

Public Types

using Ptr = std::shared_ptr< RobotModel >
 
- Public Types inherited from orca::common::ConfigurableOrcaObject
using Ptr = std::shared_ptr< ConfigurableOrcaObject >
 
using ParamMap = std::map< std::string, ParameterBase *>
 

Public Member Functions

 RobotModel (const std::string &name="")
 The default constructor. More...
 
virtual ~RobotModel ()
 
bool loadModelFromFile (const std::string &modelFile)
 Load the model from an absolute urdf file path. More...
 
bool loadModelFromString (const std::string &modelString)
 Load the model from a full urdf string (xacro not supported) More...
 
const std::string & getUrdfUrl () const
 Get the file url if it was loaded from a file. Empty string otherwise. More...
 
const std::string & getUrdfString () const
 Get the urdf expanded string used to build the model. More...
 
void setRobotState (const Eigen::Matrix4d &world_H_base, const Eigen::VectorXd &jointPos, const Eigen::Matrix< double, 6, 1 > &baseVel, const Eigen::VectorXd &jointVel, const Eigen::Vector3d &gravity)
 Set the complete robot state. More...
 
void setRobotState (const Eigen::VectorXd &jointPos, const Eigen::VectorXd &jointVel, const Eigen::Vector3d &global_gravity_vector)
 Set the partial robot state. More...
 
void setRobotState (const Eigen::VectorXd &jointPos, const Eigen::VectorXd &jointVel)
 Set the partial robot state. Useful for fixed based robots. More...
 
const std::string & getName () const
 Returns the name of the robot, either provided via constructor or extracted from the urdf is no name is provided. More...
 
void print () const
 Print information about the model to cout. More...
 
void setBaseFrame (const std::string &fixed_base_or_free_floating_frame)
 Set the base frame / the free-floating frame that attaches the robot to the world frame For a humanoid it would be generally somewhere in the hips. For a fixed based robot it would be the frame between the robot and the table. This frame is also the frame of reference for the jacobians, transforms etc when refFrameName is not specified. More...
 
const std::string & getBaseFrame () const
 Returns the base/free-floating frame. More...
 
void setGravity (const Eigen::Vector3d &global_gravity_vector)
 Return the global gravity vector. More...
 
unsigned int getNrOfDegreesOfFreedom () const
 Return the number of actuated joints. More...
 
unsigned int getConfigurationSpaceDimension () const
 Returns the number of DOF + Free floating DOF (6) More...
 
bool frameExists (const std::string &frame_name) const
 Returns true is the frame exists on the model. More...
 
const Eigen::Matrix4d & getRelativeTransform (const std::string &refFrameName, const std::string &frameName)
 Get the transform (or pose) between a frame to another. More...
 
const Eigen::Matrix4d & getTransform (const std::string &frameName)
 Get the transform of a frame w.r.t the base frame. More...
 
bool addAdditionalFrameToLink (const std::string &linkName, const std::string &frameName, const Eigen::Matrix4d &link_H_frame)
 Add an extra frame to a link. This re-creates the whole model, so it should not be used on the control loop. More...
 
const Eigen::Matrix< double, 6, 1 > & getFrameVel (const std::string &frameName)
 
const Eigen::Matrix< double, 6, 1 > & getFrameBiasAcc (const std::string &frameName)
 
const Eigen::MatrixXd & getFreeFloatingMassMatrix ()
 
const Eigen::MatrixXd & getMassMatrix ()
 
const Eigen::VectorXd & getJointPos () const
 
const Eigen::VectorXd & getJointVel () const
 
const Eigen::VectorXd & getMinJointPos ()
 
const Eigen::VectorXd & getMaxJointPos ()
 
const Eigen::MatrixXd & getJacobian (const std::string &frameName)
 
const Eigen::MatrixXd & getRelativeJacobian (const std::string &refFrameName, const std::string &frameName)
 
const Eigen::MatrixXd & getFrameFreeFloatingJacobian (const std::string &frameName)
 
const Eigen::VectorXd & generalizedBiasForces ()
 
const Eigen::VectorXd & getJointGravityTorques ()
 
const Eigen::VectorXd & getJointCoriolisTorques ()
 
const Eigen::VectorXd & getJointGravityAndCoriolisTorques ()
 
unsigned int getNrOfJoints () const
 
std::string getJointName (unsigned int idx) const
 
unsigned int getJointIndex (const std::string &jointName) const
 
const std::vector< std::string > & getLinkNames () const
 
const std::vector< std::string > & getFrameNames () const
 
const std::vector< std::string > & getJointNames () const
 
bool isInitialized () const
 
void onRobotInitializedCallback (std::function< void(void)> cb)
 
- Public Member Functions inherited from orca::common::ConfigurableOrcaObject
 ConfigurableOrcaObject (const std::string &config_name)
 
virtual ~ConfigurableOrcaObject ()
 
template<class T >
void addParameter (const std::string &param_name, Parameter< T > *param, ParamPolicy policy=ParamPolicy::Required, std::function< void()> on_loading_success=0)
 Returns true if all params added with have been set. More...
 
template<class T >
void addParameter (const std::string &param_name, T &param, ParamPolicy policy=ParamPolicy::Required, std::function< void()> on_loading_success=0)
 
ParameterBasegetParameter (const std::string &param_name)
 Returns a param via its name. More...
 
void printParameters () const
 Print all parameters to std::cout. More...
 
bool configureFromFile (const std::string &yaml_url)
 Configure the task from YAML/JSON file. It must contain all the required parameters. More...
 
bool configureFromString (const std::string &yaml_str)
 Configure the task from YAML/JSON string. It must contain all the required parameters. More...
 
bool isConfigured () const
 
const ParamMapgetParameters () const
 
void onConfigureSuccess (std::function< void()> f)
 
- Public Member Functions inherited from orca::common::OrcaObject
 OrcaObject (const std::string &name)
 
virtual ~OrcaObject ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 

Protected Types

enum  RobotModelImplType { iDynTree, KDL }
 

Protected Member Functions

bool loadFromParameters ()
 

Protected Attributes

RobotModelImplType robot_kinematics_type_ = iDynTree
 
std::function< void(void)> robot_initialized_cb_
 
bool is_initialized_ = false
 
common::Parameter< std::string > urdf_url_
 
common::Parameter< std::string > urdf_str_
 
common::Parameter< std::string > base_frame_
 
common::Parameter< Eigen::Vector3d > gravity_
 
common::Parameter< Eigen::VectorXd > home_joint_positions_
 
common::Parameter< std::string > name_
 

Detailed Description

The robot model class allow to make kinematics and dynamics computations.

Member Typedef Documentation

◆ Ptr

using orca::robot::RobotModel::Ptr = std::shared_ptr<RobotModel>

Member Enumeration Documentation

◆ RobotModelImplType

Enumerator
iDynTree 
KDL 

Constructor & Destructor Documentation

◆ RobotModel()

RobotModel::RobotModel ( const std::string &  name = "")

The default constructor.

Parameters
nameYou can explicitely give it a name, otherwise it will be extracted from the urdf

◆ ~RobotModel()

RobotModel::~RobotModel ( )
virtual

Member Function Documentation

◆ addAdditionalFrameToLink()

bool RobotModel::addAdditionalFrameToLink ( const std::string &  linkName,
const std::string &  frameName,
const Eigen::Matrix4d &  link_H_frame 
)

Add an extra frame to a link. This re-creates the whole model, so it should not be used on the control loop.

Parameters
linkNameThe link from which you want to attach a new frame
frameNameThe new frame
link_H_frameThe transform between the link to the frame
Returns
bool

◆ frameExists()

bool RobotModel::frameExists ( const std::string &  frame_name) const

Returns true is the frame exists on the model.

Parameters
frame_nameThe test frame
Returns
bool

◆ generalizedBiasForces()

const Eigen::VectorXd & RobotModel::generalizedBiasForces ( )

◆ getBaseFrame()

const std::string & RobotModel::getBaseFrame ( ) const

Returns the base/free-floating frame.

Returns
const std::string&

◆ getConfigurationSpaceDimension()

unsigned int RobotModel::getConfigurationSpaceDimension ( ) const

Returns the number of DOF + Free floating DOF (6)

Returns
unsigned int

◆ getFrameBiasAcc()

const Eigen::Matrix< double, 6, 1 > & RobotModel::getFrameBiasAcc ( const std::string &  frameName)

◆ getFrameFreeFloatingJacobian()

const Eigen::MatrixXd & RobotModel::getFrameFreeFloatingJacobian ( const std::string &  frameName)

◆ getFrameNames()

const std::vector< std::string > & RobotModel::getFrameNames ( ) const

◆ getFrameVel()

const Eigen::Matrix< double, 6, 1 > & RobotModel::getFrameVel ( const std::string &  frameName)

◆ getFreeFloatingMassMatrix()

const Eigen::MatrixXd & RobotModel::getFreeFloatingMassMatrix ( )

◆ getJacobian()

const Eigen::MatrixXd & RobotModel::getJacobian ( const std::string &  frameName)

◆ getJointCoriolisTorques()

const Eigen::VectorXd & RobotModel::getJointCoriolisTorques ( )

◆ getJointGravityAndCoriolisTorques()

const Eigen::VectorXd & RobotModel::getJointGravityAndCoriolisTorques ( )

◆ getJointGravityTorques()

const Eigen::VectorXd & RobotModel::getJointGravityTorques ( )

◆ getJointIndex()

unsigned int RobotModel::getJointIndex ( const std::string &  jointName) const

◆ getJointName()

std::string RobotModel::getJointName ( unsigned int  idx) const

◆ getJointNames()

const std::vector< std::string > & RobotModel::getJointNames ( ) const

◆ getJointPos()

const Eigen::VectorXd & RobotModel::getJointPos ( ) const

◆ getJointVel()

const Eigen::VectorXd & RobotModel::getJointVel ( ) const

◆ getLinkNames()

const std::vector< std::string > & RobotModel::getLinkNames ( ) const

◆ getMassMatrix()

const Eigen::MatrixXd & RobotModel::getMassMatrix ( )

◆ getMaxJointPos()

const Eigen::VectorXd & RobotModel::getMaxJointPos ( )

◆ getMinJointPos()

const Eigen::VectorXd & RobotModel::getMinJointPos ( )

◆ getName()

const std::string & RobotModel::getName ( ) const

Returns the name of the robot, either provided via constructor or extracted from the urdf is no name is provided.

◆ getNrOfDegreesOfFreedom()

unsigned int RobotModel::getNrOfDegreesOfFreedom ( ) const

Return the number of actuated joints.

Returns
unsigned int

◆ getNrOfJoints()

unsigned int RobotModel::getNrOfJoints ( ) const

◆ getRelativeJacobian()

const Eigen::MatrixXd & RobotModel::getRelativeJacobian ( const std::string &  refFrameName,
const std::string &  frameName 
)

◆ getRelativeTransform()

const Eigen::Matrix4d & RobotModel::getRelativeTransform ( const std::string &  refFrameName,
const std::string &  frameName 
)

Get the transform (or pose) between a frame to another.

Parameters
refFrameNameThe reference frame
frameNameThe frame you want to compute w.r.t the reference frame
Returns
const Eigen::Matrix4d&

◆ getTransform()

const Eigen::Matrix4d & RobotModel::getTransform ( const std::string &  frameName)

Get the transform of a frame w.r.t the base frame.

Parameters
frameNameThe frame you want to compute w.r.t the base frame
Returns
const Eigen::Matrix4d&

◆ getUrdfString()

const std::string & RobotModel::getUrdfString ( ) const

Get the urdf expanded string used to build the model.

Returns
const std::string&

◆ getUrdfUrl()

const std::string & RobotModel::getUrdfUrl ( ) const

Get the file url if it was loaded from a file. Empty string otherwise.

Returns
const std::string&

◆ isInitialized()

bool RobotModel::isInitialized ( ) const

◆ loadFromParameters()

bool RobotModel::loadFromParameters ( )
protected

◆ loadModelFromFile()

bool RobotModel::loadModelFromFile ( const std::string &  modelFile)

Load the model from an absolute urdf file path.

Parameters
modelFileThe absolute file path
Returns
bool

◆ loadModelFromString()

bool RobotModel::loadModelFromString ( const std::string &  modelString)

Load the model from a full urdf string (xacro not supported)

Parameters
modelStringThe expanded urdf string
Returns
bool

◆ onRobotInitializedCallback()

void RobotModel::onRobotInitializedCallback ( std::function< void(void)>  cb)

◆ print()

void RobotModel::print ( ) const

Print information about the model to cout.

◆ setBaseFrame()

void RobotModel::setBaseFrame ( const std::string &  fixed_base_or_free_floating_frame)

Set the base frame / the free-floating frame that attaches the robot to the world frame For a humanoid it would be generally somewhere in the hips. For a fixed based robot it would be the frame between the robot and the table. This frame is also the frame of reference for the jacobians, transforms etc when refFrameName is not specified.

Parameters
fixed_base_or_free_floating_framep_fixed_base_or_free_floating_frame:...

◆ setGravity()

void RobotModel::setGravity ( const Eigen::Vector3d &  global_gravity_vector)

Return the global gravity vector.

Parameters
global_gravity_vectorThe global gravity vector (usually 0,0,-9.81)

◆ setRobotState() [1/3]

void RobotModel::setRobotState ( const Eigen::Matrix4d &  world_H_base,
const Eigen::VectorXd &  jointPos,
const Eigen::Matrix< double, 6, 1 > &  baseVel,
const Eigen::VectorXd &  jointVel,
const Eigen::Vector3d &  gravity 
)

Set the complete robot state.

Parameters
world_H_baseThe pose of the robot w.r.t the world frame (identity for fixed-based robots)
jointPosThe current joint positions
baseVelThe base twist (zero for fixed-base robots)
jointVelThe current joint velocities
gravityThe world gravity

◆ setRobotState() [2/3]

void RobotModel::setRobotState ( const Eigen::VectorXd &  jointPos,
const Eigen::VectorXd &  jointVel,
const Eigen::Vector3d &  global_gravity_vector 
)

Set the partial robot state.

Parameters
jointPosThe current joint positions
jointVelTHe current joint velocities
global_gravity_vectorthe world gravity

◆ setRobotState() [3/3]

void RobotModel::setRobotState ( const Eigen::VectorXd &  jointPos,
const Eigen::VectorXd &  jointVel 
)

Set the partial robot state. Useful for fixed based robots.

Parameters
jointPosThe current joint positions
jointVelThe current joint velocities

Member Data Documentation

◆ base_frame_

common::Parameter<std::string> orca::robot::RobotModel::base_frame_
protected

◆ gravity_

common::Parameter<Eigen::Vector3d> orca::robot::RobotModel::gravity_
protected

◆ home_joint_positions_

common::Parameter<Eigen::VectorXd> orca::robot::RobotModel::home_joint_positions_
protected

◆ is_initialized_

bool orca::robot::RobotModel::is_initialized_ = false
protected

◆ name_

common::Parameter<std::string> orca::robot::RobotModel::name_
protected

◆ robot_initialized_cb_

std::function<void(void)> orca::robot::RobotModel::robot_initialized_cb_
protected

◆ robot_kinematics_type_

RobotModelImplType orca::robot::RobotModel::robot_kinematics_type_ = iDynTree
protected

◆ urdf_str_

common::Parameter<std::string> orca::robot::RobotModel::urdf_str_
protected

◆ urdf_url_

common::Parameter<std::string> orca::robot::RobotModel::urdf_url_
protected

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