Skip to content

raisim::Object ​

abstract class · #include <raisim/object/Object.hpp>

Derived by: raisim::ArticulatedSystem, raisim::DeformableObject, raisim::GranularSystem, raisim::SingleBodyObject

Abstract base class of everything that can be added to a raisim::World: single bodies, terrains, articulated systems, deformable objects and granular systems. Objects are created and owned by the World. Functions taking a localIdx address a body (articulated systems) or a particle (deformable/granular); single bodies ignore it (use 0).

Public types ​

Id ​

cpp
using Id = std::uint64_t

Stable object id type (see getId()).

Constructors & destructor ​

Object ​

cpp
explicit Object()

Objects are created through World (e.g., World::addSphere()).

~Object ​

cpp
virtual ~Object() = default

Public member functions ​

clearPerObjectContact ​

cpp
void clearPerObjectContact()

Internal: clears the contact list (called by World before collision detection).

addContactToPerObjectContact ​

cpp
void addContactToPerObjectContact(Contact &contact)

Internal: appends a contact to the contact list.

Parameters

ParameterDescription
contact (in)the contact to copy

setIndexInWorld ​

cpp
void setIndexInWorld(size_t indexInWorld_)

Internal: set by World when the object list changes.

Parameters

ParameterDescription
indexInWorld_ (in)the new index in World::getObjList()

getIndexInWorld ​

cpp
size_t getIndexInWorld() const

get the world index. raisim::World::getObjects() returns a vector of object pointers. This is method returns the index of this object in the vector.

Returns the world index

getId ​

cpp
Id getId() const

Returns a stable object id assigned by the world. Unlike getIndexInWorld(), this id is not changed when world indices are compacted after removals.

Returns the object id

getContacts ​

cpp
const std::vector<Contact> &getContacts() const

get a vector of all contacts on the object.

Returns contacts on the body

cpp
std::vector<Contact> &getContacts()

Returns mutable contacts on the body (see the const overload).

updateCollision ​

cpp
virtual void updateCollision() = 0

Internal: synchronizes the collision geometry with the current pose.

updateContactAabbs ​

cpp
virtual void updateContactAabbs() = 0

Internal: recomputes the world-frame AABBs used by the broadphase.

preContactSolverUpdate1 ​

cpp
virtual void preContactSolverUpdate1(const Vec<3> &gravity, double dt) = 0

Internal: first per-step update before the contact solver (called by World).

Parameters

ParameterDescription
gravity (in)gravitational acceleration (m/s^2)
dt (in)time step (s)

preContactSolverUpdate2 ​

cpp
virtual void preContactSolverUpdate2(
    const Vec<3> &gravity,
    double dt,
    contact::ContactProblems &problems) = 0

Internal: second per-step update before the contact solver (called by World).

Parameters

ParameterDescription
gravity (in)gravitational acceleration (m/s^2)
dt (in)time step (s)
problems (in, out)contact problems of the world

integrate ​

cpp
virtual void integrate(double dt, class World &world) = 0

Internal: integrates the state after the contact solve (called by World).

Parameters

ParameterDescription
dt (in)time step (s)
world (in)the owning world

setExternalForce ​

cpp
virtual void setExternalForce(size_t localIdx, const Vec<3> &force) = 0

apply forces at the Center of Mass

Parameters

ParameterDescription
localIdx (in)local body index
force (in)force in the world frame (N)
cpp
virtual void setExternalForce(
    size_t localIdx,
    const Vec<3> &pos,
    const Vec<3> &force) = 0

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

Parameters

ParameterDescription
localIdx (in)local body index
pos (in)application point in the body frame
force (in)force in the world frame (N)

setExternalTorque ​

cpp
virtual void setExternalTorque(size_t localIdx, const Vec<3> &torque) = 0

apply torque on a body

Parameters

ParameterDescription
localIdx (in)local body index
torque (in)torque in the world frame (Nm)

setConstraintForce ​

cpp
virtual void setConstraintForce(
    size_t localIdx,
    const Vec<3> &pos,
    const Vec<3> &force) = 0

Internal: apply a constraint force (expressed in the world frame) at specific location of the body (expressed in the body frame). Unlike setExternalForce(), it is not visualized.

Parameters

ParameterDescription
localIdx (in)local body index
pos (in)application point in the body frame
force (in)force in the world frame (N)

getMass ​

cpp
virtual double getMass(size_t localIdx) const = 0

Parameters

ParameterDescription
localIdx (in)local body (or particle) index

Returns the mass of the local body (kg)

getObjectType ​

