Single-Body Objects

SingleBodyObject API (Parent class)

class raisim::SingleBodyObject : public raisim::Object

this class is only for inheritance

Subclassed by raisim::Box, raisim::Capsule, raisim::Compound, raisim::Cone, raisim::Cylinder, raisim::Ground, raisim::HeightMap, raisim::Mesh, raisim::Sphere

Public Functions

Eigen::Vector4d getQuaternion() const

returns the quaternion in Eigen::Vector4d

Return

the orientation of the object

void getQuaternion(Vec<4> &quat) const

returns the quaternion in raisim::Vec<4>

Parameters
  • [out] quat: the orientation of the object

Eigen::Matrix3d getRotationMatrix() const

returns the rotation matrix in Eigen::Matrix3d

Return

the orientation of the object

void getRotationMatrix(Mat<3, 3> &rotation) const

returns the quaternion in raisim::Mat<3,3>

Parameters
  • [out] rotation: the orientation of the object

Eigen::Vector3d getPosition() const

returns the body position in Eigen::Vector3d. Currently, all body positions are the same as the COM position

Return

the position of the object

Eigen::Vector3d getComPosition() const

returns the body position in Eigen::Vector3d. Currently, all body positions are the same as the COM position

Return

the position of the object

const raisim::Vec<3> &getComPosition_rs() const

returns the body position in raisim::Vec<3>. Currently, all body positions are the same as the COM position

Return

the position of the object

const raisim::Vec<3> &getBodyToComPosition_rs() const

returns the body position in raisim::Vec<3>. Currently, all body positions are the same as the COM position

Return

the position of the object

Eigen::Vector3d getLinearVelocity() const

returns the linear velocity

Return

the linear velocity of the object

void getLinearVelocity(Vec<3> &linVel)

returns the linear velocity

Parameters
  • [out] linVel: the linear velocity of the object

Eigen::Vector3d getAngularVelocity() const

returns the angular velocity

Return

the angular velocity of the object

void getAngularVelocity(Vec<3> &angVel)

returns the angular velocity

Parameters
  • [out] angVel: the angular velocity of the object

double getKineticEnergy() const

returns the kinetic energy

Return

the kinetic energy of the object

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

returns the potential energy w.r.t. z=0 and the given gravitational acceleration param[in] gravity gravitational acceleration

Return

the potential energy of the object

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

equivalent to getKineticEnergy() + getPotentialEnergy(gravity) param[in] gravity gravitational acceleration

Return

the sum of the potential and gravitational energy of the object

Eigen::Vector3d getLinearMomentum() const

returns the linear momentum of the object

Return

the linear momentum of the object

double getMass(size_t localIdx = 0) const override

returns the mass of the object. The localIdx is unused

Return

the linear momentum of the object

void setMass(double mass)

set the mass of the object.

Parameters
  • [in] mass: set the mass of the object

Eigen::Matrix3d getInertiaMatrix_B() const

get the inertia matrix in the body frame. This value is constant.

Return

the inertia matrix in the body frame

Eigen::Matrix3d getInertiaMatrix_W() const

get the inertia matrix in the world frame. This value changes as the body rotates.

Return

the inertia matrix in the world frame

const raisim::Mat<3, 3> &getInertiaMatrix_B_rs() const

get the inertia matrix in the body frame (raisim matrix type). This value is constant.

Return

the inertia matrix in the body frame

const raisim::Mat<3, 3> &getInertiaMatrix_W_rs() const

get the inertia matrix in the world frame (raisim matrix type). This value changes as the body rotates.

Return

the inertia matrix in the world frame

ObjectType getObjectType() const final

get the object type. Possible types are SPHERE, BOX, CYLINDER, CONE, CAPSULE, MESH, HALFSPACE, COMPOUND, HEIGHTMAP, ARTICULATED_SYSTEM

Return

the object type

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

apply forces at the Center of Mass

void setExternalTorque(size_t localIdx, const Vec<3> &torque) final

apply torque on a body

void setExternalForce(size_t localIdx, const Vec<3> &pos, const Vec<3> &force) final

apply force (expressed in the world frame) at specific location of the body (expressed in the body frame)

void setConstraintForce(size_t localIdx, const Vec<3> &pos, const Vec<3> &force) final

apply spring force (expressed in the world frame) at specific location of the body (expressed in the body frame)

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

get the contact point velocity in the world frame.

Parameters
  • [in] pointId: the contact index. This is an index of a contact in the contact vector that you can retrieve from getContacts().

  • [out] vel: the contact point velocity in the world frame

Sphere API

class raisim::Sphere : public raisim::SingleBodyObject

Public Functions

Sphere(double radius, double mass)

NOTE body frame origin of Sphere is C.O.M of Sphere

double getRadius() const

returns the radius of the sphere

Return

the radius of the sphere

Box API

class raisim::Box : public raisim::SingleBodyObject

Public Functions

Box(double xLength, double yLength, double zLength, double mass)

NOTE body origin of Box is C.O.M of Box

Vec<3> getDim()

returns the dimension of the box

Return

the box of the box

Capsule API

class raisim::Capsule : public raisim::SingleBodyObject

Public Functions

Capsule(double radius, double height, double mass)

NOTE body origin of Capsule is C.O.M of Capsule

double getRadius() const

returns the radius of the capsule

Return

the radius of the capsule

double getHeight() const

returns the height of the capsule

Return

the height of the capsule

Cylinder API

class raisim::Cylinder : public raisim::SingleBodyObject

Public Functions

Cylinder(double radius, double height, double mass)

NOTE body frame origin of Cylinder is C.O.M of Cylinder

double getRadius() const

returns the radius of the cylinder

Return

the radius of the cylinder

double getHeight() const

returns the height of the cylinder

Return

the height of the cylinder

Ground API

class raisim::Ground : public raisim::SingleBodyObject

Public Functions

double getHeight()

returns the height of the plane

Return

the height