Skip to content

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 ​

  • struct IKOptions — Options for solveIK().
  • struct IKResult — Result of solveIK().
  • class JointRef — Lightweight handle to a joint (coordinate frame) of an ArticulatedSystem, obtained by getJoint().
  • class LinkRef — Lightweight handle to a body (link) of an ArticulatedSystem, obtained by getLink().
  • struct SpringElement — A linear/torsional spring acting at the joint of a body (see addSpring()).

Public types ​

Frame ​

cpp
enum Frame : unsigned

Coordinate frame in which a vector argument is expressed.

EnumeratorValueDescription
WORLD_FRAME0World frame.
PARENT_FRAMEFrame of the parent body of the given body (the world frame for the root body).
BODY_FRAMEFrame of the given body (its parent joint frame).

IntegrationScheme ​

cpp
enum class IntegrationScheme : int

Time integration scheme (see setIntegrationScheme()).

EnumeratorValueDescription
TRAPEZOID0Positions are integrated with the average of the old and new generalized velocity.
SEMI_IMPLICITPositions are integrated with the new generalized velocity (default).
EULERPositions are integrated with the old generalized velocity.
RUNGE_KUTTA_4Fourth-order Runge-Kutta integration.

Constructors & destructor ​

ArticulatedSystem ​

cpp
ArticulatedSystem() = default
cpp
ArticulatedSystem(
    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

ParameterDescription
child (in)root node of the tree
resDir (in)resource directory used to resolve relative mesh paths
options (in)articulated system options
cpp
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

ParameterDescription
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
cpp
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

ParameterDescription
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
cpp
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

ParameterDescription
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 ​

cpp
~ArticulatedSystem()

Public member functions ​

isSecondOrderOrHigher ​

cpp
bool isSecondOrderOrHigher(IntegrationScheme scheme) const

Parameters

ParameterDescription
scheme (in)integration scheme

Returns true only for IntegrationScheme::RUNGE_KUTTA_4

getGeneralizedCoordinate ​

cpp
const raisim::VecDyn &getGeneralizedCoordinate() const

Returns generalized coordinate of the system (size getGeneralizedCoordinateDim(); see the class description for the layout)

getGeneralizedVelocity ​

cpp
const raisim::VecDyn &getGeneralizedVelocity() const

Returns generalized velocity of the system (size getDOF())

getGeneralizedAcceleration ​

cpp
const raisim::VecDyn &getGeneralizedAcceleration() const

Returns 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 ​

cpp
void getBaseOrientation(raisim::Vec<4> &quaternion) const

Only for a floating base (fatal otherwise).

Parameters

ParameterDescription
quaternion (out)orientation of the base as a quaternion (w,x,y,z), i.e., gc[3..6]
cpp
void getBaseOrientation(raisim::Mat<3, 3> &rotataionMatrix) const

Parameters

ParameterDescription
rotataionMatrix (out)world-frame orientation of the base
cpp
const raisim::Mat<3, 3> &getBaseOrientation() const

Returns world-frame orientation of the base

getBasePosition ​

cpp
void getBasePosition(raisim::Vec<3> &position) const

Only for a floating base (fatal otherwise).

Parameters

ParameterDescription
position (out)world-frame position of the base, i.e., gc[0..2] [m]
cpp
raisim::Vec<3> getBasePosition() const

Only for a floating base (fatal otherwise).

Returns world-frame position of the base, i.e., gc[0..2] [m]

updateKinematics ​

cpp
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 ​

cpp
void setGeneralizedCoordinate(const Eigen::VectorXd &jointState)

set gc of each joint in order. This updates the kinematics and removes previously computed contact points.

Parameters

ParameterDescription
jointState (in)generalized coordinate (size getGeneralizedCoordinateDim(); fatal otherwise)
cpp
void setGeneralizedCoordinate(const raisim::VecDyn &jointState)

set gc of each joint in order. This updates the kinematics and removes previously computed contact points.

Parameters

ParameterDescription
jointState (in)generalized coordinate (size getGeneralizedCoordinateDim(); fatal otherwise)
cpp
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

ParameterDescription
jointState (in)the generalized coordinate (must have getGeneralizedCoordinateDim() elements; fatal otherwise)

setGeneralizedVelocity ​

cpp
void setGeneralizedVelocity(const Eigen::VectorXd &jointVel)

set the generalized velocity. This updates the kinematics.

Parameters

ParameterDescription
jointVel (in)the generalized velocity (size getDOF(); fatal otherwise)
cpp
void setGeneralizedVelocity(const raisim::VecDyn &jointVel)

set the generalized velocity. This updates the kinematics.

Parameters

ParameterDescription
jointVel (in)the generalized velocity (size getDOF(); fatal otherwise)
cpp
void setGeneralizedVelocity(std::initializer_list<double> jointVel)

set the generalized velocity of each joint in order. This updates the kinematics.

Parameters

ParameterDescription
jointVel (in)the generalized velocity (must have getDOF() elements; fatal otherwise)

setGeneralizedForce ​

cpp
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

ParameterDescription
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
cpp
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

ParameterDescription
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
cpp
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

ParameterDescription
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 ​

cpp
void getState(Eigen::VectorXd &genco, Eigen::VectorXd &genvel) const

get both the generalized coordinate and the generalized velocity

Parameters

ParameterDescription
genco (out)the generalized coordinate (size getGeneralizedCoordinateDim())
genvel (out)the generalized velocity (size getDOF())
cpp
void getState(VecDyn &genco, VecDyn &genvel) const

get both the generalized coordinate and the generalized velocity

Parameters

ParameterDescription
genco (out)the generalized coordinate (size getGeneralizedCoordinateDim())
genvel (out)the generalized velocity (size getDOF())

setState ​

cpp
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

ParameterDescription
genco (in)the generalized coordinate (size getGeneralizedCoordinateDim(); fatal otherwise)
genvel (in)the generalized velocity (size getDOF(); fatal otherwise)

getGeneralizedForce ​

cpp
VecDyn getGeneralizedForce() const

Actuation 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 ​

cpp
const VecDyn &getFeedForwardGeneralizedForce() const

get the feedfoward generalized force (which is set by the user)

Returns the feedforward generalized force

getMassMatrix ​

cpp
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 ​

cpp
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

ParameterDescription
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 ​

cpp
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 ​

cpp
const std::vector<raisim::Vec<3>> &getCompositeCOM() const

get 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 ​

cpp
Vec<3> getCOM() const

get 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 ​

cpp
const std::vector<raisim::Mat<3, 3>> &getCompositeInertia() const

get 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 ​

cpp
const std::vector<double> &getCompositeMass() const

get 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 ​

cpp
Vec<3> getLinearMomentum() const

linear momentum of the whole system

Returns world-frame linear momentum [kg m/s]

getGeneralizedMomentum ​

cpp
const VecDyn &getGeneralizedMomentum() const

returns 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 ​

cpp
double getEnergy(const Vec<3> &gravity)

Parameters

ParameterDescription
gravity (in)gravitational acceleration

Returns the sum of potential/kinetic energy given the gravitational acceleration [J]. See getKineticEnergy() and getPotentialEnergy()

getKineticEnergy ​

cpp
double getKineticEnergy()

Computes 0.5 * u^T M u. This recomputes the mass matrix (including rotor inertia).

Returns the kinetic energy [J].

getPotentialEnergy ​

cpp
double getPotentialEnergy(const Vec<3> &gravity) const

Parameters

ParameterDescription
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 ​

cpp
void getAngularMomentum(
    const Vec<3> &referencePoint,
    Vec<3> &angularMomentum) const

Parameters

ParameterDescription
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 ​

cpp
void printOutBodyNamesInOrder() const

bodies here means moving bodies. Fixed bodies are optimized out

printOutMovableJointNamesInOrder ​

cpp
void printOutMovableJointNamesInOrder() const

print out movable joint names in order

printOutFrameNamesInOrder ​

cpp
void printOutFrameNamesInOrder() const

frames are attached to every joint coordinate

getMovableJointNames ​

cpp
const std::vector<std::string> &getMovableJointNames() const

getMovableJointNames. 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 ​

cpp
size_t getGeneralizedVelocityIndex(const std::string &name) const

get generalized velocity index of a joint. Fatal if the joint does not exist.

Parameters

ParameterDescription
name (in)movable joint name ("ROOT" for a floating base)

Returns index of the joint's first element in the generalized velocity.

getPosition ​

cpp
void getPosition(
    size_t bodyIdx,
    const Vec<3> &point_B,
    Vec<3> &point_W) const final

Transform a point from a body frame to the world frame.

Parameters

ParameterDescription
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
cpp
void getPosition(size_t bodyIdx, Vec<3> &pos_w) const final

Parameters

ParameterDescription
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 ​

cpp
CoordinateFrame &getFrameByName(const std::string &nm)

Refer to Object/ArticulatedSystem/Kinematics/Frame in the manual for details

Parameters

ParameterDescription
nm (in)name of the frame (joint name). Fatal if not found

Returns the coordinate frame of the given name

cpp
const CoordinateFrame &getFrameByName(const std::string &nm) const

Const overload of getFrameByName().

Parameters

ParameterDescription
nm (in)name of the frame (joint name). Fatal if not found

Returns the coordinate frame of the given name

getFrameByLinkName ​

cpp
CoordinateFrame &getFrameByLinkName(const std::string &name)

Refer to Object/ArticulatedSystem/Kinematics/Frame in the manual for details

Parameters

ParameterDescription
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

cpp
const CoordinateFrame &getFrameByLinkName(const std::string &name) const

Const overload of getFrameByLinkName().

Parameters

ParameterDescription
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 ​

cpp
size_t getFrameIdxByLinkName(const std::string &name) const

Refer to Object/ArticulatedSystem/Kinematics/Frame in the manual for details

Parameters

ParameterDescription
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 ​

cpp
CoordinateFrame &getFrameByIdx(size_t idx)

Refer to Object/ArticulatedSystem/Kinematics/Frame in the manual for details

Parameters

ParameterDescription
idx (in)index of the frame. Fatal if out of range

Returns the coordinate frame of the given index

cpp
const CoordinateFrame &getFrameByIdx(size_t idx) const

Const overload of getFrameByIdx().

Parameters

ParameterDescription
idx (in)index of the frame. Fatal if out of range

Returns the coordinate frame of the given index

getFrameIdxByName ​

cpp
size_t getFrameIdxByName(const std::string &nm) const

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

Parameters

ParameterDescription
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 ​

cpp
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

cpp
const std::vector<CoordinateFrame> &getFrames() const

Const overload of getFrames().

Returns a vector of the coordinate frames

getFramePosition ​

cpp
void getFramePosition(size_t frameId, Vec<3> &point_W) const

Parameters

ParameterDescription
frameId (in)the frame id which can be obtained by getFrameIdxByName()
point_W (out)the position of the frame expressed in the world frame
cpp
void getFramePosition(const std::string &frameName, Vec<3> &point_W) const

Parameters

ParameterDescription
frameName (in)the frame name (defined in the urdf)
point_W (out)the position of the frame expressed in the world frame
cpp
void getFramePosition(const CoordinateFrame &frame, Vec<3> &point_W) const

Parameters

ParameterDescription
frame (in)custom frame defined by the user
point_W (out)the position of the frame relative to the world frame

getPositionInFrame ​

cpp
void getPositionInFrame(
    size_t frameId,
    const Vec<3> &localPos,
    Vec<3> &point_W) const

Parameters

ParameterDescription
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 ​

cpp
void getFrameOrientation(size_t frameId, Mat<3, 3> &orientation_W) const

Parameters

ParameterDescription
frameId (in)the frame id which can be obtained by getFrameIdxByName()
orientation_W (out)the orientation of the frame relative to the world frame
cpp
void getFrameOrientation(
    const std::string &frameName,
    Mat<3, 3> &orientation_W) const

Parameters

ParameterDescription
frameName (in)the frame name (defined in the urdf)
orientation_W (out)the orientation of the frame relative to the world frame
cpp
void getFrameOrientation(
    const CoordinateFrame &frame,
    Mat<3, 3> &orientation_W) const

Parameters

ParameterDescription
frame (in)custom frame defined by the user
orientation_W (out)the orientation of the frame relative to the world frame

getFrameVelocity ​

cpp
void getFrameVelocity(size_t frameId, Vec<3> &vel_W) const

Parameters

ParameterDescription
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
cpp
void getFrameVelocity(const std::string &frameName, Vec<3> &vel_W) const

Parameters

ParameterDescription
frameName (in)the frame name (defined in the urdf)
vel_W (out)the linear velocity of the frame expressed in the world frame
cpp
void getFrameVelocity(const CoordinateFrame &frame, Vec<3> &vel_W) const

Parameters

ParameterDescription
frame (in)custom frame defined by the user
vel_W (out)the linear velocity of the frame expressed to the world frame

getFrameAngularVelocity ​

cpp
void getFrameAngularVelocity(size_t frameId, Vec<3> &angVel_W) const

Parameters

ParameterDescription
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
cpp
void getFrameAngularVelocity(
    const std::string &frameName,
    Vec<3> &angVel_W) const

Parameters

ParameterDescription
frameName (in)the frame name (defined in the urdf)
angVel_W (out)the angular velocity of the frame relative to the world frame
cpp
void getFrameAngularVelocity(
    const CoordinateFrame &frame,
    Vec<3> &angVel_W) const

Parameters

ParameterDescription
frame (in)custom frame defined by the user
angVel_W (out)the angular velocity of the frame expressed to the world frame

getFrameAcceleration ​

cpp
void getFrameAcceleration(const std::string &frameName, Vec<3> &acc_W) const

YOU 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

ParameterDescription
frameName (in)name of the frame
acc_W (out)the frame's specific force (linear acceleration minus gravity) expressed in the world frame
cpp
void getFrameAcceleration(const CoordinateFrame &frame, Vec<3> &acc_W) const

YOU 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

ParameterDescription
frame (in)custom frame defined by the user
acc_W (out)the frame's specific force expressed in the world frame

getPositionInBodyCoordinate ​

cpp
void getPositionInBodyCoordinate(
    size_t bodyIdx,
    const Vec<3> &pos_W,
    Vec<3> &pos_B)

Parameters

ParameterDescription
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 ​

cpp
void getOrientation(size_t bodyIdx, Mat<3, 3> &rot) const final

Parameters

ParameterDescription
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 ​

cpp
void getVelocity(size_t bodyIdx, Vec<3> &vel_w) const final

Parameters

ParameterDescription
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)
cpp
void getVelocity(const SparseJacobian &jaco, Vec<3> &pointVel) const