cpp
virtual ObjectType getObjectType() const = 0

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

Returns the object type

getPosition ​

cpp
virtual void getPosition(size_t localIdx, Vec<3> &pos_w) const = 0

get the position of a local body (its body frame origin) or particle.

Parameters

ParameterDescription
localIdx (in)local body (or particle) index
pos_w (out)position in the world frame (m)
cpp
virtual void getPosition(
    size_t localIdx,
    const Vec<3> &pos_b,
    Vec<3> &pos_w) const = 0

get the world position of a point fixed to a local body.

Parameters

ParameterDescription
localIdx (in)local body index
pos_b (in)the point in the body frame
pos_w (out)the point in the world frame (m)

getVelocity ​

cpp
virtual void getVelocity(size_t localIdx, Vec<3> &vel_w) const = 0

get the linear velocity of a local body or particle.

Parameters

ParameterDescription
localIdx (in)local body (or particle) index
vel_w (out)linear velocity in the world frame (m/s)
cpp
virtual void getVelocity(
    size_t localIdx,
    const Vec<3> &pos_b,
    Vec<3> &vel_w) const = 0

get the world velocity of a point fixed to a local body.

Parameters

ParameterDescription
localIdx (in)local body index
pos_b (in)the point in the body frame
vel_w (out)the point velocity in the world frame (m/s)

getOrientation ​

cpp
virtual void getOrientation(size_t localIdx, Mat<3, 3> &rot) const = 0

get the orientation of a local body.

Parameters

ParameterDescription
localIdx (in)local body index
rot (out)body-to-world rotation matrix

getBodyType ​

cpp
virtual BodyType getBodyType(size_t localIdx) const

get the body type of a local body. Available types are: DYNAMIC (movable and finite mass), STATIC (not movable and infinite mass), KINEMATIC (movable and infinite mass)

Parameters

ParameterDescription
localIdx (in)local body index (ignored by objects with a single body type)

Returns the body type

cpp
virtual BodyType getBodyType() const

get the object body type. Available types are: DYNAMIC (movable and finite mass), STATIC (not movable and infinite mass), KINEMATIC (movable and infinite mass).

Returns the body type

getContactPointVel ​

cpp
virtual void getContactPointVel(size_t pointId, Vec<3> &vel) const = 0

get the contact point velocity used by the contact solver (the velocity being solved for, not the state before the step). For single bodies, articulated systems and deformable objects, it is expressed in the contact frame (z is the contact normal).

Parameters

ParameterDescription
pointId (in)the contact index. This is an index of a contact in the contact vector that you can retrieve from getContacts().
vel (out)the contact point velocity

getContactAabb ​

cpp
const ::contact::AABB &getContactAabb(size_t idx) const

Internal: broadphase bounding box.

Parameters

ParameterDescription
idx (in)AABB index, less than getContactAabbCount()

Returns the world-frame AABB

getContactAabbCount ​

cpp
size_t getContactAabbCount() const

Internal:

Returns the number of broadphase AABBs.

setName ​

cpp
void setName(const std::string &name)

set the name of the object. You can retrieve an object by name using raisim::World::getObject()

Parameters

ParameterDescription
name (in)name of the object.

getName ​

cpp
const std::string &getName() const

get the name of the object

Returns name of the object

getRenderRevision ​

cpp
std::uint64_t getRenderRevision() const

Revision for renderer-visible object state. It changes when user-visible pose/appearance state is modified or when physics integration moves the object.

Returns the render revision

getExternalForce ​

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

Returns External forces currently applied for visualization (world frame).

getExternalForcePosition ​

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

Returns Positions where external forces are applied (world frame).

getExternalTorque ​

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

Returns External torques currently applied for visualization (world frame).

getExternalTorquePosition ​

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

Returns Positions where external torques are applied (world frame).

clearExternalForcesAndTorques ​

cpp
virtual void clearExternalForcesAndTorques() = 0

Clears the recorded external forces/torques. The exact effect depends on the object type; World does not call it automatically.

lockMutex ​

cpp
void lockMutex()

locks the object mutex. This can be used if you use raisim in a multi-threaded environment.

lock ​

cpp
void lock()

Same as lockMutex(); lets std::lock_guard / std::unique_lock be used with an object.

try_lock ​

cpp
bool try_lock()

Try to lock the mutex without blocking.

Returns true if the lock was acquired.

unlockMutex ​

cpp
void unlockMutex()

unlocks the object mutex. This can be used if you use raisim in a multi-threaded environment.

unlock ​

cpp
void unlock()

Same as unlockMutex().

RaiSim — physics for robotics and AI.