Flexiv RDK APIs  2.1
Public Member Functions | List of all members
flexiv::rdk::Model Class Reference

Interface to obtain certain model data of the robot, including kinematics and dynamics. More...

#include <model.hpp>

Public Member Functions

 Model (const Robot &robot, const Eigen::Vector3d &gravity_vector=Eigen::Vector3d(0.0, 0.0, -9.81))
 [Non-blocking] Instantiate the robot model interface. More...
 
std::vector< std::string > link_names () const
 [Non-blocking] Names of all links in the robot model. More...
 
std::vector< std::string > joint_names () const
 [Non-blocking] Names of all actuated joints in the robot model. More...
 
void Reload ()
 [Blocking] Reload (refresh) parameters of the robot model stored locally in this class using the latest data synced from the connected robot. Tool model is also synced. More...
 
void Update (const std::vector< double > &full_q, const std::vector< double > &full_dq)
 [Non-blocking] Update the configuration (posture) of the locally-stored robot model so that the locally computed functions return results based on the updated configuration. More...
 
Eigen::MatrixXd dJ (const std::string &link_name)
 [Non-blocking] Compute the time derivative of Jacobian matrix at the specified frame w.r.t. world frame. More...
 
Eigen::MatrixXd M ()
 [Non-blocking] Compute the mass matrix in generalized coordinates, i.e. joint space. More...
 
Eigen::MatrixXd C ()
 [Non-blocking] Compute the Coriolis/centripetal matrix in generalized coordinates, i.e. joint space. More...
 
Eigen::VectorXd g ()
 [Non-blocking] Compute the gravity force vector in generalized coordinates, i.e. joint space. More...
 
Eigen::VectorXd c ()
 [Non-blocking] Compute the Coriolis force vector in generalized coordinates, i.e. joint space. More...
 
Eigen::MatrixXd J (const std::string &link_name)
 [Non-blocking] Compute the Jacobian matrix at the specified frame w.r.t. world frame. More...
 
Eigen::Isometry3d T (const std::string &link_name)
 [Non-blocking] Compute the transformation matrix of the specified frame w.r.t. world frame. More...
 
void SyncURDF (const std::string &template_urdf_path)
 [Blocking] Sync the actual kinematic parameters of the connected robot into the template URDF file. More...
 
size_t SyncKinematicsYAML (const std::string &template_yaml_path)
 [Blocking] Sync the actual kinematic parameters of the connected robot into the template YAML file. More...
 
IKResult SolveConstrainedIK (const std::map< JointGroup, IKParams > &ik_params_by_group)
 [Blocking] Solve constrained IK using one or more active joint groups. More...
 
std::map< JointGroup, std::pair< double, double > > configuration_score () const
 [Blocking] Score of each joint group's current configuration (posture), calculated from the manipulability measurements. More...
 
std::map< JointGroup, std::vector< Eigen::Vector3d > > multi_contact_forces () const
 [Non-blocking] Estimated multi-contact forces applied on each link of applicable joint groups, calculated using the force-torque sensors installed in every joint of the robot. More...
 
std::map< JointGroup, std::vector< Eigen::Vector3d > > multi_contact_positions () const
 [Non-blocking] Estimated multi-contact positions on each link of applicable joint groups, calculated using the force-torque sensors installed in every joint of the robot. More...
 

Detailed Description

Interface to obtain certain model data of the robot, including kinematics and dynamics.

Definition at line 48 of file model.hpp.

Constructor & Destructor Documentation

◆ Model()

flexiv::rdk::Model::Model ( const Robot robot,
const Eigen::Vector3d &  gravity_vector = Eigen::Vector3d(0.0, 0.0, -9.81) 
)

[Non-blocking] Instantiate the robot model interface.

Parameters
[in]robotReference to the instance of flexiv::rdk::Robot.
[in]gravity_vectorEarth's gravity vector in world frame. Default to \( [0.0, 0.0, -9.81]^T \). Unit: \( [m/s^2] \).
Exceptions
std::runtime_errorif the initialization sequence failed.
std::logic_errorif the connected robot does not have an RDK professional license; or the parsed robot model is not supported.

Member Function Documentation

◆ C()

Eigen::MatrixXd flexiv::rdk::Model::C ( )

[Non-blocking] Compute the Coriolis/centripetal matrix in generalized coordinates, i.e. joint space.