Computes J * u with the current generalized velocity.

Parameters

ParameterDescription
jaco (in)the Jacobian associated with the point of interest
pointVel (out)the velocity of the point expressed in the world frame
cpp
void getVelocity(
    size_t bodyIdx,
    const Vec<3> &posInBodyFrame,
    Vec<3> &pointVel) const final

Parameters

ParameterDescription
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
cpp
void getVelocity(
    size_t bodyIdx,
    Frame frameOfPos,
    const Vec<3> &pos,
    Frame frameOfVel,
    Vec<3> &pointVel) const

Parameters

ParameterDescription
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 ​

cpp
void getAngularVelocity(size_t bodyIdx, Vec<3> &angVel_w) const

Parameters

ParameterDescription
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 ​

cpp
void getSparseJacobian(
    size_t bodyIdx,
    const Vec<3> &point_W,
    SparseJacobian &jaco) const

Parameters

ParameterDescription
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)
cpp
void getSparseJacobian(
    size_t bodyIdx,
    Frame frame,
    const Vec<3> &point,
    SparseJacobian &jaco) const

Parameters

ParameterDescription
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 ​

cpp
void getSparseRotationalJacobian(size_t bodyIdx, SparseJacobian &jaco) const

Parameters

ParameterDescription
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 ​

cpp
void getTimeDerivativeOfSparseJacobian(
    size_t bodyIdx,
    Frame frame,
    const Vec<3> &point,
    SparseJacobian &jaco) const

