raisim::ArticulatedSystem
class · #include <raisim/object/ArticulatedSystem/ArticulatedSystem.hpp>
Inherits: raisim::Object
A tree of rigid bodies connected by joints (robot), simulated in generalized coordinates.
Usually created from a URDF/MJCF file through World::addArticulatedSystem(). Conventions used below:
- body (index): a movable body. Links connected by fixed joints are merged into their movable parent, so the body index equals the index of the joint that connects the body to its parent. The body frame is the frame of that parent joint (after the joint transformation).
- gc (generalized coordinate, size getGeneralizedCoordinateDim()): floating base = position (3) + quaternion (w,x,y,z); spherical joint = quaternion (w,x,y,z); revolute/prismatic = 1 value.
- gv (generalized velocity, size getDOF()): floating base = linear velocity (3) and angular velocity (3), both in the world frame; spherical joint = angular velocity in the child body frame; revolute/prismatic = 1 value.
- frame: a CoordinateFrame is defined at every joint, including fixed joints (and sensors).
Nested classes
structIKOptions — Options for solveIK().structIKResult — Result of solveIK().classJointRef — Lightweight handle to a joint (coordinate frame) of an ArticulatedSystem, obtained by getJoint().classLinkRef — Lightweight handle to a body (link) of an ArticulatedSystem, obtained by getLink().structSpringElement — A linear/torsional spring acting at the joint of a body (see addSpring()).
Public types
Frame
enum Frame : unsignedCoordinate frame in which a vector argument is expressed.
| Enumerator | Value | Description |
|---|---|---|
WORLD_FRAME | 0 | World frame. |
PARENT_FRAME | Frame of the parent body of the given body (the world frame for the root body). | |
BODY_FRAME | Frame of the given body (its parent joint frame). |
IntegrationScheme
enum class IntegrationScheme : intTime integration scheme (see setIntegrationScheme()).
| Enumerator | Value | Description |
|---|---|---|
TRAPEZOID | 0 | Positions are integrated with the average of the old and new generalized velocity. |
SEMI_IMPLICIT | Positions are integrated with the new generalized velocity (default). | |
EULER | Positions are integrated with the old generalized velocity. | |
RUNGE_KUTTA_4 | Fourth-order Runge-Kutta integration. |
Constructors & destructor
ArticulatedSystem
ArticulatedSystem() = defaultArticulatedSystem(
const Child &child,
const std::string &resDir,
ArticulatedSystemOption options)Build a system from a programmatically constructed kinematic tree. Users normally go through World::addArticulatedSystem().
Parameters
| Parameter | Description |
|---|---|
child (in) | root node of the tree |
resDir (in) | resource directory used to resolve relative mesh paths |
options (in) | articulated system options |
explicit ArticulatedSystem(
const std::string &filePathOrURDFScript,
const std::string &resDir="",
const std::vector<std::string> &jointOrder=std::vector<std::string>(),
ArticulatedSystemOption options=ArticulatedSystemOption())Build a system from a URDF file or a URDF string. Users normally go through World::addArticulatedSystem().
Parameters
| Parameter | Description |
|---|---|
filePathOrURDFScript (in) | path to a ".urdf"/".xml" file, or the URDF text itself (an argument containing '<' is treated as URDF text) |
resDir (in) | resource directory for meshes. If empty, the directory of the file is used |
jointOrder (in) | optional joint names that set the order in which sibling branches are traversed (and hence the gc/gv ordering). Joints not listed follow in file order |
options (in) | articulated system options |
explicit ArticulatedSystem(
const std::string &filePathOrURDFScript,
const std::vector<std::string> &modules,
const std::string &resDir="",
const std::vector<std::string> &jointOrder=std::vector<std::string>(),
ArticulatedSystemOption options=ArticulatedSystemOption())Build a system from a URDF file extended by module files. The content of each module file is inserted before the closing robot tag, and the merged model is written to "generated_<urdf name>_<module names>.urdf" in the base directory (resDir, or the URDF's directory) before it is loaded.
Parameters
| Parameter | Description |
|---|---|
filePathOrURDFScript (in) | path to the base URDF file (URDF text is not supported here) |
modules (in) | module files. Each is searched as an absolute path, then relative to the base directory, then in "modules"/"module" next to or one level above the base directory |
resDir (in) | resource directory for meshes and the base directory of the modules. If empty, the directory of the URDF file is used |
jointOrder (in) | see the URDF constructor |
options (in) | articulated system options |
ArticulatedSystem(
const RaiSimTinyXmlWrapper &c,
const std::string &resDir,
const std::unordered_map<std::string, RaiSimTinyXmlWrapper> &defaultNode,
const std::unordered_map<std::string, std::pair<std::string, Vec<3>>> &mesh,
const mjcf::MjcfCompilerSetting &setting,
ArticulatedSystemOption options=ArticulatedSystemOption())Internal: build a system from an MJCF body node. Used by the MJCF world loader.
Parameters
| Parameter | Description |
|---|---|
c (in) | MJCF body element |
resDir (in) | resource directory for meshes |
defaultNode (in) | MJCF default classes (and assets) keyed by name |
mesh (in) | MJCF mesh assets: name -> (file, scale) |
setting (in) | MJCF compiler settings |
options (in) | articulated system options |
~ArticulatedSystem
~ArticulatedSystem()Public member functions
isSecondOrderOrHigher
bool isSecondOrderOrHigher(IntegrationScheme scheme) constParameters
| Parameter | Description |
|---|---|
scheme (in) | integration scheme |
Returns true only for IntegrationScheme::RUNGE_KUTTA_4
getGeneralizedCoordinate
const raisim::VecDyn &getGeneralizedCoordinate() constReturns generalized coordinate of the system (size getGeneralizedCoordinateDim(); see the class description for the layout)
getGeneralizedVelocity
const raisim::VecDyn &getGeneralizedVelocity() constReturns generalized velocity of the system (size getDOF())
getGeneralizedAcceleration
const raisim::VecDyn &getGeneralizedAcceleration() constReturns generalized acceleration of the system (size getDOF()). The generalized acceleration is computed in the integration step. So this function does not work properly if you have not integrated the world.
getBaseOrientation
void getBaseOrientation(raisim::Vec<4> &quaternion) constOnly for a floating base (fatal otherwise).
Parameters
| Parameter | Description |
|---|---|
quaternion (out) | orientation of the base as a quaternion (w,x,y,z), i.e., gc[3..6] |
void getBaseOrientation(raisim::Mat<3, 3> &rotataionMatrix) constParameters
| Parameter | Description |
|---|---|
rotataionMatrix (out) | world-frame orientation of the base |
const raisim::Mat<3, 3> &getBaseOrientation() constReturns world-frame orientation of the base
getBasePosition
void getBasePosition(raisim::Vec<3> &position) constOnly for a floating base (fatal otherwise).
Parameters
| Parameter | Description |
|---|---|
position (out) | world-frame position of the base, i.e., gc[0..2] [m] |
raisim::Vec<3> getBasePosition() constOnly for a floating base (fatal otherwise).
Returns world-frame position of the base, i.e., gc[0..2] [m]
updateKinematics
void updateKinematics()Recompute body poses and velocities from the current gc and gv (quaternions in gc are normalized). unnecessary to call this function if you are simulating your system. integrate1 calls this function Call this function if you want to get kinematic properties but you don't want to integrate.
setGeneralizedCoordinate
void setGeneralizedCoordinate(const Eigen::VectorXd &jointState)set gc of each joint in order. This updates the kinematics and removes previously computed contact points.
Parameters
| Parameter | Description |
|---|---|
jointState (in) | generalized coordinate (size getGeneralizedCoordinateDim(); fatal otherwise) |
void setGeneralizedCoordinate(const raisim::VecDyn &jointState)set gc of each joint in order. This updates the kinematics and removes previously computed contact points.
Parameters
| Parameter | Description |
|---|---|
jointState (in) | generalized coordinate (size getGeneralizedCoordinateDim(); fatal otherwise) |
void setGeneralizedCoordinate(std::initializer_list<double> jointState)set the generalized coordinate of each joint in order. This updates the kinematics and removes previously computed contact points.
Parameters
| Parameter | Description |
|---|---|
jointState (in) | the generalized coordinate (must have getGeneralizedCoordinateDim() elements; fatal otherwise) |
setGeneralizedVelocity
void setGeneralizedVelocity(const Eigen::VectorXd &jointVel)set the generalized velocity. This updates the kinematics.
Parameters
| Parameter | Description |
|---|---|
jointVel (in) | the generalized velocity (size getDOF(); fatal otherwise) |
void setGeneralizedVelocity(const raisim::VecDyn &jointVel)set the generalized velocity. This updates the kinematics.
Parameters
| Parameter | Description |
|---|---|
jointVel (in) | the generalized velocity (size getDOF(); fatal otherwise) |
void setGeneralizedVelocity(std::initializer_list<double> jointVel)set the generalized velocity of each joint in order. This updates the kinematics.
Parameters
| Parameter | Description |
|---|---|
jointVel (in) | the generalized velocity (must have getDOF() elements; fatal otherwise) |
setGeneralizedForce
void setGeneralizedForce(std::initializer_list<double> tau)This is feedforward generalized force. In the PD control mode, this differs from the actual generalizedForce the dimension should be the same as dof. Unlike setExternalForce(), it persists until it is set again.
Parameters
| Parameter | Description |
|---|---|
tau (in) | the generalized force. If the built-in PD controller is active, this force is added to the generalized force from the PD controller |
void setGeneralizedForce(const raisim::VecDyn &tau)This is feedforward generalized force. In the PD control mode, this differs from the actual generalizedForce the dimension should be the same as dof. Unlike setExternalForce(), it persists until it is set again.
Parameters
| Parameter | Description |
|---|---|
tau (in) | the generalized force (size getDOF(); fatal otherwise). If the built-in PD controller is active, this force is added to the generalized force from the PD controller |
void setGeneralizedForce(const Eigen::VectorXd &tau)This is feedforward generalized force. In the PD control mode, this differs from the actual generalizedForce the dimension should be the same as dof. Unlike setExternalForce(), it persists until it is set again.
Parameters
| Parameter | Description |
|---|---|
tau (in) | the generalized force (size getDOF(); fatal otherwise). If the built-in PD controller is active, this force is added to the generalized force from the PD controller |
getState
void getState(Eigen::VectorXd &genco, Eigen::VectorXd &genvel) constget both the generalized coordinate and the generalized velocity
Parameters
| Parameter | Description |
|---|---|
genco (out) | the generalized coordinate (size getGeneralizedCoordinateDim()) |
genvel (out) | the generalized velocity (size getDOF()) |
void getState(VecDyn &genco, VecDyn &genvel) constget both the generalized coordinate and the generalized velocity
Parameters
| Parameter | Description |
|---|---|
genco (out) | the generalized coordinate (size getGeneralizedCoordinateDim()) |
genvel (out) | the generalized velocity (size getDOF()) |
setState
void setState(const Eigen::VectorXd &genco, const Eigen::VectorXd &genvel)set both the generalized coordinate and the generalized velocity. This updates the kinematics and removes previously computed contact points
Parameters
| Parameter | Description |
|---|---|
genco (in) | the generalized coordinate (size getGeneralizedCoordinateDim(); fatal otherwise) |
genvel (in) | the generalized velocity (size getDOF(); fatal otherwise) |
getGeneralizedForce
VecDyn getGeneralizedForce() constActuation generalized force: the feedforward force (setGeneralizedForce()) plus, in the PD control mode, the PD term (using the position error of the last step and the current velocity), clamped to the actuation limits, plus the actuator torques clipped to their motor operating regions at the current motor speeds. This method a small error when the built-in PD controller is used. The PD controller is implicit (using a continuous, linear model) so we cannot get the true gen force. But if you set the time step small enough, the difference is negligible.
Returns the generalized force (size getDOF())
getFeedForwardGeneralizedForce
const VecDyn &getFeedForwardGeneralizedForce() constget the feedfoward generalized force (which is set by the user)
Returns the feedforward generalized force
getMassMatrix
const MatDyn &getMassMatrix()compute and get the mass matrix at the current configuration. It includes the rotor inertia on its diagonal.
Returns the mass matrix (getDOF() x getDOF()). The reference is to internal storage that is overwritten by the next call. Check Object/ArticulatedSystem section in the manual
getNonlinearities
const VecDyn &getNonlinearities(const Vec<3> &gravity)compute and get the coriolis and the gravitational term (h in M*du + h = tau) at the current state
Parameters
| Parameter | Description |
|---|---|
gravity (in) | gravitational acceleration. You should get this value from the world.getGravity(); |
Returns the coriolis and the gravitational term (size getDOF()). Check Object/ArticulatedSystem section in the manual
getInverseMassMatrix
const MatDyn &getInverseMassMatrix()get the inverse mass matrix. Note that this is actually damped inverse. It contains the effect of damping, the springs and the PD gains due to the implicit integration. YOU MUST CALL getMassMatrix FIRST BEFORE CALLING THIS METHOD.
Returns the inverse mass matrix. Check Object/ArticulatedSystem section in the manual
getCompositeCOM
const std::vector<raisim::Vec<3>> &getCompositeCOM() constget the center of mass of a composite body containing body i and all its children. if you want the COM of the whole robot, just take the first element This only works if you have called getMassMatrix() with the current state
Returns world-frame centers of mass of the composite bodies, indexed by body index [m]
getCOM
Vec<3> getCOM() constget the center of mass of the whole system, computed from the current body COM positions
Returns world-frame center of mass of the system [m]
getCompositeInertia
const std::vector<raisim::Mat<3, 3>> &getCompositeInertia() constget the composite inertia of a composite body containing body i and all its children. It is updated by getMassMatrix(), not by the integration step.
Returns inertia of each composite body about its composite COM, expressed in the world frame, indexed by body index
getCompositeMass
const std::vector<double> &getCompositeMass() constget the current composite mass of a composite body containing body i and all its children. Call updateMassInfo() after changing body masses.
Returns composite masses indexed by body index [kg]
getLinearMomentum
Vec<3> getLinearMomentum() constlinear momentum of the whole system
Returns world-frame linear momentum [kg m/s]
getGeneralizedMomentum
const VecDyn &getGeneralizedMomentum() constreturns the generalized momentum which is M * u It is already computed in "integrate1()" so you don't have to compute again.
Returns the generalized momentum
getEnergy
double getEnergy(const Vec<3> &gravity)Parameters
| Parameter | Description |
|---|---|
gravity (in) | gravitational acceleration |
Returns the sum of potential/kinetic energy given the gravitational acceleration [J]. See getKineticEnergy() and getPotentialEnergy()
getKineticEnergy
double getKineticEnergy()Computes 0.5 * u^T M u. This recomputes the mass matrix (including rotor inertia).
Returns the kinetic energy [J].
getPotentialEnergy
double getPotentialEnergy(const Vec<3> &gravity) constParameters
| Parameter | Description |
|---|---|
gravity (in) | gravitational acceleration |
Returns the gravitational potential energy, -sum_i m_i * (gravity . com_i), i.e., relative to the world origin [J]
getAngularMomentum
void getAngularMomentum(
const Vec<3> &referencePoint,
Vec<3> &angularMomentum) constParameters
| Parameter | Description |
|---|---|
referencePoint (in) | the world-frame reference point about which the angular momentum is computed |
angularMomentum (out) | world-frame angular momentum about the reference point |
printOutBodyNamesInOrder
void printOutBodyNamesInOrder() constbodies here means moving bodies. Fixed bodies are optimized out
printOutMovableJointNamesInOrder
void printOutMovableJointNamesInOrder() constprint out movable joint names in order
printOutFrameNamesInOrder
void printOutFrameNamesInOrder() constframes are attached to every joint coordinate
getMovableJointNames
const std::vector<std::string> &getMovableJointNames() constgetMovableJointNames. Note! the order doesn't correspond to dof since there are joints with multiple dof's. For a floating base, the first entry is "ROOT".
Returns movable joint names in the joint order.
getGeneralizedVelocityIndex
size_t getGeneralizedVelocityIndex(const std::string &name) constget generalized velocity index of a joint. Fatal if the joint does not exist.
Parameters
| Parameter | Description |
|---|---|
name (in) | movable joint name ("ROOT" for a floating base) |
Returns index of the joint's first element in the generalized velocity.
getPosition
void getPosition(
size_t bodyIdx,
const Vec<3> &point_B,
Vec<3> &point_W) const finalTransform a point from a body frame to the world frame.
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | The body which contains the point, can be retrieved by getBodyIdx() |
point_B (in) | The position of the point in the body frame |
point_W (out) | The position of the point in the world frame |
void getPosition(size_t bodyIdx, Vec<3> &pos_w) const finalParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. Note that body index and the joint index are the same because every body has one parent joint. It can be retrieved by getBodyIdx() |
pos_w (out) | world-frame position of the joint (after its own joint transformation) |
getFrameByName
CoordinateFrame &getFrameByName(const std::string &nm)Refer to Object/ArticulatedSystem/Kinematics/Frame in the manual for details
Parameters
| Parameter | Description |
|---|---|
nm (in) | name of the frame (joint name). Fatal if not found |
Returns the coordinate frame of the given name
const CoordinateFrame &getFrameByName(const std::string &nm) constConst overload of getFrameByName().
Parameters
| Parameter | Description |
|---|---|
nm (in) | name of the frame (joint name). Fatal if not found |
Returns the coordinate frame of the given name
getFrameByLinkName
CoordinateFrame &getFrameByLinkName(const std::string &name)Refer to Object/ArticulatedSystem/Kinematics/Frame in the manual for details
Parameters
| Parameter | Description |
|---|---|
name (in) | name of the urdf link that is a child of the joint. Fatal if not found |
Returns the coordinate frame of the given link name
const CoordinateFrame &getFrameByLinkName(const std::string &name) constConst overload of getFrameByLinkName().
Parameters
| Parameter | Description |
|---|---|
name (in) | name of the urdf link that is a child of the joint. Fatal if not found |
Returns the coordinate frame of the given link name
getFrameIdxByLinkName
size_t getFrameIdxByLinkName(const std::string &name) constRefer to Object/ArticulatedSystem/Kinematics/Frame in the manual for details
Parameters
| Parameter | Description |
|---|---|
name (in) | name of the urdf link that is a child of the joint |
Returns the coordinate frame index of the given link name. Returns size_t(-1) if it doesn't exist
getFrameByIdx
CoordinateFrame &getFrameByIdx(size_t idx)Refer to Object/ArticulatedSystem/Kinematics/Frame in the manual for details
Parameters
| Parameter | Description |
|---|---|
idx (in) | index of the frame. Fatal if out of range |
Returns the coordinate frame of the given index
const CoordinateFrame &getFrameByIdx(size_t idx) constConst overload of getFrameByIdx().
Parameters
| Parameter | Description |
|---|---|
idx (in) | index of the frame. Fatal if out of range |
Returns the coordinate frame of the given index
getFrameIdxByName
size_t getFrameIdxByName(const std::string &nm) constRefer to Object/ArticulatedSystem/Kinematics/Frame in the manual for details The frame can be retrieved as as->getFrames[index]. This way is more efficient than above methods that use the frame name
Parameters
| Parameter | Description |
|---|---|
nm (in) | name of the frame |
Returns the index of the coordinate frame of the given name. Returns size_t(-1) if it doesn't exist
getFrames
std::vector<CoordinateFrame> &getFrames()Refer to Object/ArticulatedSystem/Kinematics/Frame in the manual for details The frame can be retrieved as as->getFrames[index]. This way is more efficient than above methods that use the frame name
Returns a vector of the coordinate frames
const std::vector<CoordinateFrame> &getFrames() constConst overload of getFrames().
Returns a vector of the coordinate frames
getFramePosition
void getFramePosition(size_t frameId, Vec<3> &point_W) constParameters
| Parameter | Description |
|---|---|
frameId (in) | the frame id which can be obtained by getFrameIdxByName() |
point_W (out) | the position of the frame expressed in the world frame |
void getFramePosition(const std::string &frameName, Vec<3> &point_W) constParameters
| Parameter | Description |
|---|---|
frameName (in) | the frame name (defined in the urdf) |
point_W (out) | the position of the frame expressed in the world frame |
void getFramePosition(const CoordinateFrame &frame, Vec<3> &point_W) constParameters
| Parameter | Description |
|---|---|
frame (in) | custom frame defined by the user |
point_W (out) | the position of the frame relative to the world frame |
getPositionInFrame
void getPositionInFrame(
size_t frameId,
const Vec<3> &localPos,
Vec<3> &point_W) constParameters
| Parameter | Description |
|---|---|
frameId (in) | the frame id which can be obtained by getFrameIdxByName() |
localPos (in) | local position expressed in the specified frame |
point_W (out) | the position expressed in the world frame |
getFrameOrientation
void getFrameOrientation(size_t frameId, Mat<3, 3> &orientation_W) constParameters
| Parameter | Description |
|---|---|
frameId (in) | the frame id which can be obtained by getFrameIdxByName() |
orientation_W (out) | the orientation of the frame relative to the world frame |
void getFrameOrientation(
const std::string &frameName,
Mat<3, 3> &orientation_W) constParameters
| Parameter | Description |
|---|---|
frameName (in) | the frame name (defined in the urdf) |
orientation_W (out) | the orientation of the frame relative to the world frame |
void getFrameOrientation(
const CoordinateFrame &frame,
Mat<3, 3> &orientation_W) constParameters
| Parameter | Description |
|---|---|
frame (in) | custom frame defined by the user |
orientation_W (out) | the orientation of the frame relative to the world frame |
getFrameVelocity
void getFrameVelocity(size_t frameId, Vec<3> &vel_W) constParameters
| Parameter | Description |
|---|---|
frameId (in) | the frame id which can be obtained by getFrameIdxByName() |
vel_W (out) | the linear velocity of the frame expressed in the world frame |
void getFrameVelocity(const std::string &frameName, Vec<3> &vel_W) constParameters
| Parameter | Description |
|---|---|
frameName (in) | the frame name (defined in the urdf) |
vel_W (out) | the linear velocity of the frame expressed in the world frame |
void getFrameVelocity(const CoordinateFrame &frame, Vec<3> &vel_W) constParameters
| Parameter | Description |
|---|---|
frame (in) | custom frame defined by the user |
vel_W (out) | the linear velocity of the frame expressed to the world frame |
getFrameAngularVelocity
void getFrameAngularVelocity(size_t frameId, Vec<3> &angVel_W) constParameters
| Parameter | Description |
|---|---|
frameId (in) | the frame id which can be obtained by getFrameIdxByName() |
angVel_W (out) | the angular velocity of the frame expressed in the world frame |
void getFrameAngularVelocity(
const std::string &frameName,
Vec<3> &angVel_W) constParameters
| Parameter | Description |
|---|---|
frameName (in) | the frame name (defined in the urdf) |
angVel_W (out) | the angular velocity of the frame relative to the world frame |
void getFrameAngularVelocity(
const CoordinateFrame &frame,
Vec<3> &angVel_W) constParameters
| Parameter | Description |
|---|---|
frame (in) | custom frame defined by the user |
angVel_W (out) | the angular velocity of the frame expressed to the world frame |
getFrameAcceleration
void getFrameAcceleration(const std::string &frameName, Vec<3> &acc_W) constYOU NEED TO ENABLE INVERSEDYNAMICS COMPUTATION TO USE THIS METHOD (setComputeInverseDynamics(true)) This reports specific force: the time derivative of world-frame frame velocity minus gravity. Rotating it into the frame (premultiplying by the transpose of the frame's rotation matrix) gives the ideal accelerometer reading before sensor bias and noise. This is not the same as {(time derivative of body velocity expressed in the body frame) expressed in the world frame}
Parameters
| Parameter | Description |
|---|---|
frameName (in) | name of the frame |
acc_W (out) | the frame's specific force (linear acceleration minus gravity) expressed in the world frame |
void getFrameAcceleration(const CoordinateFrame &frame, Vec<3> &acc_W) constYOU NEED TO ENABLE INVERSEDYNAMICS COMPUTATION TO USE THIS METHOD (setComputeInverseDynamics(true)) This reports specific force: the time derivative of world-frame frame velocity minus gravity. Rotating it into the frame gives the ideal accelerometer reading before sensor bias and noise.
Parameters
| Parameter | Description |
|---|---|
frame (in) | custom frame defined by the user |
acc_W (out) | the frame's specific force expressed in the world frame |
getPositionInBodyCoordinate
void getPositionInBodyCoordinate(
size_t bodyIdx,
const Vec<3> &pos_W,
Vec<3> &pos_B)Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. Note that body index and the joint index are the same because every body has one parent joint. It can be retrieved by getBodyIdx() |
pos_W (in) | the position in the world coordinate. This position does not have to be physically on the body. |
pos_B (out) | the position in the body frame |
getOrientation
void getOrientation(size_t bodyIdx, Mat<3, 3> &rot) const finalParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. Note that body index and the joint index are the same because every body has one parent joint. It can be retrieved by getBodyIdx() |
rot (out) | world-frame orientation of the joint (after its own joint transformation) |
getVelocity
void getVelocity(size_t bodyIdx, Vec<3> &vel_w) const finalParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. Note that body index and the joint index are the same because every body has one parent joint. It can be retrieved by getBodyIdx() |
vel_w (out) | world-frame linear velocity of the joint (after its own joint transformation) |
void getVelocity(const SparseJacobian &jaco, Vec<3> &pointVel) constComputes J * u with the current generalized velocity.
Parameters
| Parameter | Description |
|---|---|
jaco (in) | the Jacobian associated with the point of interest |
pointVel (out) | the velocity of the point expressed in the world frame |
void getVelocity(
size_t bodyIdx,
const Vec<3> &posInBodyFrame,
Vec<3> &pointVel) const finalParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. it can be retrieved by getBodyIdx() |
posInBodyFrame (in) | the position of the point of interest expressed in the body frame |
pointVel (out) | the velocity of the point expressed in the world frame |
void getVelocity(
size_t bodyIdx,
Frame frameOfPos,
const Vec<3> &pos,
Frame frameOfVel,
Vec<3> &pointVel) constParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. it can be retrieved by getBodyIdx() |
frameOfPos (in) | the frame in which the provided position is expressed |
pos (in) | the position of the point of interest |
frameOfVel (in) | the frame in which the computed velocity is expressed |
pointVel (out) | the velocity of the point, expressed in frameOfVel |
getAngularVelocity
void getAngularVelocity(size_t bodyIdx, Vec<3> &angVel_w) constParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. Note that body index and the joint index are the same because every body has one parent joint. It can be retrieved by getBodyIdx() |
angVel_w (out) | world-frame angular velocity of the body |
getSparseJacobian
void getSparseJacobian(
size_t bodyIdx,
const Vec<3> &point_W,
SparseJacobian &jaco) constParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. Note that body index and the joint index are the same because every body has one parent joint. It can be retrieved by getBodyIdx() |
point_W (in) | the point expressed in the world frame. If you want to use a point expressed in the body frame, use the overload taking a Frame |
jaco (out) | the positional Jacobian. v = J * u. v is the linear velocity expressed in the world frame and u is the generalized velocity. Only the columns of the joints between the body and the root are stored (jaco.idx holds their gv indices) |
void getSparseJacobian(
size_t bodyIdx,
Frame frame,
const Vec<3> &point,
SparseJacobian &jaco) constParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. Note that body index and the joint index are the same because every body has one parent joint. It can be retrieved by getBodyIdx() |
frame (in) | the frame in which the position of the point is expressed in |
point (in) | the position of the point, expressed in frame (relative to the origin of that frame) |
jaco (out) | the positional Jacobian. v = J * u. v is the linear velocity expressed in the world frame and u is the generalized velocity |
getSparseRotationalJacobian
void getSparseRotationalJacobian(size_t bodyIdx, SparseJacobian &jaco) constParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. Note that body index and the joint index are the same because every body has one parent joint. It can be retrieved by getBodyIdx() |
jaco (out) | the rotational Jacobian. omega = J * u. omgea is the angular velocity expressed in the world frame and u is the generalized velocity |
getTimeDerivativeOfSparseJacobian
void getTimeDerivativeOfSparseJacobian(
size_t bodyIdx,
Frame frame,
const Vec<3> &point,
SparseJacobian &jaco) constParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. Note that body index and the joint index are the same because every body has one parent joint. It can be retrieved by getBodyIdx() |
frame (in) | the frame in which the position of the point is expressed |
point (in) | the position of the point of interest |
jaco (out) | the time derivative of the positional Jacobian. a = dJ * u + J * du. a is the linear acceleration expressed in the world frame, u is the generalized velocity and d denotes the time derivative |
getTimeDerivativeOfSparseRotationalJacobian
void getTimeDerivativeOfSparseRotationalJacobian(
size_t bodyIdx,
SparseJacobian &jaco) constParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. Note that body index and the joint index are the same because every body has one parent joint. It can be retrieved by getBodyIdx() |
jaco (out) | the rotational Jacobian. alpha = dJ * u + J * du. alpha is the angular acceleration expressed in the world frame, u is the generalized velocity and d denotes the time derivative |
getDenseJacobian
void getDenseJacobian(
size_t bodyIdx,
const Vec<3> &point_W,
Eigen::MatrixXd &jaco) constThis method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index (fatal if out of range). Note that body index and the joint index are the same because every body has one parent joint |
point_W (in) | the point expressed in the world frame. If you want to use a point expressed in the body frame, use getDenseFrameJacobian() |
jaco (out) | the dense positional Jacobian. It must be pre-sized to 3 x getDOF() (fatal otherwise) |
getDenseRotationalJacobian
void getDenseRotationalJacobian(size_t bodyIdx, Eigen::MatrixXd &jaco) constThis method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index (fatal if out of range). it can be retrieved by getBodyIdx() |
jaco (out) | the dense rotational Jacobian (omega_W = J * u). It must be pre-sized to 3 x getDOF() (fatal otherwise) |
getDenseFrameJacobian
void getDenseFrameJacobian(size_t frameIdx, Eigen::MatrixXd &jaco) constThis method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!
Parameters
| Parameter | Description |
|---|---|
frameIdx (in) | the frame index. it can be retrieved by getFrameIdxByName() |
jaco (out) | the dense positional Jacobian of the frame origin. It must be pre-sized to 3 x getDOF() |
void getDenseFrameJacobian(
const std::string &frameName,
Eigen::MatrixXd &jaco) constThis method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!
Parameters
| Parameter | Description |
|---|---|
frameName (in) | the frame name. (defined in the URDF) |
jaco (out) | the dense positional Jacobian of the frame origin. It must be pre-sized to 3 x getDOF() |
getDenseFrameRotationalJacobian
void getDenseFrameRotationalJacobian(
size_t frameIdx,
Eigen::MatrixXd &jaco) constThis method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!
Parameters
| Parameter | Description |
|---|---|
frameIdx (in) | the frame index. it can be retrieved by getFrameIdxByName() |
jaco (out) | the dense rotational Jacobian. It must be pre-sized to 3 x getDOF() |
void getDenseFrameRotationalJacobian(
const std::string &frameName,
Eigen::MatrixXd &jaco) constThis method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!
Parameters
| Parameter | Description |
|---|---|
frameName (in) | the frame name. (defined in the URDF) |
jaco (out) | the dense rotational Jacobian. It must be pre-sized to 3 x getDOF() |
solveIK
IKResult solveIK(const std::string &frameName, const Vec<3> &targetPosition)Solve inverse kinematics for a named frame using the current articulated-system state, frame FK, the positional Jacobian of the frame origin and (for orientation targets) a finite-difference rotational Jacobian. By default, the solution is applied on success. The returned solution is a generalized coordinate vector. Currently supports dls, pinv, svd, and transpose inverse methods. Uses default IKOptions (position only).
Parameters
| Parameter | Description |
|---|---|
frameName (in) | frame name (see getFrameIdxByName()) |
targetPosition (in) | world-frame target position of the frame origin [m] |
Returns the solver result. An unknown frame yields success == false and a message
IKResult solveIK(
const std::string &frameName,
const Vec<3> &targetPosition,
const IKOptions &options)Position-only inverse kinematics for a named frame. options.useOrientation is ignored (no orientation target is given).
Parameters
| Parameter | Description |
|---|---|
frameName (in) | frame name (see getFrameIdxByName()) |
targetPosition (in) | world-frame target position of the frame origin [m] |
options (in) | solver options |
Returns the solver result
IKResult solveIK(
const std::string &frameName,
const Vec<3> &targetPosition,
const Mat<3, 3> &targetOrientation,
IKOptions options)Solve inverse kinematics for a named frame with a position and orientation target. This overload always enables the orientation task.
Parameters
| Parameter | Description |
|---|---|
frameName (in) | frame name (see getFrameIdxByName()) |
targetPosition (in) | world-frame target position of the frame origin [m] |
targetOrientation (in) | world-frame target orientation of the frame |
options (in) | solver options (useOrientation is forced to true) |
Returns the solver result
IKResult solveIK(
const std::string &frameName,
const Vec<3> &targetPosition,
const Mat<3, 3> &targetOrientation)Position and orientation inverse kinematics for a named frame with default IKOptions.
Parameters
| Parameter | Description |
|---|---|
frameName (in) | frame name (see getFrameIdxByName()) |
targetPosition (in) | world-frame target position of the frame origin [m] |
targetOrientation (in) | world-frame target orientation of the frame |
Returns the solver result
IKResult solveIK(size_t frameIdx, const Vec<3> &targetPosition)Solve inverse kinematics for a frame index using the current articulated-system state. Uses default IKOptions (position only).
Parameters
| Parameter | Description |
|---|---|
frameIdx (in) | frame index (see getFrameIdxByName()) |
targetPosition (in) | world-frame target position of the frame origin [m] |
Returns the solver result
IKResult solveIK(
size_t frameIdx,
const Vec<3> &targetPosition,
const IKOptions &options)Position-only inverse kinematics for a frame index. options.useOrientation is ignored (no orientation target is given).
Parameters
| Parameter | Description |
|---|---|
frameIdx (in) | frame index (see getFrameIdxByName()) |
targetPosition (in) | world-frame target position of the frame origin [m] |
options (in) | solver options |
Returns the solver result
IKResult solveIK(
size_t frameIdx,
const Vec<3> &targetPosition,
const Mat<3, 3> &targetOrientation,
const IKOptions &options)Solve inverse kinematics for a frame index with a position and optional orientation target. Set options.useOrientation=true to activate the orientation target. Unless a solution is applied (see IKOptions::applySolution and IKOptions::applyBestOnFailure), the generalized coordinate is restored to its value before the call.
Parameters
| Parameter | Description |
|---|---|
frameIdx (in) | frame index (see getFrameIdxByName()). An invalid index yields success == false |
targetPosition (in) | world-frame target position of the frame origin [m] |
targetOrientation (in) | world-frame target orientation of the frame |
options (in) | solver options |
Returns the solver result
getBodyIdx
size_t getBodyIdx(const std::string &nm) constreturns the index of the body
Parameters
| Parameter | Description |
|---|---|
nm (in) | name of the body. The body name is the name of the movable link of the body |
Returns the index of the body. Returns size_t(-1) if the body doesn't exist. Fatal if nm names a link that was merged into its parent through a fixed joint (use a frame instead).
getDOF
size_t getDOF() constReturns the degrees of freedom
getGeneralizedVelocityDim
size_t getGeneralizedVelocityDim() constReturns the dimension of generalized velocity (do the same thing with getDOF)
getGeneralizedCoordinateDim
size_t getGeneralizedCoordinateDim() constReturns the dimension of generalized coordinate
getBodyPose
void getBodyPose(
size_t bodyIdx,
Mat<3, 3> &orientation,
Vec<3> &position) constThe body pose is the pose of its parent joint (after its joint transformation)
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. it can be retrieved by getBodyIdx() |
orientation (out) | world-frame orientation of the body |
position (out) | world-frame position of the body [m] |
getBodyPosition
void getBodyPosition(size_t bodyIdx, Vec<3> &position) constThe body position is the position of its parent joint (after its joint transformation)
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. it can be retrieved by getBodyIdx() |
position (out) | world-frame position of the body [m] |
getBodyOrientation
void getBodyOrientation(size_t bodyIdx, Mat<3, 3> &orientation) constThe body orientation is the orientation of its parent joint (after its joint transformation)
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. it can be retrieved by getBodyIdx() |
orientation (out) | world-frame orientation of the body |
getJointPos_P
std::vector<raisim::Vec<3>> &getJointPos_P()The following 5 methods can be used to directly modify dynamic/kinematic properties of the robot. They are made for dynamic randomization. Use them with caution since they will change the the model permenantly. After you change the dynamic properties, call "void updateMassInfo()" to update some precomputed dynamic properties. The loop constraints check the joint placements again in the next step after one of these methods or updateMassInfo() was called; if you keep the returned reference and change the placements through it later, call updateMassInfo() afterwards
Returns a reference to joint position relative to its parent, expressed in the parent frame, indexed by body index [m].
const std::vector<raisim::Vec<3>> &getJointPos_P() constReturns joint position relative to its parent, expressed in the parent frame, indexed by body index [m].
getJointOrientation_P
std::vector<raisim::Mat<3, 3>> &getJointOrientation_P()Returns a reference to joint orientation relative to its parent body frame (at zero joint coordinate), indexed by body index.
const std::vector<raisim::Mat<3, 3>> &getJointOrientation_P() constReturns joint orientation relative to its parent body frame (at zero joint coordinate), indexed by body index.
getJointAxis_P
std::vector<raisim::Vec<3>> &getJointAxis_P()Returns a reference to joint axes, indexed by body index. Each axis is expressed in the joint frame, i.e., the parent body frame rotated by getJointOrientation_P().
const std::vector<raisim::Vec<3>> &getJointAxis_P() constReturns joint axes expressed in the joint frame, indexed by body index.
getJointAxis
const raisim::Vec<3> &getJointAxis(size_t idx) constParameters
| Parameter | Description |
|---|---|
idx (in) | body (joint) index |
Returns a reference to joint axis expressed in the world frame.
getMass
std::vector<double> &getMass()You MUST call updateMassInfo() after you change the mass
Returns a reference to mass of each body, indexed by body index [kg].
const std::vector<double> &getMass() constReturns mass of each body, indexed by body index [kg].
double getMass(size_t bodyIdx) const finalParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index. it can be retrieved by getBodyIdx() |
Returns mass of the body
getInertia
std::vector<raisim::Mat<3, 3>> &getInertia()Returns a reference to inertia of each body about its COM, expressed in the body frame, indexed by body index [kg m^2].
const std::vector<raisim::Mat<3, 3>> &getInertia() constReturns inertia of each body about its COM, expressed in the body frame, indexed by body index [kg m^2].
getBodyCOM_B
std::vector<raisim::Vec<3>> &getBodyCOM_B()Returns a reference to the position of the center of the mass of each body in the body frame, indexed by body index [m].
const std::vector<raisim::Vec<3>> &getBodyCOM_B() constReturns position of the center of the mass of each body in the body frame, indexed by body index [m].
getBodyCOM_W
std::vector<raisim::Vec<3>> &getBodyCOM_W()Updated by updateKinematics() (and therefore by every state setter and integration step).
Returns a reference to the position of the center of the mass of each body in the world frame, indexed by body index [m].
const std::vector<raisim::Vec<3>> &getBodyCOM_W() constReturns position of the center of the mass of each body in the world frame, indexed by body index [m].
getCollisionBodies
raisim::CollisionSet &getCollisionBodies()Returns a reference to the collision bodies. Position and orientation can be set dynamically
const raisim::CollisionSet &getCollisionBodies() constReturns the collision bodies of the system
getIgnoredCollisionPairs
const std::vector<std::pair<size_t, size_t>> &getIgnoredCollisionPairs() constReturns body index pairs (smaller index first) registered by ignoreCollisionBetween()
getCollisionBody
raisim::CollisionDefinition &getCollisionBody(const std::string &name)Fatal if no collision body has the given name.
Parameters
| Parameter | Description |
|---|---|
name | collision body name which is "LINK_NAME" + "/" + "COLLISION_NUMBER". For example, the first collision body of the link "base" is named as "base/0" |
Returns a reference to the collision bodies. Position and orientation can be set dynamically
const raisim::CollisionDefinition &getCollisionBody(const std::string &name) constConst overload of getCollisionBody(). Fatal if no collision body has the given name.
Parameters
| Parameter | Description |
|---|---|
name (in) | collision body name |
Returns the collision body
updateMassInfo
void updateMassInfo()This method updates the precomputed composite mass. Call this method after you change link mass. This also updates the composite centers of mass (getCompositeCOM()) without integration
setMass
void setMass(size_t bodyIdx, double value)set body mass. It is indexed for each body, not for individual link. Check this link (https://raisim.com/sections/ArticulatedSystem.html#introduction) to understand the difference between a link and a body. This does not call updateMassInfo().
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | body index (fatal if out of range) |
value (in) | mass [kg] |
getTotalMass
double getTotalMass() constUses the composite mass, so call updateMassInfo() after changing body masses.
Returns the total mass of the system [kg].
setExternalForce
void setExternalForce(size_t bodyIdx, const Vec<3> &force) finalset external forces or torques expressed in the world frame acting on the COM of the body. The external force is applied for a single time step only. You have to apply the force for every time step if you want persistent force
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index (fatal if out of range). it can be retrieved by getBodyIdx() |
force (in) | world-frame force applied to the body (at the center of mass) [N] |
void setExternalForce(
size_t bodyIdx,
Frame frameOfForce,
const Vec<3> &force,
Frame frameOfPos,
const Vec<3> &pos)set external force acting on the point specified The external force is applied for a single time step only. You have to apply the force for every time step if you want persistent force
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index (fatal if out of range). it can be retrieved by getBodyIdx() |
frameOfForce (in) | the frame in which the force is expressed. Options: Frame::WORLD_FRAME, Frame::PARENT_FRAME or Frame::BODY_FRAME |
force (in) | the applied force |
frameOfPos (in) | the frame in which the position vector is expressed. Options: Frame::WORLD_FRAME, Frame::PARENT_FRAME or Frame::BODY_FRAME |
pos (in) | position at which the force is applied |
void setExternalForce(
size_t bodyIdx,
const Vec<3> &pos,
const Vec<3> &force) finalset external force (expressed in the world frame) acting on the point (expressed in the body frame) specified The external force is applied for a single time step only. You have to apply the force for every time step if you want persistent force
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index (fatal if out of range). it can be retrieved by getBodyIdx() |
pos (in) | position at which the force is applied, expressed in the body frame [m] |
force (in) | the applied force, expressed in the world frame [N] |
void setExternalForce(const std::string &frame_name, const Vec<3> &force)set external force (expressed in the world frame) acting on the point specified by the frame The external force is applied for a single time step only. You have to apply the force for every time step if you want persistent force
Parameters
| Parameter | Description |
|---|---|
frame_name (in) | the name of the frame where you want to applied the force. The force is applied to the origin of the frame, on the body where the frame is attached to. |
force (in) | the applied force in the world frame |
setExternalTorque
void setExternalTorque(
size_t bodyIdx,
const Vec<3> &torque_in_world_frame) finalset external torque. The external torque is applied for a single time step only. You have to apply the force for every time step if you want persistent torque
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index (fatal if out of range). it can be retrieved by getBodyIdx() |
torque_in_world_frame (in) | the applied torque expressed in the world frame [Nm] |
setExternalTorqueInBodyFrame
void setExternalTorqueInBodyFrame(
size_t bodyIdx,
const Vec<3> &torque_in_body_frame)set external torque. The external torque is applied for a single time step only. You have to apply the force for every time step if you want persistent torque
Parameters
| Parameter | Description |
|---|---|
bodyIdx (in) | the body index (fatal if out of range). it can be retrieved by getBodyIdx() |
torque_in_body_frame (in) | the applied torque expressed in the body frame [Nm] |
getContactPointVel
void getContactPointVel(size_t contactId, Vec<3> &vel) const finalreturns the contact point velocity. The contactId is the order in the vector from Object::getContacts() It uses the generalized velocity of the contact solver (the post-contact velocity after a step).
Parameters
| Parameter | Description |
|---|---|
contactId (in) | index of the contact vector which can be obtained by getContacts() |
vel (out) | the world-frame contact point velocity |
setControlMode
void setControlMode(ControlMode::Type mode)setPdGains() and setPTarget() switch to ControlMode::PD_PLUS_FEEDFORWARD_TORQUE automatically.
Parameters
| Parameter | Description |
|---|---|
mode (in) | control mode. Can be either ControlMode::FORCE_AND_TORQUE or ControlMode::PD_PLUS_FEEDFORWARD_TORQUE |
getControlMode
ControlMode::Type getControlMode() constReturns control mode. Can be either ControlMode::FORCE_AND_TORQUE or ControlMode::PD_PLUS_FEEDFORWARD_TORQUE
setPdTarget
void setPdTarget(
const Eigen::VectorXd &posTarget,
const Eigen::VectorXd &velTarget)set PD targets. Effective only in ControlMode::PD_PLUS_FEEDFORWARD_TORQUE (this does not change the control mode).
Parameters
| Parameter | Description |
|---|---|
posTarget (in) | position target (dimension == getGeneralizedCoordinateDim(); quaternions for spherical joints) |
velTarget (in) | velocity target (dimension == getDOF()) |
void setPdTarget(
const raisim::VecDyn &posTarget,
const raisim::VecDyn &velTarget)set PD targets. Effective only in ControlMode::PD_PLUS_FEEDFORWARD_TORQUE (this does not change the control mode).
Parameters
| Parameter | Description |
|---|---|
posTarget (in) | position target (dimension == getGeneralizedCoordinateDim()) |
velTarget (in) | velocity target (dimension == getDOF()) |
getPdTarget
void getPdTarget(Eigen::VectorXd &posTarget, Eigen::VectorXd &velTarget)get PD targets. The outputs must already have the right size (fatal otherwise).
Parameters
| Parameter | Description |
|---|---|
posTarget (out) | position target (dimension == getGeneralizedCoordinateDim()) |
velTarget (out) | velocity target (dimension == getDOF()) |
setPTarget
template <class T>
void setPTarget(const T &posTarget)set P targets. This also switches to ControlMode::PD_PLUS_FEEDFORWARD_TORQUE.
Parameters
| Parameter | Description |
|---|---|
posTarget (in) | position target (dimension == getGeneralizedCoordinateDim()) |
setDTarget
template <class T>
void setDTarget(const T &velTarget)set D targets.
Parameters
| Parameter | Description |
|---|---|
velTarget (in) | velocity target (dimension == getDOF()) |
setPdGains
void setPdGains(const Eigen::VectorXd &pgain, const Eigen::VectorXd &dgain)set PD gains. This also switches to ControlMode::PD_PLUS_FEEDFORWARD_TORQUE. The first 6 entries are forced to zero for a floating base.
Parameters
| Parameter | Description |
|---|---|
pgain (in) | position gain (dimension == getDOF()) |
dgain (in) | velocity gain (dimension == getDOF()) |
void setPdGains(const raisim::VecDyn &pgain, const raisim::VecDyn &dgain)set PD gains. This also switches to ControlMode::PD_PLUS_FEEDFORWARD_TORQUE. The first 6 entries are forced to zero for a floating base.
Parameters
| Parameter | Description |
|---|---|
pgain (in) | position gain (dimension == getDOF()) |
dgain (in) | velocity gain (dimension == getDOF()) |
getPdGains
void getPdGains(Eigen::VectorXd &pgain, Eigen::VectorXd &dgain)get PD gains.
Parameters
| Parameter | Description |
|---|---|
pgain (out) | position gain (dimension == getDOF()) |
dgain (out) | velocity gain (dimension == getDOF()) |
setPGains
template <class T>
void setPGains(const T &pgain)set P gain. The first 6 entries are forced to zero for a floating base. This does not change the control mode.
Parameters
| Parameter | Description |
|---|---|
pgain (in) | position gain (dimension == getDOF()) |
setDGains
template <class T>
void setDGains(const T &dgain)set D gains. The first 6 entries are forced to zero for a floating base. This does not change the control mode.
Parameters
| Parameter | Description |
|---|---|
dgain (in) | velocity gain (dimension == getDOF()) |
getJointDamping
const raisim::VecDyn &getJointDamping() constReturns the current passive joint damping coefficients in generalized velocity order (size getDOF()). Initially loaded from the model, then replaced by setJointDamping(). Excludes actuator output damping and PD gains.
setJointDamping
void setJointDamping(const Eigen::VectorXd &dampingCoefficient)passive elements at the joints. They can be specified in the URDF file as well. Check Object/ArticulatedSystem/URDF convention in the manual
Parameters
| Parameter | Description |
|---|---|
dampingCoefficient (in) | the damping coefficient vector, acting at each degrees of freedom (dimension == getDOF(); fatal otherwise) |
void setJointDamping(const raisim::VecDyn &dampingCoefficient)passive elements at the joints. They can be specified in the URDF file as well. Check Object/ArticulatedSystem/URDF convention in the manual
Parameters
| Parameter | Description |
|---|---|
dampingCoefficient (in) | the damping coefficient vector, acting at each degrees of freedom (dimension == getDOF(); fatal otherwise) |
computeSparseInverse
void computeSparseInverse(const MatDyn &M, MatDyn &Minv) noexceptThis computes the inverse mass matrix given the mass matrix. The return type is dense. It exploits the sparsity of the mass matrix to efficiently perform the computation. The outcome also contains effects of the joint damping, the springs and the PD gains (see getInverseMassMatrix())
Parameters
| Parameter | Description |
|---|---|
M (in) | mass matrix |
Minv (out) | inverse mass matrix |
massMatrixVecMul
void massMatrixVecMul(const VecDyn &vec1, VecDyn &vec) constthis method exploits the sparsity of the mass matrix. If the mass matrix is nearly dense, it will be slower than your ordinary matrix multiplication which is probably vectorized vec = M * vec1, where M is the mass matrix last computed (e.g., by getMassMatrix())
Parameters
| Parameter | Description |
|---|---|
vec1 (in) | input vector (size getDOF(); fatal otherwise) |
vec (out) | output vector, resized to getDOF() |
ignoreCollisionBetween
void ignoreCollisionBetween(size_t bodyIdx1, size_t bodyIdx2)The bodies specified here will not collide. If the system is already in a world, call updateSelfCollisionCache() afterwards.
Parameters
| Parameter | Description |
|---|---|
bodyIdx1 (in) | first body index |
bodyIdx2 (in) | second body index |
updateSelfCollisionCache
void updateSelfCollisionCache(World &world)Refresh contact body metadata in the world contact detector. Call this after changing collision ignore settings at runtime.
Parameters
| Parameter | Description |
|---|---|
world (in) | the world that owns this articulated system |
getOptions
ArticulatedSystemOption getOptions() constReturns a copy of the options the system was created with
getBodyNames
const std::vector<std::string> &getBodyNames() constReturns a vector of body names (following the joint order)
getVisOb
std::vector<VisObject> &getVisOb()Returns a vector of visualized bodies
const std::vector<VisObject> &getVisOb() constReturns a vector of visualized bodies
getVisColOb
std::vector<VisObject> &getVisColOb()Returns a vector of visualized collision bodies (same order as getCollisionBodies())
const std::vector<VisObject> &getVisColOb() constReturns a vector of visualized collision bodies (same order as getCollisionBodies())
getVisObPose
void getVisObPose(size_t visObjIdx, Mat<3, 3> &rot, Vec<3> &pos) constParameters
| Parameter | Description |
|---|---|
visObjIdx (in) | visual object index. Following the order specified by the vector getVisOb() |
rot (out) | world-frame orientation |
pos (out) | world-frame position [m] |
getVisColObPose
void getVisColObPose(size_t visColObjIdx, Mat<3, 3> &rot, Vec<3> &pos) constParameters
| Parameter | Description |
|---|---|
visColObjIdx (in) | visual collision object index. Following the order specified by the vector getVisColOb() |
rot (out) | world-frame orientation |
pos (out) | world-frame position [m] |
getResourceDir
const std::string &getResourceDir() constReturns the resource directory (for mesh files, textures, etc)
getRobotDescriptionfFileName
const std::string &getRobotDescriptionfFileName() constReturns the file name (with extension) of the robot description file (empty if the robot was not created from a file path)
getRobotDescriptionfTopDirName
const std::string &getRobotDescriptionfTopDirName() constReturns the name of the directory containing the robot description file (not the full path; empty if the robot was not created from a file)
getRobotDescriptionFullPath
const std::string &getRobotDescriptionFullPath() constReturns the full path to the URDF file (returns empty string if the robot was not specified by a URDF file)
getRobotDescription
const std::string &getRobotDescription() constReturns if the object was instantiated with raw URDF string, it returns the string
exportRobotDescriptionToURDF
void exportRobotDescriptionToURDF(const std::string &filePath) constif the object was instantiated with raw URDF string, it exports the robot description to an URDF file. Fatal if there is no stored description or filePath does not end with ".urdf".
Parameters
| Parameter | Description |
|---|---|
filePath (in) | Path where the file is generated |
setBasePos_e
void setBasePos_e(const Eigen::Vector3d &pos)set the base position using an eigen vector. For a fixed base, this moves the fixed base pose.
Parameters
| Parameter | Description |
|---|---|
pos (in) | world-frame position of the base [m] |
setBaseOrientation_e
void setBaseOrientation_e(const Eigen::Matrix3d &rot)set the base orientation using an eigen matrix. For a fixed base, this moves the fixed base pose.
Parameters
| Parameter | Description |
|---|---|
rot (in) | world-frame orientation of the base |
setBasePos
void setBasePos(const Vec<3> &pos)set the base position. For a floating base this writes gc[0..2]; for a fixed base, it moves the fixed base.
Parameters
| Parameter | Description |
|---|---|
pos (in) | world-frame position of the base [m] |
setBaseOrientation
void setBaseOrientation(const Mat<3, 3> &rot)set the base orientation using a raisim rotation matrix (i.e., Mat<3,3>). For a fixed base, it rotates the fixed base.
Parameters
| Parameter | Description |
|---|---|
rot (in) | world-frame orientation of the base |
void setBaseOrientation(const Vec<4> &quat)set the base orientation using a raisim quaternion (i.e., Vec<4>). For a fixed base, it rotates the fixed base.
Parameters
| Parameter | Description |
|---|---|
quat (in) | world-frame orientation of the base as a quaternion (w,x,y,z) |
setBaseVelocity
void setBaseVelocity(const Vec<3> &vel)set the base linear velocity (gv[0..2]). Only for a floating base (prints a warning otherwise).
Parameters
| Parameter | Description |
|---|---|
vel (in) | the world-frame linear velocity of the base [m/s] |
setBaseAngularVelocity
void setBaseAngularVelocity(const Vec<3> &vel)set the base angular velocity (gv[3..5]). Only for a floating base (prints a warning otherwise).
Parameters
| Parameter | Description |
|---|---|
vel (in) | the world-frame angular velocity of the base [rad/s] |
setActuationLimits
void setActuationLimits(
const Eigen::VectorXd &upper,
const Eigen::VectorXd &lower)set limits in actuation force. It can be also specified in the URDF file. The limits clamp the sum of feedforward and PD actuator forces (not external forces or springs).
Parameters
| Parameter | Description |
|---|---|
upper (in) | upper joint force/torque limit (dimension == getDOF(); fatal otherwise) |
lower (in) | lower joint force/torque limit (dimension == getDOF(); fatal otherwise) |
getCollisionVisualRevision
std::uint64_t getCollisionVisualRevision() constRevision of collision geometry shown by remote viewers. Offset and shape edits require a fresh initialization record so body-frame markers stay aligned.
getActuationUpperLimits
const VecDyn &getActuationUpperLimits() constReturns the upper joint torque/force limit
getActuationLowerLimits
const VecDyn &getActuationLowerLimits() constReturns the lower joint torque/force limit
setActuators
void setActuators(const std::vector<ActuatorDefinition> &actuators)Define the actuators of the robot. An actuator is a motor with its gear; it drives one revolute or prismatic joint, and its motor can also turn with other joints (couplings, see ActuatorDefinition). Actuators can also be defined in the URDF with <actuator> elements.
The actuators are commanded with setActuatorTorques(). Every step, each actuator's motor torque is clipped to the motor operating region (EM-MOR, the bus-voltage and peak-torque limits) at the motor's speed at the beginning of the step, and the clipped torque drives the joints for the whole step. The region limits only the torque, not the speed: external forces can drive a motor at any speed. Torques from setGeneralizedForce(), the built-in PD controller, joint damping, springs and friction are added on top and are not clipped by the region.
At the voltage limit the motor acts as a damper of G^2 Kt / (R Kv) at the joint (G the gear ratio), applied explicitly. It settles at the no-load speed for time steps below twice the motor's mechanical time constant, 2 I R Kv / (G^2 Kt) (I the inertia at the joint, including the reflected rotor inertia); with larger steps the speed oscillates around the no-load speed, with the torque inside the region. Replaces the existing actuators and resets the actuator torques to zero; an empty vector removes all actuators.
Parameters
| Parameter | Description |
|---|---|
actuators (in) | actuators. A joint can be driven by only one actuator. |
getNumberOfActuators
size_t getNumberOfActuators() constReturns the number of actuators
getActuatorNames
const std::vector<std::string> &getActuatorNames() constThe order of the actuators is the order of setActuators() (or of the <actuator> elements of the URDF), and of setActuatorTorques() and getActuatorStates().
Returns the actuator names in order
getActuators
const std::vector<ActuatorDefinition> &getActuators() constReturns the actuators as defined in the URDF or by setActuators(), with the bus voltages set since. Every actuator has its name (getActuatorNames()).
getActuatorIndex
size_t getActuatorIndex(const std::string &name) constParameters
| Parameter | Description |
|---|---|
name (in) | actuator name (getActuatorNames()) |
Returns the actuator index, or size_t(-1) if there is no actuator with the name
getTracks
const std::vector<Track> &getTracks() constThe tracks (continuous belts) defined by the URDF <track> elements, in their order there. A track's belt moves with its drive joints, so it is controlled through those joints (PD targets, torques or actuators). See Track.
Returns the tracks
getTrackIndex
size_t getTrackIndex(const std::string &name) constParameters
| Parameter | Description |
|---|---|
name (in) | track name |
Returns the track index, or size_t(-1) if there is no track with the name
getTrackSpeed
double getTrackSpeed(size_t trackIndex) constThe belt speed of a track: sum(gain * joint velocity) over its drives. A positive speed moves the belt counter-clockwise seen from the track axis, so with the axis along the body's +y, the bottom of the belt moves backwards and the robot forwards.
Parameters
| Parameter | Description |
|---|---|
trackIndex (in) | track index (getTracks() order) |
Returns the belt speed [m/s]
setActuatorTorques
void setActuatorTorques(const Eigen::VectorXd &torques)Set the torque of every actuator at the output of its gear: the motor torque times the gear ratio. It is the torque on the joint the actuator drives; an actuator with couplings also applies its motor torque times the coupling ratio to each coupled joint. The torques hold until they are set again. Every step, the motor torques are clipped to the motor operating regions at the motor speeds at the beginning of the step and mapped to the joints. They add to everything else; the actuation limits (URDF effort) do not clip them.
Parameters
| Parameter | Description |
|---|---|
torques (in) | actuator torques [Nm or N], ordered like getActuatorNames() |
setActuatorTorque
void setActuatorTorque(const std::string &name, double torque)Set the torque of one actuator (see setActuatorTorques()).
Parameters
| Parameter | Description |
|---|---|
name (in) | actuator name (getActuatorNames()) |
torque (in) | actuator torque at the output of its gear [Nm or N] |
void setActuatorTorque(size_t index, double torque)Set the torque of one actuator (see setActuatorTorques()).
Parameters
| Parameter | Description |
|---|---|
index (in) | actuator index (getActuatorNames() order) |
torque (in) | actuator torque at the output of its gear [Nm or N] |
getActuatorTorques
const std::vector<double> &getActuatorTorques() constReturns the actuator torques set with setActuatorTorques(), ordered like getActuatorNames()
getActuatorTorqueBounds
void getActuatorTorqueBounds(VecDyn &lower, VecDyn &upper) constThe torques every actuator can apply now, at the output of its gear: its motor's operating region at the current motor speed, times its gear ratio. These are the bounds the next step clips setActuatorTorques() to (with the region not enforced, they are infinite). For the motor alone, without the gear, see motorTorqueBounds().
Parameters
| Parameter | Description |
|---|---|
lower (out) | lowest admissible actuator torque [Nm or N], ordered like getActuatorNames() |
upper (out) | highest admissible actuator torque [Nm or N], ordered like getActuatorNames() |
setBusVoltage
void setBusVoltage(double voltage)Set the bus voltage of the motors of all actuators, e.g., to follow the battery voltage or to randomize it. Only the voltage changes; it is cheap enough to call every step.
Parameters
| Parameter | Description |
|---|---|
voltage (in) | bus voltage [V] (positive) |
void setBusVoltage(const std::string &actuatorName, double voltage)Set the bus voltage of the motor of one actuator.
Parameters
| Parameter | Description |
|---|---|
actuatorName (in) | actuator name (getActuatorNames()) |
voltage (in) | bus voltage [V] (positive) |
getActuatorStates
const std::vector<ActuatorState> &getActuatorStates() constThe states are captured at the end of integration. Reading does not mutate the snapshot, and later setState() calls cannot mix a new velocity into the previous step. Concurrent readers are supported while no thread integrates or changes the actuator configuration.
Returns the actuator states of the last step, ordered like getActuatorNames(). Use (motorSpeed, motorTorque) to check an actuator's motor against its operating region.
setMotorOperatingRegionEnforced
void setMotorOperatingRegionEnforced(bool enforce)When disabled, actuator torques are added as set with setActuatorTorques(), and getActuatorStates() reports how far they leave the motor operating regions.
Parameters
| Parameter | Description |
|---|---|
enforce (in) | clip motor torques to the motor operating region (default true) |
isMotorOperatingRegionEnforced
bool isMotorOperatingRegionEnforced() constReturns if motor torques are clipped to the motor operating region
setCollisionBodyShapeParameters
void setCollisionBodyShapeParameters(size_t id, const Vec<4> ¶ms)change collision geom parameters. Only primitive shapes are supported (fatal for meshes); all used parameters must be positive and finite. The collision visual is updated as well.
Parameters
| Parameter | Description |
|---|---|
id (in) | collision object id (index in getCollisionBodies()) |
params (in) | collision object parameters (depending on the object) [m]. For a sphere, {radius}. For a cylinder and a capsule, {radius, length} For a box, {x-dim, y-dim, z-dim} (full side lengths) |
setCollisionBodyPositionOffset
void setCollisionBodyPositionOffset(size_t id, const Vec<3> &posOffset)change collision geom offset from the joint position. The collision visual is updated as well.
Parameters
| Parameter | Description |
|---|---|
id (in) | collision object id (index in getCollisionBodies()) |
posOffset (in) | the position vector expressed in the joint frame [m] |
setCollisionBodyOrientationOffset
void setCollisionBodyOrientationOffset(
size_t id,
const Mat<3, 3> &oriOffset)change collision geom orientation offset from the joint frame. The collision visual is updated as well.
Parameters
| Parameter | Description |
|---|---|
id (in) | collision object id (index in getCollisionBodies()) |
oriOffset (in) | the orientation relative to the joint frame (must be a proper rotation matrix) |
setRotorInertia
void setRotorInertia(const VecDyn &rotorInertia)rotor inertia is a term added to the diagonal of the mass matrix. This approximates the rotor inertia. Note that this is not exactly equivalent in dynamics (due to gyroscopic effect). but it is a commonly used approximation. It can also be expressed in the URDF file
Parameters
| Parameter | Description |
|---|---|
rotorInertia (in) | the rotor inertia (dimension == getDOF(); fatal otherwise) |
getRotorInertia
const VecDyn &getRotorInertia() constrotor inertia is a term added to the diagonal of the mass matrix. This approximates the rotor inertia. Note that this is not exactly equivalent in dynamics (due to gyroscopic effect). but it is a commonly used approximation. It can also be expressed in the URDF file
Returns the rotor inertia
getJointType
Joint::Type getJointType(size_t jointIndex)The joint index is the body index (joint i connects body i to its parent; joint 0 is the base joint). Joints are in the same order as the elements of the generalized velocity, but the indices differ because some joints have multiple degrees of freedom (see getMappingFromBodyIndexToGeneralizedVelocityIndex())
Parameters
| Parameter | Description |
|---|---|
jointIndex (in) | the joint index |
Returns the joint type
Joint::Type getJointType(size_t jointIndex) constConst overload of getJointType().
Parameters
| Parameter | Description |
|---|---|
jointIndex (in) | the joint (body) index |
Returns the joint type
getNumberOfJoints
size_t getNumberOfJoints() constReturns the number of joints (same as the number of bodies)
getJoint
JointRef getJoint(const std::string &name)returns reference object of the joint. Fatal if no frame has the given name.
Parameters
| Parameter | Description |
|---|---|
name (in) | joint name (frame name, see getFrameIdxByName()) |
Returns a JointRef to the joint. Check the example JointRefAndLinkRef
getLink
LinkRef getLink(const std::string &name)returns reference object of the link. Fatal if no body has the given name (links merged into a parent through fixed joints are not bodies).
Parameters
| Parameter | Description |
|---|---|
name (in) | the link name |
Returns a LinkRef to the link. Check the example JointRefAndLinkRef
getMappingFromBodyIndexToGeneralizedVelocityIndex
const std::vector<size_t> &getMappingFromBodyIndexToGeneralizedVelocityIndex() constReturns a mapping that converts body index to gv index (of the first element of the body's parent joint). The entry of a fixed base is size_t(-1)
getMappingFromBodyIndexToGeneralizedCoordinateIndex
const std::vector<size_t> &getMappingFromBodyIndexToGeneralizedCoordinateIndex() constReturns a mapping that converts body index to gc index (of the first element of the body's parent joint). The entry of a fixed base is size_t(-1)
getObjectType
ObjectType getObjectType() const finalReturns the object type (ARTICULATED_SYSTEM)
getBodyType
BodyType getBodyType(size_t bodyIdx) const finalParameters
| Parameter | Description |
|---|---|
bodyIdx (in) | body index |
Returns the body type (STATIC, KINEMATIC, or DYNAMIC) of the specified body. It is always DYNAMIC except for the fixed base (STATIC)
BodyType getBodyType() const finalReturns the body type (STATIC, KINEMATIC, or DYNAMIC). It is always dynamic
setIntegrationScheme
void setIntegrationScheme(IntegrationScheme scheme)Parameters
| Parameter | Description |
|---|---|
scheme (in) | the integration scheme. Can be either TRAPEZOID, SEMI_IMPLICIT (the default), EULER, or RUNGE_KUTTA_4. SEMI_IMPLICIT moves the positions with the velocity the contact solver leaves, so an impact that stops a body stops its position too; TRAPEZOID sinks by up to half a step's travel. TRAPEZOID is exact only for constant forces (a projectile); under forces that depend on the state (gravity on a joint, springs, PD control, the gyroscopic force) it gains energy, and SEMI_IMPLICIT does not. RUNGE_KUTTA_4 is useful for systems with few contacts and when the integration accuracy is important. In the PD control mode, SEMI_IMPLICIT replaces EULER and RUNGE_KUTTA_4 once the system has been in contact (from the step after its first contact), until its state is set again with setState(), setGeneralizedCoordinate() or an applied solveIK() solution. SEMI_IMPLICIT also replaces RUNGE_KUTTA_4 while the system has pin, equality or mimic constraints: they are eliminated from the velocity of one step, which the Runge-Kutta stages would leave. |
getJointLimitViolations
std::vector<contact::Single3DContactProblem const *> getJointLimitViolations(const contact::ContactProblems &problemListFromWorld)usage example: For 1d joints (e.g., revolute or prismatic), you can get the impulse due to the joint limit as robot.getJointLimitViolations()[0]->imp_i[0] For a ball joint, all three components of imp_i represent the torque in the 3d space. The following joint returns the joint/body Id robot.getJointLimitViolations()[0]->jointId.
Parameters
| Parameter | Description |
|---|---|
problemListFromWorld (in) | the contact problem list of the world (*World::getContactProblem()) |
Returns get contact problems associated with violated joint limits. The pointers refer to elements of problemListFromWorld
setJointLimits
void setJointLimits(const std::vector<raisim::Vec<2>> &jointLimits)set new joint limits For revolute and prisimatic joints, the joint limit is {lower, upper} [rad or m]. Equal bounds mean no limit. For spherical joint, the joint limit is {angle, NOT_USED}. The limit of a joint is stored at the gv index of its first element One entry per generalized velocity coordinate (getDOF()), including unused entries for coordinates without position limits.
Parameters
| Parameter | Description |
|---|---|
jointLimits (in) | joint limits |
getJointLimits
const std::vector<raisim::Vec<2>> &getJointLimits() constget the joint limits For revolute and prisimatic joints, the joint limit is {lower, upper} For spherical joint, the joint limit is {angle, NOT_USED}
Returns joint limits, one entry per generalized velocity coordinate (getDOF())
getJointVelocityLimits
const VecDyn &getJointVelocityLimits() constget the joint velocity limits One entry per body, including the root body. A non-finite entry means no limit.
Returns joint velocity limits [rad/s or m/s]
setJointVelocityLimits
void setJointVelocityLimits(const VecDyn &velLimits)set the joint velocity limits One entry per body, including the root body.
Parameters
| Parameter | Description |
|---|---|
velLimits (in) | joint velocity limits |
clearExternalForcesAndTorques
void clearExternalForcesAndTorques() finalClears all external forces and torques set by setExternalForce()/setExternalTorque() for the current step
addSpring
void addSpring(const SpringElement &spring)Parameters
| Parameter | Description |
|---|---|
spring (in) | Additional spring elements for joints (copied; fatal if its body index is out of range, or if it is on a spherical joint and its q_ref is not a rotation; a non-unit q_ref is normalized) |
getSprings
std::vector<SpringElement> &getSprings()The implicit spring terms of the mass matrix are refreshed at the next step, so change the springs through the returned reference before that step, and call this method again for later changes.
Returns springs Existing spring elements on joints (including those created from joint stiffness in the model file)
const std::vector<SpringElement> &getSprings() constReturns springs Existing spring elements on joints
getParentVector
const std::vector<size_t> &getParentVector() constReturns parent parent[i] is a parent body id of the i^th body (size_t(-1) for the root)
getSensorSet
SensorSet *getSensorSet(const std::string &name)Parameters
| Parameter | Description |
|---|---|
name (in) | sensor set name |
Returns the sensor set with the given name, or nullptr if not found. Owned by the system
getSensorSets
SensorSetGroupDataType &getSensorSets()Returns sensor sets on the robot (owned by the system)
const SensorSetGroupDataType &getSensorSets() constReturns sensor sets on the robot (owned by the system)
addConstraints
void addConstraints(
const std::vector<PinConstraintDefinition> &pinDef,
const VecDyn &pinConstraintNominalConfig)Internal: store pin (loop-closure) constraint definitions; they are built by initializeConstraints().
Parameters
| Parameter | Description |
|---|---|
pinDef (in) | pin constraint definitions |
pinConstraintNominalConfig (in) | generalized coordinate at which the constraints are defined |
void addConstraints(
const std::vector<PinConstraintDefinition> &pinDef,
const std::vector<EqualityConstraintDefinition> &equalityDef,
const VecDyn &nominalConfig)Internal: store pin and equality (loop-closure) constraint definitions; they are built by initializeConstraints().
Parameters
| Parameter | Description |
|---|---|
pinDef (in) | pin constraint definitions |
equalityDef (in) | equality constraint definitions (one or two axes each) |
nominalConfig (in) | generalized coordinate at which the constraints are defined |
addMimicConstraints
void addMimicConstraints(const std::vector<MimicConstraintDefinition> &mimicDef)Internal: store mimic constraint definitions; they are built by initializeConstraints().
Parameters
| Parameter | Description |
|---|---|
mimicDef (in) | mimic constraint definitions |
addMimicConstraint
void addMimicConstraint(
const std::string &followerJoint,
const std::string &leaderJoint,
double multiplier=1.,
double offset=0.)Couple two one-degree-of-freedom (revolute or prismatic) joints: the follower's position is kept at multiplier * (leader position) + offset, and its velocity at multiplier * (leader velocity). Like pin and equality constraints, it is eliminated exactly before the contact solve. The follower is driven only through the coupling: it should have no actuation of its own. A position error (e.g. an initial configuration that violates the relation) is removed at the same rate as a pin's. Adding one wakes a sleeping system, and World::exportToXml() records it (the constraints of the robot description come with the description).
Parameters
| Parameter | Description |
|---|---|
followerJoint (in) | name of the constrained joint |
leaderJoint (in) | name of the joint it follows |
multiplier (in) | ratio between the follower's and the leader's position |
offset (in) | follower position when the leader is at zero |
Exceptions
| Exception | Description |
|---|---|
std::logic_error | between World::integrate1() and World::integrate2() while this system takes part in the step: the step's contact problems were made for its old constraints |
initializeConstraints
void initializeConstraints()Internal: build the pin constraints stored by addConstraints().
setComputeInverseDynamics
void setComputeInverseDynamics(bool flag)If it is true, it also computes inverse dynamics and you can get the following properties: the force and torque (including the constrained directions) at the joint and acceleration of a body (necessary for IMU computation)
Parameters
| Parameter | Description |
|---|---|
flag (in) | True to compute inverse dynamics each update. |
getComputeInverseDynamics
bool getComputeInverseDynamics() constReturns return if the inverse dynamics is computed
getForceAtJointInWorldFrame
const raisim::Vec<3> &getForceAtJointInWorldFrame(size_t jointId) constYOU MUST CALL raisim::ArticulatedSystem::setComputeInverseDynamics(true) before calling this method. This method returns the force at the specified joint, computed in the last integration step
Parameters
| Parameter | Description |
|---|---|
jointId (in) | the joint id (body index) |
Returns world-frame force transmitted through the joint [N]
getTorqueAtJointInWorldFrame
const raisim::Vec<3> &getTorqueAtJointInWorldFrame(size_t jointId) constYOU MUST CALL raisim::ArticulatedSystem::setComputeInverseDynamics(true) before calling this method. This method returns the torque at the specified joint, computed in the last integration step
Parameters
| Parameter | Description |
|---|---|
jointId (in) | the joint id (body index) |
Returns world-frame torque transmitted through the joint, about the joint position [Nm]
getAllowedNumberOfInternalContactsBetweenTwoBodies
int getAllowedNumberOfInternalContactsBetweenTwoBodies() constDefault is 1. This number limits the number of possible contacts between two bodies.
Returns the number of possible contacts between two bodies
setAllowedNumberOfInternalContactsBetweenTwoBodies
void setAllowedNumberOfInternalContactsBetweenTwoBodies(int count)Default is 1. This sets the number of possible contacts between two bodies
Parameters
| Parameter | Description |
|---|---|
count (in) | Maximum number of internal contacts between two bodies. |
articulatedBodyAlgorithm
void articulatedBodyAlgorithm(
const Vec<3> &gravity,
double dt,
bool holdActuatorTorques=false)to be removed. just for testing purposes
Internal (testing only): run the articulated body algorithm for one step.
Parameters
| Parameter | Description |
|---|---|
gravity (in) | gravitational acceleration |
dt (in) | time step [s] |
getMinvJT
const std::vector<MatDyn> &getMinvJT()Returns Internal (testing only).
getj_MinvJT_T1D
const std::vector<VecDyn> &getj_MinvJT_T1D()Returns Internal (testing only).
getUdot
const raisim::VecDyn &getUdot()Returns Internal (testing only).
getFullDelassusAndTauStar
void getFullDelassusAndTauStar(double dt)Internal (testing only).
Parameters
| Parameter | Description |
|---|---|
dt (in) | time step |
getContactSolverSparseAccess
bool getContactSolverSparseAccess(
size_t pointId,
const SparseJacobian *&J,
const MatDyn *&MinvJT,
VecDyn *&genVel) finalInternal: sparse counterpart for articulated systems: direct pointers to the per-contact sparse jacobian, the dense (3 x dof) MinvJT (applied transposed) and the generalized velocity, so the contact solver can inline the velocity updates instead of dispatching virtually in the iteration loop on failure the outputs are nulled (see getContactSolverDirectAccess)
Parameters
| Parameter | Description |
|---|---|
pointId (in) | contact index |
J (out) | sparse contact Jacobian |
MinvJT (out) | dense (3 x dof) M^-1 J^T |
genVel (out) | solver generalized velocity |
Returns true if sparse access is supported
appendJointLimits
void appendJointLimits(contact::ContactProblems &problem) finalInternal: append violated joint limits to the contact problem list.
Parameters
| Parameter | Description |
|---|---|
problem (in, out) | contact problems of the world |
Static member functions
convertSparseJacobianToDense static
static void convertSparseJacobianToDense(
const SparseJacobian &sparseJaco,
Eigen::MatrixXd &denseJaco)Only the non-zero columns are written; denseJaco must be pre-sized to 3 x getDOF() and zeroed.
Parameters
| Parameter | Description |
|---|---|
sparseJaco (in) | sparse Jacobian (either positional or rotational) |
denseJaco (out) | the corresponding dense Jacobian |
Inherited members
From raisim::Object: addContactToPerObjectContact, clearPerObjectContact, getContactAabb, getContactAabbCount, getContacts, getExternalForce, getExternalForcePosition, getExternalTorque, getExternalTorquePosition, getId, getIndexInWorld, getName, getRenderRevision, Id, lock, lockMutex, setIndexInWorld, setName, try_lock, unlock, unlockMutex