Returns
Coriolis/centripetal matrix: \( C(q,\dot{q}) \in \mathbb{R}^{n \times n} \).
Note
Call Update() before this function.

◆ c()

Eigen::VectorXd flexiv::rdk::Model::c ( )

[Non-blocking] Compute the Coriolis force vector in generalized coordinates, i.e. joint space.

Returns
Coriolis force vector: \( c(q,\dot{q}) \in \mathbb{R}^{n \times 1} \). Unit: \( [Nm] \).
Note
Call Update() before this function.

◆ configuration_score()

std::map<JointGroup, std::pair<double, double> > flexiv::rdk::Model::configuration_score ( ) const

[Blocking] Score of each joint group's current configuration (posture), calculated from the manipulability measurements.

Returns
Configuration score mapped by joint group as {translation_score, orientation_score}. The quality of configuration based on the score can be interpreted as: poor = [0, 20), medium = [20, 40), good = [40, 100].
Exceptions
std::runtime_errorif failed to get a reply from the connected robot.
Note
This function blocks until a reply is received.
Warning
A poor configuration score means the robot is near or at singularity, which can lead to degraded Cartesian performance. Use configuration with high scores for better manipulability and task results.

◆ dJ()

Eigen::MatrixXd flexiv::rdk::Model::dJ ( const std::string &  link_name)

[Non-blocking] Compute the time derivative of Jacobian matrix at the specified frame w.r.t. world frame.

Parameters
[in]link_nameName of the link whose frame is the specified one.
Returns
Time derivative of the Jacobian matrix: \( ^{O}\dot{J_i} \in \mathbb{R}^{m \times n} \).
Exceptions
std::invalid_argumentif [link_name] does not exist.
Note
Call Update() before this function.
See also
link_names().

◆ g()

Eigen::VectorXd flexiv::rdk::Model::g ( )

[Non-blocking] Compute the gravity force vector in generalized coordinates, i.e. joint space.

Returns
Gravity force vector: \( g(q) \in \mathbb{R}^{n \times 1} \). Unit: \( [Nm] \).
Note
Call Update() before this function.

◆ J()

Eigen::MatrixXd flexiv::rdk::Model::J ( const std::string &  link_name)

[Non-blocking] Compute the Jacobian matrix at the specified frame w.r.t. world frame.

Parameters
[in]link_nameName of the link whose frame is the specified one.
Returns
Jacobian matrix: \( ^{O}J_i \in \mathbb{R}^{m \times n} \).
Exceptions
std::invalid_argumentif [link_name] does not exist.
Note
Call Update() before this function.
See also
link_names().

◆ joint_names()

std::vector<std::string> flexiv::rdk::Model::joint_names ( ) const

[Non-blocking] Names of all actuated joints in the robot model.

Returns
Name vector in the same order as the robot's kinematic chain.

◆ link_names()

std::vector<std::string> flexiv::rdk::Model::link_names ( ) const

[Non-blocking] Names of all links in the robot model.

Returns
Name vector in the same order as the robot's kinematic chain.

◆ M()

Eigen::MatrixXd flexiv::rdk::Model::M ( )

[Non-blocking] Compute the mass matrix in generalized coordinates, i.e. joint space.

Returns
Symmetric positive definite mass matrix: \( M(q) \in \mathbb{S}^{n \times n}_{++} \). Unit: \( [kgm^2] \).
Note
Call Update() before this function.

◆ multi_contact_forces()

std::map<JointGroup, std::vector<Eigen::Vector3d> > flexiv::rdk::Model::multi_contact_forces ( ) const

[Non-blocking] Estimated multi-contact forces applied on each link of applicable joint groups, calculated using the force-torque sensors installed in every joint of the robot.

Returns
\( f_c \in \mathbb{R}^{n \times 1} \) mapped by joint group. Each vector element is a \( \mathbb{R}^{3 \times 1} \) force vector w.r.t. the corresponding link frame. Only contains joint groups that are capable of multi-contact estimation.
Warning
This data is only available on certain robot models. An empty vector will be returned if the connected robot does not support multi-contact estimation.

◆ multi_contact_positions()

std::map<JointGroup, std::vector<Eigen::Vector3d> > flexiv::rdk::Model::multi_contact_positions ( ) const

[Non-blocking] Estimated multi-contact positions on each link of applicable joint groups, calculated using the force-torque sensors installed in every joint of the robot.