Parameters

ParameterDescription
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 ​

cpp
void getTimeDerivativeOfSparseRotationalJacobian(
    size_t bodyIdx,
    SparseJacobian &jaco) const

Parameters

ParameterDescription
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 ​

cpp
void getDenseJacobian(
    size_t bodyIdx,
    const Vec<3> &point_W,
    Eigen::MatrixXd &jaco) const

This method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!

Parameters

ParameterDescription
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 ​

cpp
void getDenseRotationalJacobian(size_t bodyIdx, Eigen::MatrixXd &jaco) const

This method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!

Parameters

ParameterDescription
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 ​

cpp
void getDenseFrameJacobian(size_t frameIdx, Eigen::MatrixXd &jaco) const

This method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!

Parameters

ParameterDescription
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()
cpp
void getDenseFrameJacobian(
    const std::string &frameName,
    Eigen::MatrixXd &jaco) const

This method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!

Parameters

ParameterDescription
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 ​

cpp
void getDenseFrameRotationalJacobian(
    size_t frameIdx,
    Eigen::MatrixXd &jaco) const

This method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!

Parameters

ParameterDescription
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()
cpp
void getDenseFrameRotationalJacobian(
    const std::string &frameName,
    Eigen::MatrixXd &jaco) const

This method only fills out non-zero elements. Make sure that the jaco is setZero() once in the initialization!

