Rigid Body Dynamics Library
|
Data Structures | |
struct | InverseKinematicsConstraintSet |
Functions | |
RBDL_DLLAPI void | UpdateKinematics (Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot) |
Updates and computes velocities and accelerations of the bodies. More... | |
RBDL_DLLAPI void | UpdateKinematicsCustom (Model &model, const Math::VectorNd *Q, const Math::VectorNd *QDot, const Math::VectorNd *QDDot) |
Selectively updates model internal states of body positions, velocities and/or accelerations. More... | |
RBDL_DLLAPI Vector3d | CalcBodyToBaseCoordinates (Model &model, const Math::VectorNd &Q, unsigned int body_id, const Math::Vector3d &body_point_position, bool update_kinematics=true) |
Returns the base coordinates of a point given in body coordinates. More... | |
RBDL_DLLAPI Vector3d | CalcBaseToBodyCoordinates (Model &model, const Math::VectorNd &Q, unsigned int body_id, const Math::Vector3d &base_point_position, bool update_kinematics=true) |
Returns the body coordinates of a point given in base coordinates. More... | |
RBDL_DLLAPI Matrix3d | CalcBodyWorldOrientation (Model &model, const Math::VectorNd &Q, const unsigned int body_id, bool update_kinematics=true) |
Returns the orientation of a given body as 3x3 matrix. More... | |
RBDL_DLLAPI void | CalcPointJacobian (Model &model, const Math::VectorNd &Q, unsigned int body_id, const Math::Vector3d &point_position, Math::MatrixNd &G, bool update_kinematics=true) |
Computes the point jacobian for a point on a body. More... | |
RBDL_DLLAPI void | CalcPointJacobian6D (Model &model, const Math::VectorNd &Q, unsigned int body_id, const Math::Vector3d &point_position, Math::MatrixNd &G, bool update_kinematics=true) |
Computes a 6-D Jacobian for a point on a body. More... | |
RBDL_DLLAPI void | CalcBodySpatialJacobian (Model &model, const Math::VectorNd &Q, unsigned int body_id, Math::MatrixNd &G, bool update_kinematics=true) |
Computes the spatial jacobian for a body. More... | |
RBDL_DLLAPI Vector3d | CalcPointVelocity (Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, unsigned int body_id, const Math::Vector3d &point_position, bool update_kinematics=true) |
Computes the velocity of a point on a body. More... | |
RBDL_DLLAPI Math::SpatialVector | CalcPointVelocity6D (Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, unsigned int body_id, const Math::Vector3d &point_position, bool update_kinematics=true) |
Computes angular and linear velocity of a point that is fixed on a body. More... | |
RBDL_DLLAPI Vector3d | CalcPointAcceleration (Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot, unsigned int body_id, const Math::Vector3d &point_position, bool update_kinematics=true) |
Computes the linear acceleration of a point on a body. More... | |
RBDL_DLLAPI SpatialVector | CalcPointAcceleration6D (Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot, unsigned int body_id, const Math::Vector3d &point_position, bool update_kinematics=true) |
Computes linear and angular acceleration of a point on a body. More... | |
RBDL_DLLAPI bool | InverseKinematics (Model &model, const Math::VectorNd &Qinit, const std::vector< unsigned int > &body_id, const std::vector< Math::Vector3d > &body_point, const std::vector< Math::Vector3d > &target_pos, Math::VectorNd &Qres, double step_tol=1.0e-12, double lambda=0.01, unsigned int max_iter=55) |
Computes the inverse kinematics iteratively using a damped Levenberg-Marquardt method (also known as Damped Least Squares method) More... | |
RBDL_DLLAPI Vector3d | CalcAngularVelocityfromMatrix (const Matrix3d &RotMat) |
RBDL_DLLAPI bool | InverseKinematics (Model &model, const Math::VectorNd &Qinit, InverseKinematicsConstraintSet &CS, Math::VectorNd &Qres) |
RBDL_DLLAPI Math::Vector3d CalcAngularVelocityfromMatrix | ( | const Matrix3d & | RotMat | ) |
Definition at line 699 of file Kinematics.cc.
References std::atan2(), and RigidBodyDynamics::Math::Vector3dZero.
RBDL_DLLAPI Math::Vector3d CalcBaseToBodyCoordinates | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
unsigned int | body_id, | ||
const Math::Vector3d & | base_point_position, | ||
bool | update_kinematics = true |
||
) |
Returns the body coordinates of a point given in base coordinates.
model | the rigid body model |
Q | the curent genereralized positions |
body_id | id of the body for which the point coordinates are expressed |
base_point_position | coordinates of the point in base coordinates |
update_kinematics | whether UpdateKinematics() should be called or not (default: true). |
Definition at line 190 of file Kinematics.cc.
References RigidBodyDynamics::UpdateKinematicsCustom().
RBDL_DLLAPI void CalcBodySpatialJacobian | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
unsigned int | body_id, | ||
Math::MatrixNd & | G, | ||
bool | update_kinematics = true |
||
) |
Computes the spatial jacobian for a body.
The spatial velocity of a body at the origin of coordinate system of body can be expressed as . The matrix is called the spatial body jacobian of the body and can be computed using this function.
model | rigid body model |
Q | state vector of the internal joints |
body_id | the id of the body |
G | a matrix of size 6 x #qdot_size where the result will be stored in |
update_kinematics | whether UpdateKinematics() should be called or not (default: true) |
The result will be returned via the G argument and represents the body Jacobian expressed at the origin of the body.
Definition at line 370 of file Kinematics.cc.
References SpatialTransform::apply(), MX_Xd_dynamic::block(), MX_Xd_dynamic::cols(), SpatialTransform::inverse(), MX_Xd_dynamic::rows(), and RigidBodyDynamics::UpdateKinematicsCustom().
RBDL_DLLAPI Math::Vector3d CalcBodyToBaseCoordinates | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
unsigned int | body_id, | ||
const Math::Vector3d & | body_point_position, | ||
bool | update_kinematics = true |
||
) |
Returns the base coordinates of a point given in body coordinates.
model | the rigid body model |
Q | the curent genereralized positions |
body_id | id of the body for which the point coordinates are expressed |
body_point_position | coordinates of the point in body coordinates |
update_kinematics | whether UpdateKinematics() should be called or not (default: true) |
Definition at line 157 of file Kinematics.cc.
References RigidBodyDynamics::UpdateKinematicsCustom().
RBDL_DLLAPI Math::Matrix3d CalcBodyWorldOrientation | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
const unsigned int | body_id, | ||
bool | update_kinematics = true |
||
) |
Returns the orientation of a given body as 3x3 matrix.
model | the rigid body model |
Q | the curent genereralized positions |
body_id | id of the body for which the point coordinates are expressed |
update_kinematics | whether UpdateKinematics() should be called or not (default: true). |
Definition at line 222 of file Kinematics.cc.
References RigidBodyDynamics::UpdateKinematicsCustom().
RBDL_DLLAPI Math::Vector3d CalcPointAcceleration | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
const Math::VectorNd & | QDot, | ||
const Math::VectorNd & | QDDot, | ||
unsigned int | body_id, | ||
const Math::Vector3d & | point_position, | ||
bool | update_kinematics = true |
||
) |
Computes the linear acceleration of a point on a body.
model | rigid body model |
Q | state vector of the internal joints |
QDot | velocity vector of the internal joints |
QDDot | velocity vector of the internal joints |
body_id | the id of the body |
point_position | the position of the point in body-local data |
update_kinematics | whether UpdateKinematics() should be called or not (default: true) |
The kinematic state of the model has to be updated before valid values can be obtained. This can either be done by calling UpdateKinematics() or setting the last parameter update_kinematics to true (default).
Definition at line 515 of file Kinematics.cc.
References SpatialTransform::apply(), RigidBodyDynamics::CalcBaseToBodyCoordinates(), RigidBodyDynamics::CalcBodyToBaseCoordinates(), RigidBodyDynamics::CalcBodyWorldOrientation(), and RigidBodyDynamics::UpdateKinematics().
RBDL_DLLAPI Math::SpatialVector CalcPointAcceleration6D | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
const Math::VectorNd & | QDot, | ||
const Math::VectorNd & | QDDot, | ||
unsigned int | body_id, | ||
const Math::Vector3d & | point_position, | ||
bool | update_kinematics = true |
||
) |
Computes linear and angular acceleration of a point on a body.
model | rigid body model |
Q | state vector of the internal joints |
QDot | velocity vector of the internal joints |
QDDot | velocity vector of the internal joints |
body_id | the id of the body |
point_position | the position of the point in body-local data |
update_kinematics | whether UpdateKinematics() should be called or not (default: true) |
The kinematic state of the model has to be updated before valid values can be obtained. This can either be done by calling UpdateKinematics() or setting the last parameter update_kinematics to true (default).
Definition at line 562 of file Kinematics.cc.
References SpatialTransform::apply(), RigidBodyDynamics::CalcBaseToBodyCoordinates(), RigidBodyDynamics::CalcBodyToBaseCoordinates(), RigidBodyDynamics::CalcBodyWorldOrientation(), and RigidBodyDynamics::UpdateKinematics().
RBDL_DLLAPI void CalcPointJacobian | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
unsigned int | body_id, | ||
const Math::Vector3d & | point_position, | ||
Math::MatrixNd & | G, | ||
bool | update_kinematics = true |
||
) |
Computes the point jacobian for a point on a body.
If a position of a point is computed by a function for which its time derivative is then this function computes the jacobian matrix .
model | rigid body model |
Q | state vector of the internal joints |
body_id | the id of the body |
point_position | the position of the point in body-local data |
G | a matrix of dimensions 3 x #qdot_size where the result will be stored in |
update_kinematics | whether UpdateKinematics() should be called or not (default: true) |
The result will be returned via the G argument.
Definition at line 244 of file Kinematics.cc.
References SpatialTransform::apply(), MX_Xd_dynamic::block(), RigidBodyDynamics::CalcBodyToBaseCoordinates(), MX_Xd_dynamic::cols(), SpatialTransform::inverse(), MX_Xd_dynamic::rows(), and RigidBodyDynamics::UpdateKinematicsCustom().
RBDL_DLLAPI void CalcPointJacobian6D | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
unsigned int | body_id, | ||
const Math::Vector3d & | point_position, | ||
Math::MatrixNd & | G, | ||
bool | update_kinematics = true |
||
) |
Computes a 6-D Jacobian for a point on a body.
Computes the 6-D Jacobian that when multiplied with gives a 6-D vector that has the angular velocity as the first three entries and the linear velocity as the last three entries.
model | rigid body model |
Q | state vector of the internal joints |
body_id | the id of the body |
point_position | the position of the point in body-local data |
G | a matrix of dimensions 6 x #qdot_size where the result will be stored in |
update_kinematics | whether UpdateKinematics() should be called or not (default: true) |
The result will be returned via the G argument.
Definition at line 308 of file Kinematics.cc.
References SpatialTransform::apply(), MX_Xd_dynamic::block(), RigidBodyDynamics::CalcBodyToBaseCoordinates(), MX_Xd_dynamic::cols(), SpatialTransform::inverse(), MX_Xd_dynamic::rows(), and RigidBodyDynamics::UpdateKinematicsCustom().
RBDL_DLLAPI Math::Vector3d CalcPointVelocity | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
const Math::VectorNd & | QDot, | ||
unsigned int | body_id, | ||
const Math::Vector3d & | point_position, | ||
bool | update_kinematics = true |
||
) |
Computes the velocity of a point on a body.
model | rigid body model |
Q | state vector of the internal joints |
QDot | velocity vector of the internal joints |
body_id | the id of the body |
point_position | the position of the point in body-local data |
update_kinematics | whether UpdateKinematics() should be called or not (default: true) |
Definition at line 434 of file Kinematics.cc.
References SpatialTransform::apply(), RigidBodyDynamics::CalcBaseToBodyCoordinates(), RigidBodyDynamics::CalcBodyToBaseCoordinates(), RigidBodyDynamics::CalcBodyWorldOrientation(), MX_Xd_dynamic::size(), and RigidBodyDynamics::UpdateKinematicsCustom().
RBDL_DLLAPI Math::SpatialVector CalcPointVelocity6D | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
const Math::VectorNd & | QDot, | ||
unsigned int | body_id, | ||
const Math::Vector3d & | point_position, | ||
bool | update_kinematics = true |
||
) |
Computes angular and linear velocity of a point that is fixed on a body.
model | rigid body model |
Q | state vector of the internal joints |
QDot | velocity vector of the internal joints |
body_id | the id of the body |
point_position | the position of the point in body-local data |
update_kinematics | whether UpdateKinematics() should be called or not (default: true) |
Definition at line 478 of file Kinematics.cc.
References SpatialTransform::apply(), RigidBodyDynamics::CalcBaseToBodyCoordinates(), RigidBodyDynamics::CalcBodyToBaseCoordinates(), RigidBodyDynamics::CalcBodyWorldOrientation(), MX_Xd_dynamic::size(), and RigidBodyDynamics::UpdateKinematicsCustom().
RBDL_DLLAPI bool InverseKinematics | ( | Model & | model, |
const Math::VectorNd & | Qinit, | ||
const std::vector< unsigned int > & | body_id, | ||
const std::vector< Math::Vector3d > & | body_point, | ||
const std::vector< Math::Vector3d > & | target_pos, | ||
Math::VectorNd & | Qres, | ||
double | step_tol = 1.0e-12 , |
||
double | lambda = 0.01 , |
||
unsigned int | max_iter = 55 |
||
) |
Computes the inverse kinematics iteratively using a damped Levenberg-Marquardt method (also known as Damped Least Squares method)
model | rigid body model |
Qinit | initial guess for the state |
body_id | a vector of all bodies for which we we have kinematic target positions |
body_point | a vector of points in body local coordinates that are to be matched to target positions |
target_pos | a vector of target positions |
Qres | output of the computed inverse kinematics |
step_tol | tolerance used for convergence detection |
lambda | damping factor for the least squares function |
max_iter | maximum number of steps that should be performed |
This function repeatedly computes
where and is the correction of the body points so that they coincide with the target positions. The function returns true when step_tol or if the error between body points and target gets smaller than step_tol. Otherwise it returns false.
The parameter is the damping factor that has to be chosen carefully. In case of unreachable positions higher values (e.g 0.9) can be helpful. Otherwise values of 0.0001, 0.001, 0.01, 0.1 might yield good results. See the literature for best practices.
Definition at line 605 of file Kinematics.cc.
References RigidBodyDynamics::CalcBodyToBaseCoordinates(), RigidBodyDynamics::CalcPointJacobian(), MX_Xd_dynamic::Identity(), RigidBodyDynamics::Math::LinSolveGaussElimPivot(), MX_Xd_dynamic::norm(), MX_Xd_dynamic::setZero(), MX_Xd_dynamic::size(), MX_Xd_dynamic::squaredNorm(), MX_Xd_dynamic::transpose(), RigidBodyDynamics::UpdateKinematicsCustom(), and MX_Xd_dynamic::Zero().
RBDL_DLLAPI bool InverseKinematics | ( | Model & | model, |
const Math::VectorNd & | Qinit, | ||
InverseKinematicsConstraintSet & | CS, | ||
Math::VectorNd & | Qres | ||
) |
Definition at line 855 of file Kinematics.cc.
References InverseKinematicsConstraintSet::body_ids, InverseKinematicsConstraintSet::body_points, RigidBodyDynamics::CalcAngularVelocityfromMatrix(), RigidBodyDynamics::CalcBodyToBaseCoordinates(), RigidBodyDynamics::CalcBodyWorldOrientation(), RigidBodyDynamics::Utils::CalcCenterOfMass(), RigidBodyDynamics::CalcPointJacobian6D(), InverseKinematicsConstraintSet::constraint_row_index, InverseKinematicsConstraintSet::constraint_type, InverseKinematicsConstraintSet::constraint_weight, InverseKinematicsConstraintSet::ConstraintTypeFull, InverseKinematicsConstraintSet::ConstraintTypeOrientation, InverseKinematicsConstraintSet::ConstraintTypePosition, InverseKinematicsConstraintSet::ConstraintTypePositionCoMXY, InverseKinematicsConstraintSet::ConstraintTypePositionXY, InverseKinematicsConstraintSet::ConstraintTypePositionZ, InverseKinematicsConstraintSet::delta_q_norm, InverseKinematicsConstraintSet::e, InverseKinematicsConstraintSet::error_norm, InverseKinematicsConstraintSet::G, InverseKinematicsConstraintSet::J, InverseKinematicsConstraintSet::lambda, InverseKinematicsConstraintSet::max_steps, MX_Xd_dynamic::norm(), InverseKinematicsConstraintSet::num_constraints, InverseKinematicsConstraintSet::num_steps, MX_Xd_dynamic::size(), InverseKinematicsConstraintSet::step_tol, InverseKinematicsConstraintSet::target_orientations, InverseKinematicsConstraintSet::target_positions, MX_Xd_dynamic::transpose(), RigidBodyDynamics::UpdateKinematicsCustom(), and MX_Xd_dynamic::Zero().
RBDL_DLLAPI void UpdateKinematics | ( | Model & | model, |
const Math::VectorNd & | Q, | ||
const Math::VectorNd & | QDot, | ||
const Math::VectorNd & | QDDot | ||
) |
Updates and computes velocities and accelerations of the bodies.
This function updates the kinematic variables such as body velocities and accelerations in the model to reflect the variables passed to this function.
model | the model |
Q | the positional variables of the model |
QDot | the generalized velocities of the joints |
QDDot | the generalized accelerations of the joints |
Definition at line 25 of file Kinematics.cc.
References MX_Xd_dynamic::block(), RigidBodyDynamics::Math::crossm(), and RigidBodyDynamics::jcalc().
RBDL_DLLAPI void UpdateKinematicsCustom | ( | Model & | model, |
const Math::VectorNd * | Q, | ||
const Math::VectorNd * | QDot, | ||
const Math::VectorNd * | QDDot | ||
) |
Selectively updates model internal states of body positions, velocities and/or accelerations.
This function updates the kinematic variables such as body velocities and accelerations in the model to reflect the variables passed to this function.
In contrast to UpdateKinematics() this function allows to update the model state with values one is interested and thus reduce computations (e.g. only positions, only positions + accelerations, only velocities, etc.).
model | the model |
Q | the positional variables of the model |
QDot | the generalized velocities of the joints |
QDDot | the generalized accelerations of the joints |
Definition at line 78 of file Kinematics.cc.
References MX_Xd_dynamic::block(), RigidBodyDynamics::Math::crossm(), RigidBodyDynamics::jcalc(), and MX_Xd_dynamic::Zero().