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
using Id = std::uint64_tStable object id type (see getId()).
Constructors & destructor
Object
explicit Object()Objects are created through World (e.g., World::addSphere()).
~Object
virtual ~Object() = defaultPublic member functions
clearPerObjectContact
void clearPerObjectContact()Internal: clears the contact list (called by World before collision detection).
addContactToPerObjectContact
void addContactToPerObjectContact(Contact &contact)Internal: appends a contact to the contact list.
Parameters
| Parameter | Description |
|---|---|
contact (in) | the contact to copy |
setIndexInWorld
void setIndexInWorld(size_t indexInWorld_)Internal: set by World when the object list changes.
Parameters
| Parameter | Description |
|---|---|
indexInWorld_ (in) | the new index in World::getObjList() |
getIndexInWorld
size_t getIndexInWorld() constget 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
Id getId() constReturns 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
const std::vector<Contact> &getContacts() constget a vector of all contacts on the object.
Returns contacts on the body
std::vector<Contact> &getContacts()Returns mutable contacts on the body (see the const overload).
updateCollision
virtual void updateCollision() = 0Internal: synchronizes the collision geometry with the current pose.
updateContactAabbs
virtual void updateContactAabbs() = 0Internal: recomputes the world-frame AABBs used by the broadphase.
preContactSolverUpdate1
virtual void preContactSolverUpdate1(const Vec<3> &gravity, double dt) = 0Internal: first per-step update before the contact solver (called by World).
Parameters
| Parameter | Description |
|---|---|
gravity (in) | gravitational acceleration (m/s^2) |
dt (in) | time step (s) |
preContactSolverUpdate2
virtual void preContactSolverUpdate2(
const Vec<3> &gravity,
double dt,
contact::ContactProblems &problems) = 0Internal: second per-step update before the contact solver (called by World).
Parameters
| Parameter | Description |
|---|---|
gravity (in) | gravitational acceleration (m/s^2) |
dt (in) | time step (s) |
problems (in, out) | contact problems of the world |
integrate
virtual void integrate(double dt, class World &world) = 0Internal: integrates the state after the contact solve (called by World).
Parameters
| Parameter | Description |
|---|---|
dt (in) | time step (s) |
world (in) | the owning world |
setExternalForce
virtual void setExternalForce(size_t localIdx, const Vec<3> &force) = 0apply forces at the Center of Mass
Parameters
| Parameter | Description |
|---|---|
localIdx (in) | local body index |
force (in) | force in the world frame (N) |
virtual void setExternalForce(
size_t localIdx,
const Vec<3> &pos,
const Vec<3> &force) = 0apply force (expressed in the world frame) at specific location of the body (expressed in the body frame)
Parameters
| Parameter | Description |
|---|---|
localIdx (in) | local body index |
pos (in) | application point in the body frame |
force (in) | force in the world frame (N) |
setExternalTorque
virtual void setExternalTorque(size_t localIdx, const Vec<3> &torque) = 0apply torque on a body
Parameters
| Parameter | Description |
|---|---|
localIdx (in) | local body index |
torque (in) | torque in the world frame (Nm) |
setConstraintForce
virtual void setConstraintForce(
size_t localIdx,
const Vec<3> &pos,
const Vec<3> &force) = 0Internal: 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
| Parameter | Description |
|---|---|
localIdx (in) | local body index |
pos (in) | application point in the body frame |
force (in) | force in the world frame (N) |
getMass
virtual double getMass(size_t localIdx) const = 0Parameters
| Parameter | Description |
|---|---|
localIdx (in) | local body (or particle) index |
Returns the mass of the local body (kg)
getObjectType
virtual ObjectType getObjectType() const = 0get the object type. Possible types are SPHERE, BOX, CYLINDER, CONE, CAPSULE, MESH, HALFSPACE, COMPOUND, HEIGHTMAP, ARTICULATED_SYSTEM, DEFORMABLE, GRANULAR
Returns the object type
getPosition
virtual void getPosition(size_t localIdx, Vec<3> &pos_w) const = 0get the position of a local body (its body frame origin) or particle.
Parameters
| Parameter | Description |
|---|---|
localIdx (in) | local body (or particle) index |
pos_w (out) | position in the world frame (m) |
virtual void getPosition(
size_t localIdx,
const Vec<3> &pos_b,
Vec<3> &pos_w) const = 0get the world position of a point fixed to a local body.
Parameters
| Parameter | Description |
|---|---|
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
virtual void getVelocity(size_t localIdx, Vec<3> &vel_w) const = 0get the linear velocity of a local body or particle.
Parameters
| Parameter | Description |
|---|---|
localIdx (in) | local body (or particle) index |
vel_w (out) | linear velocity in the world frame (m/s) |
virtual void getVelocity(
size_t localIdx,
const Vec<3> &pos_b,
Vec<3> &vel_w) const = 0get the world velocity of a point fixed to a local body.
Parameters
| Parameter | Description |
|---|---|
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
virtual void getOrientation(size_t localIdx, Mat<3, 3> &rot) const = 0get the orientation of a local body.
Parameters
| Parameter | Description |
|---|---|
localIdx (in) | local body index |
rot (out) | body-to-world rotation matrix |
getBodyType
virtual BodyType getBodyType(size_t localIdx) constget 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
| Parameter | Description |
|---|---|
localIdx (in) | local body index (ignored by objects with a single body type) |
Returns the body type
virtual BodyType getBodyType() constget 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
virtual void getContactPointVel(size_t pointId, Vec<3> &vel) const = 0get 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
| Parameter | Description |
|---|---|
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
const ::contact::AABB &getContactAabb(size_t idx) constInternal: broadphase bounding box.
Parameters
| Parameter | Description |
|---|---|
idx (in) | AABB index, less than getContactAabbCount() |
Returns the world-frame AABB
getContactAabbCount
size_t getContactAabbCount() constInternal:
Returns the number of broadphase AABBs.
setName
void setName(const std::string &name)set the name of the object. You can retrieve an object by name using raisim::World::getObject()
Parameters
| Parameter | Description |
|---|---|
name (in) | name of the object. |
getName
const std::string &getName() constget the name of the object
Returns name of the object
getRenderRevision
std::uint64_t getRenderRevision() constRevision 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
const std::vector<Vec<3>> &getExternalForce() constReturns External forces currently applied for visualization (world frame).
getExternalForcePosition
const std::vector<Vec<3>> &getExternalForcePosition() constReturns Positions where external forces are applied (world frame).
getExternalTorque
const std::vector<Vec<3>> &getExternalTorque() constReturns External torques currently applied for visualization (world frame).
getExternalTorquePosition
const std::vector<Vec<3>> &getExternalTorquePosition() constReturns Positions where external torques are applied (world frame).
clearExternalForcesAndTorques
virtual void clearExternalForcesAndTorques() = 0Clears the recorded external forces/torques. The exact effect depends on the object type; World does not call it automatically.
lockMutex
void lockMutex()locks the object mutex. This can be used if you use raisim in a multi-threaded environment.
lock
void lock()Same as lockMutex(); lets std::lock_guard / std::unique_lock be used with an object.
try_lock
bool try_lock()Try to lock the mutex without blocking.
Returns true if the lock was acquired.
unlockMutex
void unlockMutex()unlocks the object mutex. This can be used if you use raisim in a multi-threaded environment.
unlock
void unlock()Same as unlockMutex().