Parameters

ParameterDescription
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 ​

cpp
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

ParameterDescription
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

cpp
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

ParameterDescription
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

cpp
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

ParameterDescription
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

cpp
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

ParameterDescription
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

cpp
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

ParameterDescription
frameIdx (in)frame index (see getFrameIdxByName())
targetPosition (in)world-frame target position of the frame origin [m]

Returns the solver result

cpp
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

ParameterDescription
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

cpp
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

ParameterDescription
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 ​

cpp
size_t getBodyIdx(const std::string &nm) const

returns the index of the body

Parameters

ParameterDescription
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 ​

cpp
size_t getDOF() const

Returns the degrees of freedom

getGeneralizedVelocityDim ​

cpp
size_t getGeneralizedVelocityDim() const

Returns the dimension of generalized velocity (do the same thing with getDOF)

getGeneralizedCoordinateDim ​

cpp
size_t getGeneralizedCoordinateDim() const

Returns the dimension of generalized coordinate

getBodyPose ​

cpp
void getBodyPose(
    size_t bodyIdx,
    Mat<3, 3> &orientation,
    Vec<3> &position) const

The body pose is the pose of its parent joint (after its joint transformation)

Parameters

ParameterDescription
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 ​

cpp
void getBodyPosition(size_t bodyIdx, Vec<3> &position) const

The body position is the position of its parent joint (after its joint transformation)

Parameters

ParameterDescription
bodyIdx (in)the body index. it can be retrieved by getBodyIdx()
position (out)world-frame position of the body [m]

getBodyOrientation ​

cpp
void getBodyOrientation(size_t bodyIdx, Mat<3, 3> &orientation) const

The body orientation is the orientation of its parent joint (after its joint transformation)

Parameters

ParameterDescription
bodyIdx (in)the body index. it can be retrieved by getBodyIdx()
orientation (out)world-frame orientation of the body

getJointPos_P ​

cpp
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].

cpp
const std::vector<raisim::Vec<3>> &getJointPos_P() const

Returns joint position relative to its parent, expressed in the parent frame, indexed by body index [m].

getJointOrientation_P ​

cpp
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.

cpp
const std::vector<raisim::Mat<3, 3>> &getJointOrientation_P() const

Returns joint orientation relative to its parent body frame (at zero joint coordinate), indexed by body index.

getJointAxis_P ​

cpp
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().

cpp
const std::vector<raisim::Vec<3>> &getJointAxis_P() const

Returns joint axes expressed in the joint frame, indexed by body index.

getJointAxis ​

cpp
const raisim::Vec<3> &getJointAxis(size_t idx) const

Parameters

ParameterDescription
idx (in)body (joint) index

Returns a reference to joint axis expressed in the world frame.

getMass ​

cpp
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].

cpp
const std::vector<double> &getMass() const

Returns mass of each body, indexed by body index [kg].

cpp
double getMass(size_t bodyIdx) const final

Parameters

ParameterDescription
bodyIdx (in)the body index. it can be retrieved by getBodyIdx()

Returns mass of the body

getInertia ​

cpp
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].

cpp
const std::vector<raisim::Mat<3, 3>> &getInertia() const