Returns
\( p_c \in \mathbb{R}^{n \times 1} \) mapped by joint group. Each vector element is a \( \mathbb{R}^{3 \times 1} \) position vector w.r.t. the corresponding link frame. Only contains joint groups that are capable of multi-contact estimation.
Warning
This data is only available on certain robot models. An empty vector will be returned if the connected robot does not support multi-contact estimation.

◆ Reload()

void flexiv::rdk::Model::Reload ( )

[Blocking] Reload (refresh) parameters of the robot model stored locally in this class using the latest data synced from the connected robot. Tool model is also synced.

Exceptions
std::runtime_errorif failed to sync model data.
std::logic_errorif the synced robot model contains invalid data.
Note
This function blocks until the model parameters are synced and reloaded.
This function does not affect the kinematics functions.
Warning
Parameters of the locally-stored robot model must be manually refreshed using this function whenever a physical change is made to the connected robot (e.g. a tool is added or changed). Otherwise the locally computed functions will return incorrect results.

◆ SolveConstrainedIK()

IKResult flexiv::rdk::Model::SolveConstrainedIK ( const std::map< JointGroup, IKParams > &  ik_params_by_group)

[Blocking] Solve constrained IK using one or more active joint groups.

Parameters
[in]ik_params_by_groupIK input parameters mapped by active joint group. Joint groups not included in this map are treated as inactive. Only single-arm joint groups like ARM_1 and ARM_2 are accepted.
Returns
Solver result. [solved_q] contains one entry per requested active joint group.
Exceptions
std::invalid_argumentif input map is empty, if any joint group is not an existing single-arm joint group, or if any [seed_q] size does not match DoF of its joint group.
std::runtime_errorif failed to get a reply from the connected robot.
Note
This function blocks until a reply is received.

◆ SyncKinematicsYAML()

size_t flexiv::rdk::Model::SyncKinematicsYAML ( const std::string &  template_yaml_path)

[Blocking] Sync the actual kinematic parameters of the connected robot into the template YAML file.

Parameters
[in]template_yaml_pathPath to the template YAML file located at [flexiv_description/config/.../default_kinematics.yaml]. This template YAML file will be updated when the sync is finished.
Returns
Total number of joints that have been successfully synced.
Exceptions
std::invalid_argumentif failed to load the template YAML file.
std::runtime_errorif failed to sync the YAML file.
Note
This function blocks until the sync is finished.

◆ SyncURDF()

void flexiv::rdk::Model::SyncURDF ( const std::string &  template_urdf_path)

[Blocking] Sync the actual kinematic parameters of the connected robot into the template URDF file.

Parameters
[in]template_urdf_pathPath to the template URDF file that can be generated in flexiv_description. This template URDF file will be updated when the sync is finished.
Exceptions
std::invalid_argumentif failed to load the template URDF file.
std::runtime_errorif failed to sync the URDF file.
Note
This function blocks until the sync is finished.
Why is this function needed?
The template URDF contains kinematic parameters of the latest version of robot hardware, which might be different from older versions. This function is therefore provided to sync the actual kinematic parameters of the connected robot into the template URDF.

◆ T()

Eigen::Isometry3d flexiv::rdk::Model::T ( const std::string &  link_name)

[Non-blocking] Compute the transformation matrix of the specified frame w.r.t. world frame.

Parameters
[in]link_nameName of the link whose frame is the specified one.
Returns
Transformation matrix: \( ^{O}T_i \in \mathbb{R}^{4 \times 4} \).
Exceptions
std::invalid_argumentif [link_name] does not exist.
Note
Call Update() before this function.
See also
link_names().

◆ Update()

void flexiv::rdk::Model::Update ( const std::vector< double > &  full_q,
const std::vector< double > &  full_dq 
)

[Non-blocking] Update the configuration (posture) of the locally-stored robot model so that the locally computed functions return results based on the updated configuration.

Parameters
[in]full_qCurrent joint positions of the whole robot and matching the order of joint_names(): \( q \in \mathbb{R}^{n \times 1} \). Unit: \( [rad] \).
[in]full_dqCurrent joint velocities of the whole robot and matching the order of joint_names(): \( \dot{q} \in \mathbb{R}^{n \times 1} \). Unit: \( [rad/s] \).
Exceptions
std::invalid_argumentif size of any input vector does not match robot full DoF.

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