Returns inertia of each body about its COM, expressed in the body frame, indexed by body index [kg m^2].

getBodyCOM_B ​

cpp
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].

cpp
const std::vector<raisim::Vec<3>> &getBodyCOM_B() const

Returns position of the center of the mass of each body in the body frame, indexed by body index [m].

getBodyCOM_W ​

cpp
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].

cpp
const std::vector<raisim::Vec<3>> &getBodyCOM_W() const

Returns position of the center of the mass of each body in the world frame, indexed by body index [m].

getCollisionBodies ​

cpp
raisim::CollisionSet &getCollisionBodies()

Returns a reference to the collision bodies. Position and orientation can be set dynamically

cpp
const raisim::CollisionSet &getCollisionBodies() const

Returns the collision bodies of the system

getIgnoredCollisionPairs ​

cpp
const std::vector<std::pair<size_t, size_t>> &getIgnoredCollisionPairs() const

Returns body index pairs (smaller index first) registered by ignoreCollisionBetween()

getCollisionBody ​

cpp
raisim::CollisionDefinition &getCollisionBody(const std::string &name)

Fatal if no collision body has the given name.

Parameters

ParameterDescription
namecollision 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

cpp
const raisim::CollisionDefinition &getCollisionBody(const std::string &name) const

Const overload of getCollisionBody(). Fatal if no collision body has the given name.

Parameters

ParameterDescription
name (in)collision body name

Returns the collision body

updateMassInfo ​

cpp
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 ​

cpp
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

ParameterDescription
bodyIdx (in)body index (fatal if out of range)
value (in)mass [kg]

getTotalMass ​

cpp
double getTotalMass() const

Uses the composite mass, so call updateMassInfo() after changing body masses.

Returns the total mass of the system [kg].

setExternalForce ​

cpp
void setExternalForce(size_t bodyIdx, const Vec<3> &force) final

set 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

ParameterDescription
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]
cpp
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

ParameterDescription
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
cpp
void setExternalForce(
    size_t bodyIdx,
    const Vec<3> &pos,
    const Vec<3> &force) final

set 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

ParameterDescription
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]
cpp
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

ParameterDescription
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 ​

cpp
void setExternalTorque(
    size_t bodyIdx,
    const Vec<3> &torque_in_world_frame) final

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

ParameterDescription
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 ​

cpp
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

ParameterDescription
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 ​

cpp
void getContactPointVel(size_t contactId, Vec<3> &vel) const final

returns 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

ParameterDescription
contactId (in)index of the contact vector which can be obtained by getContacts()
vel (out)the world-frame contact point velocity

setControlMode ​

cpp
void setControlMode(ControlMode::Type mode)

setPdGains() and setPTarget() switch to ControlMode::PD_PLUS_FEEDFORWARD_TORQUE automatically.

Parameters

ParameterDescription
mode (in)control mode. Can be either ControlMode::FORCE_AND_TORQUE or ControlMode::PD_PLUS_FEEDFORWARD_TORQUE

getControlMode ​

cpp
ControlMode::Type getControlMode() const

Returns control mode. Can be either ControlMode::FORCE_AND_TORQUE or ControlMode::PD_PLUS_FEEDFORWARD_TORQUE

setPdTarget ​

cpp
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

ParameterDescription
posTarget (in)position target (dimension == getGeneralizedCoordinateDim(); quaternions for spherical joints)
velTarget (in)velocity target (dimension == getDOF())
cpp
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

ParameterDescription
posTarget (in)position target (dimension == getGeneralizedCoordinateDim())
velTarget (in)velocity target (dimension == getDOF())

getPdTarget ​

cpp
void getPdTarget(Eigen::VectorXd &posTarget, Eigen::VectorXd &velTarget)

get PD targets. The outputs must already have the right size (fatal otherwise).

Parameters

ParameterDescription
posTarget (out)position target (dimension == getGeneralizedCoordinateDim())
velTarget (out)velocity target (dimension == getDOF())

setPTarget ​

cpp
template <class T>
void setPTarget(const T &posTarget)

set P targets. This also switches to ControlMode::PD_PLUS_FEEDFORWARD_TORQUE.

Parameters

ParameterDescription
posTarget (in)position target (dimension == getGeneralizedCoordinateDim())

setDTarget ​

cpp
template <class T>
void setDTarget(const T &velTarget)

set D targets.

Parameters

ParameterDescription
velTarget (in)velocity target (dimension == getDOF())

setPdGains ​

cpp
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

ParameterDescription
pgain (in)position gain (dimension == getDOF())
dgain (in)velocity gain (dimension == getDOF())
cpp
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

ParameterDescription
pgain (in)position gain (dimension == getDOF())
dgain (in)velocity gain (dimension == getDOF())

getPdGains ​

cpp
void getPdGains(Eigen::VectorXd &pgain, Eigen::VectorXd &dgain)

get PD gains.

Parameters

ParameterDescription
pgain (out)position gain (dimension == getDOF())
dgain (out)velocity gain (dimension == getDOF())

setPGains ​

cpp
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

ParameterDescription
pgain (in)position gain (dimension == getDOF())

setDGains ​

cpp
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

ParameterDescription
dgain (in)velocity gain (dimension == getDOF())

getJointDamping ​

cpp
const raisim::VecDyn &getJointDamping() const

Returns 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 ​

cpp
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

ParameterDescription
dampingCoefficient (in)the damping coefficient vector, acting at each degrees of freedom (dimension == getDOF(); fatal otherwise)
cpp
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

ParameterDescription
dampingCoefficient (in)the damping coefficient vector, acting at each degrees of freedom (dimension == getDOF(); fatal otherwise)

computeSparseInverse ​

cpp
void computeSparseInverse(const MatDyn &M, MatDyn &Minv) noexcept

This 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

ParameterDescription
M (in)mass matrix
Minv (out)inverse mass matrix

massMatrixVecMul ​

cpp
void massMatrixVecMul(const VecDyn &vec1, VecDyn &vec) const

this 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

ParameterDescription
vec1 (in)input vector (size getDOF(); fatal otherwise)
vec (out)output vector, resized to getDOF()

ignoreCollisionBetween ​

cpp
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

ParameterDescription
bodyIdx1 (in)first body index
bodyIdx2 (in)second body index

updateSelfCollisionCache ​

cpp
void updateSelfCollisionCache(World &world)

Refresh contact body metadata in the world contact detector. Call this after changing collision ignore settings at runtime.

Parameters

ParameterDescription
world (in)the world that owns this articulated system

getOptions ​

cpp
ArticulatedSystemOption getOptions() const

Returns a copy of the options the system was created with

getBodyNames ​

cpp
const std::vector<std::string> &getBodyNames() const

Returns a vector of body names (following the joint order)

getVisOb ​

cpp
std::vector<VisObject> &getVisOb()

Returns a vector of visualized bodies

cpp
const std::vector<VisObject> &getVisOb() const

Returns a vector of visualized bodies

getVisColOb ​

cpp
std::vector<VisObject> &getVisColOb()

Returns a vector of visualized collision bodies (same order as getCollisionBodies())

cpp
const std::vector<VisObject> &getVisColOb() const

Returns a vector of visualized collision bodies (same order as getCollisionBodies())

getVisObPose ​

cpp
void getVisObPose(size_t visObjIdx, Mat<3, 3> &rot, Vec<3> &pos) const

Parameters

ParameterDescription
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 ​

cpp
void getVisColObPose(size_t visColObjIdx, Mat<3, 3> &rot, Vec<3> &pos) const

Parameters

ParameterDescription
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 ​

cpp
const std::string &getResourceDir() const

Returns the resource directory (for mesh files, textures, etc)

getRobotDescriptionfFileName ​

cpp
const std::string &getRobotDescriptionfFileName() const

Returns the file name (with extension) of the robot description file (empty if the robot was not created from a file path)

getRobotDescriptionfTopDirName ​

cpp
const std::string &getRobotDescriptionfTopDirName() const

Returns 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 ​

cpp
const std::string &getRobotDescriptionFullPath() const

Returns the full path to the URDF file (returns empty string if the robot was not specified by a URDF file)

getRobotDescription ​

cpp
const std::string &getRobotDescription() const

Returns if the object was instantiated with raw URDF string, it returns the string

exportRobotDescriptionToURDF ​

cpp
void exportRobotDescriptionToURDF(const std::string &filePath) const

if 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

ParameterDescription
filePath (in)Path where the file is generated

setBasePos_e ​

cpp
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

ParameterDescription
pos (in)world-frame position of the base [m]

setBaseOrientation_e ​

cpp
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

ParameterDescription
rot (in)world-frame orientation of the base

setBasePos ​

cpp
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

ParameterDescription
pos (in)world-frame position of the base [m]

setBaseOrientation ​

cpp
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

ParameterDescription
rot (in)world-frame orientation of the base
cpp
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

ParameterDescription
quat (in)world-frame orientation of the base as a quaternion (w,x,y,z)

setBaseVelocity ​

cpp
void setBaseVelocity(const Vec<3> &vel)

set the base linear velocity (gv[0..2]). Only for a floating base (prints a warning otherwise).

Parameters

ParameterDescription
vel (in)the world-frame linear velocity of the base [m/s]

setBaseAngularVelocity ​

cpp
void setBaseAngularVelocity(const Vec<3> &vel)

set the base angular velocity (gv[3..5]). Only for a floating base (prints a warning otherwise).

Parameters

ParameterDescription
vel (in)the world-frame angular velocity of the base [rad/s]

setActuationLimits ​

cpp
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

ParameterDescription
upper (in)upper joint force/torque limit (dimension == getDOF(); fatal otherwise)
lower (in)lower joint force/torque limit (dimension == getDOF(); fatal otherwise)

getCollisionVisualRevision ​

cpp
std::uint64_t getCollisionVisualRevision() const

Revision of collision geometry shown by remote viewers. Offset and shape edits require a fresh initialization record so body-frame markers stay aligned.

getActuationUpperLimits ​

cpp
const VecDyn &getActuationUpperLimits() const

Returns the upper joint torque/force limit

getActuationLowerLimits ​

cpp
const VecDyn &getActuationLowerLimits() const

Returns the lower joint torque/force limit

setActuators ​

cpp
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

ParameterDescription
actuators (in)actuators. A joint can be driven by only one actuator.

getNumberOfActuators ​

cpp
size_t getNumberOfActuators() const

Returns the number of actuators

getActuatorNames ​

cpp
const std::vector<std::string> &getActuatorNames() const

The 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 ​

cpp
const std::vector<ActuatorDefinition> &getActuators() const

Returns the actuators as defined in the URDF or by setActuators(), with the bus voltages set since. Every actuator has its name (getActuatorNames()).

getActuatorIndex ​

cpp
size_t getActuatorIndex(const std::string &name) const

Parameters

ParameterDescription
name (in)actuator name (getActuatorNames())

Returns the actuator index, or size_t(-1) if there is no actuator with the name

getTracks ​

cpp
const std::vector<Track> &getTracks() const

The 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 ​

cpp
size_t getTrackIndex(const std::string &name) const

Parameters

ParameterDescription
name (in)track name

Returns the track index, or size_t(-1) if there is no track with the name

getTrackSpeed ​

cpp
double getTrackSpeed(size_t trackIndex) const

The 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

ParameterDescription
trackIndex (in)track index (getTracks() order)

Returns the belt speed [m/s]

setActuatorTorques ​

cpp
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

ParameterDescription
torques (in)actuator torques [Nm or N], ordered like getActuatorNames()

setActuatorTorque ​

cpp
void setActuatorTorque(const std::string &name, double torque)

Set the torque of one actuator (see setActuatorTorques()).

Parameters

ParameterDescription
name (in)actuator name (getActuatorNames())
torque (in)actuator torque at the output of its gear [Nm or N]
cpp
void setActuatorTorque(size_t index, double torque)

Set the torque of one actuator (see setActuatorTorques()).

Parameters

ParameterDescription
index (in)actuator index (getActuatorNames() order)
torque (in)actuator torque at the output of its gear [Nm or N]

getActuatorTorques ​

cpp
const std::vector<double> &getActuatorTorques() const

Returns the actuator torques set with setActuatorTorques(), ordered like getActuatorNames()

getActuatorTorqueBounds ​

cpp
void getActuatorTorqueBounds(VecDyn &lower, VecDyn &upper) const

The 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

ParameterDescription
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 ​

cpp
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

ParameterDescription
voltage (in)bus voltage [V] (positive)
cpp
void setBusVoltage(const std::string &actuatorName, double voltage)

Set the bus voltage of the motor of one actuator.

Parameters

ParameterDescription
actuatorName (in)actuator name (getActuatorNames())
voltage (in)bus voltage [V] (positive)

getActuatorStates ​

cpp
const std::vector<ActuatorState> &getActuatorStates() const

The 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 ​

cpp
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

ParameterDescription
enforce (in)clip motor torques to the motor operating region (default true)

isMotorOperatingRegionEnforced ​

cpp
bool isMotorOperatingRegionEnforced() const

Returns if motor torques are clipped to the motor operating region

setCollisionBodyShapeParameters ​

cpp
void setCollisionBodyShapeParameters(size_t id, const Vec<4> &params)

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

ParameterDescription
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 ​

cpp
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

ParameterDescription
id (in)collision object id (index in getCollisionBodies())
posOffset (in)the position vector expressed in the joint frame [m]

setCollisionBodyOrientationOffset ​

cpp
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

ParameterDescription
id (in)collision object id (index in getCollisionBodies())
oriOffset (in)the orientation relative to the joint frame (must be a proper rotation matrix)

setRotorInertia ​

cpp
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

ParameterDescription
rotorInertia (in)the rotor inertia (dimension == getDOF(); fatal otherwise)

getRotorInertia ​

cpp
const VecDyn &getRotorInertia() const

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

Returns the rotor inertia

getJointType ​

cpp
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

ParameterDescription
jointIndex (in)the joint index

Returns the joint type

cpp
Joint::Type getJointType(size_t jointIndex) const

Const overload of getJointType().

Parameters

ParameterDescription
jointIndex (in)the joint (body) index

Returns the joint type

getNumberOfJoints ​

cpp
size_t getNumberOfJoints() const

Returns the number of joints (same as the number of bodies)

getJoint ​

cpp
JointRef getJoint(const std::string &name)

returns reference object of the joint. Fatal if no frame has the given name.

Parameters

ParameterDescription
name (in)joint name (frame name, see getFrameIdxByName())

Returns a JointRef to the joint. Check the example JointRefAndLinkRef

cpp
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

ParameterDescription
name (in)the link name

Returns a LinkRef to the link. Check the example JointRefAndLinkRef

getMappingFromBodyIndexToGeneralizedVelocityIndex ​

cpp
const std::vector<size_t> &getMappingFromBodyIndexToGeneralizedVelocityIndex() const

Returns 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 ​

cpp
const std::vector<size_t> &getMappingFromBodyIndexToGeneralizedCoordinateIndex() const

Returns 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 ​

cpp
ObjectType getObjectType() const final

Returns the object type (ARTICULATED_SYSTEM)

getBodyType ​

cpp
BodyType getBodyType(size_t bodyIdx) const final

Parameters

ParameterDescription
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)

cpp
BodyType getBodyType() const final

Returns the body type (STATIC, KINEMATIC, or DYNAMIC). It is always dynamic

setIntegrationScheme ​

cpp
void setIntegrationScheme(IntegrationScheme scheme)

Parameters

ParameterDescription
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 ​

cpp
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

ParameterDescription
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 ​

cpp
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

ParameterDescription
jointLimits (in)joint limits

getJointLimits ​

cpp
const std::vector<raisim::Vec<2>> &getJointLimits() const

get 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 ​

cpp
const VecDyn &getJointVelocityLimits() const

get 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 ​

cpp
void setJointVelocityLimits(const VecDyn &velLimits)

set the joint velocity limits One entry per body, including the root body.

Parameters

ParameterDescription
velLimits (in)joint velocity limits

clearExternalForcesAndTorques ​

cpp
void clearExternalForcesAndTorques() final

Clears all external forces and torques set by setExternalForce()/setExternalTorque() for the current step

addSpring ​

cpp
void addSpring(const SpringElement &spring)

Parameters

ParameterDescription
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 ​

cpp
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)

cpp
const std::vector<SpringElement> &getSprings() const

Returns springs Existing spring elements on joints

getParentVector ​

cpp
const std::vector<size_t> &getParentVector() const

Returns parent parent[i] is a parent body id of the i^th body (size_t(-1) for the root)

getSensorSet ​

cpp
SensorSet *getSensorSet(const std::string &name)

Parameters

ParameterDescription
name (in)sensor set name

Returns the sensor set with the given name, or nullptr if not found. Owned by the system

getSensorSets ​

cpp
SensorSetGroupDataType &getSensorSets()

Returns sensor sets on the robot (owned by the system)

cpp
const SensorSetGroupDataType &getSensorSets() const

Returns sensor sets on the robot (owned by the system)

addConstraints ​

cpp
void addConstraints(
    const std::vector<PinConstraintDefinition> &pinDef,
    const VecDyn &pinConstraintNominalConfig)

Internal: store pin (loop-closure) constraint definitions; they are built by initializeConstraints().

Parameters

ParameterDescription
pinDef (in)pin constraint definitions
pinConstraintNominalConfig (in)generalized coordinate at which the constraints are defined
cpp
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

ParameterDescription
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 ​

cpp
void addMimicConstraints(const std::vector<MimicConstraintDefinition> &mimicDef)

Internal: store mimic constraint definitions; they are built by initializeConstraints().

Parameters

ParameterDescription
mimicDef (in)mimic constraint definitions

addMimicConstraint ​

cpp
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

ParameterDescription
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

ExceptionDescription
std::logic_errorbetween 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 ​

cpp
void initializeConstraints()

Internal: build the pin constraints stored by addConstraints().

setComputeInverseDynamics ​

cpp
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

ParameterDescription
flag (in)True to compute inverse dynamics each update.

getComputeInverseDynamics ​

cpp
bool getComputeInverseDynamics() const

Returns return if the inverse dynamics is computed

getForceAtJointInWorldFrame ​

cpp
const raisim::Vec<3> &getForceAtJointInWorldFrame(size_t jointId) const

YOU 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

ParameterDescription
jointId (in)the joint id (body index)

Returns world-frame force transmitted through the joint [N]

getTorqueAtJointInWorldFrame ​

cpp
const raisim::Vec<3> &getTorqueAtJointInWorldFrame(size_t jointId) const

YOU 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

ParameterDescription
jointId (in)the joint id (body index)

Returns world-frame torque transmitted through the joint, about the joint position [Nm]

getAllowedNumberOfInternalContactsBetweenTwoBodies ​

cpp
int getAllowedNumberOfInternalContactsBetweenTwoBodies() const

Default is 1. This number limits the number of possible contacts between two bodies.

Returns the number of possible contacts between two bodies

setAllowedNumberOfInternalContactsBetweenTwoBodies ​

cpp
void setAllowedNumberOfInternalContactsBetweenTwoBodies(int count)

Default is 1. This sets the number of possible contacts between two bodies

Parameters

ParameterDescription
count (in)Maximum number of internal contacts between two bodies.

articulatedBodyAlgorithm ​

cpp
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

ParameterDescription
gravity (in)gravitational acceleration
dt (in)time step [s]

getMinvJT ​

cpp
const std::vector<MatDyn> &getMinvJT()

Returns Internal (testing only).

getj_MinvJT_T1D ​

cpp
const std::vector<VecDyn> &getj_MinvJT_T1D()

Returns Internal (testing only).

getUdot ​

cpp
const raisim::VecDyn &getUdot()

Returns Internal (testing only).

getFullDelassusAndTauStar ​

cpp
void getFullDelassusAndTauStar(double dt)

Internal (testing only).

Parameters

ParameterDescription
dt (in)time step

getContactSolverSparseAccess ​

cpp
bool getContactSolverSparseAccess(
    size_t pointId,
    const SparseJacobian *&J,
    const MatDyn *&MinvJT,
    VecDyn *&genVel) final

Internal: 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

ParameterDescription
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 ​

cpp
void appendJointLimits(contact::ContactProblems &problem) final

Internal: append violated joint limits to the contact problem list.

Parameters

ParameterDescription
problem (in, out)contact problems of the world

Static member functions ​

convertSparseJacobianToDense static ​

cpp
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

ParameterDescription
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

RaiSim — physics for robotics and AI.