Skip to content

raisim::InstancedVisuals ​

struct · #include <raisim/server/Visuals.hpp>

Many visual-only instances of one shape, drawn with per-instance pose, scale and a color interpolated between color1 and color2. Create with RaisimServer::addInstancedVisuals(); the server owns it. Instance ids are indices into the instance array (0 .. count()-1); ids are not checked.

Constructors & destructor ​

InstancedVisuals ​

cpp
InstancedVisuals(
    Shape::Type type,
    std::string name,
    const Vec<3> &size,
    const Vec<4> &color1,
    const Vec<4> &color2)

Normally called by RaisimServer::addInstancedVisuals().

Parameters

ParameterDescription
type (in)shape of every instance
name (in)name used by the server
size (in)base size of an instance (same convention as Visuals::size)
color1 (in)color at weight 0
color2 (in)color at weight 1

Public member functions ​

count ​

cpp
size_t count()

Returns the number of instances

clearInstances ​

cpp
void clearInstances()

clear the instances

resize ​

cpp
void resize(size_t numberOfObjects)

Resize the instance array. Every instance (including existing ones) is reset to identity orientation and the base size; new instances start at the origin with color weight 0.

Parameters

ParameterDescription
numberOfObjects (in)new number of instances

addInstance ​

cpp
void addInstance(
    const Eigen::Vector3d &pos,
    const Eigen::Vector4d &ori,
    const Eigen::Vector3d &scale,
    float colorWeight=0.f)

Parameters

ParameterDescription
pos (in)position of the visual object in Eigen::Vector3d.
ori (in)quaternion of the visual object in Eigen::Vector4d.
scale (in)per-axis multiplier applied to the base size.
colorWeight (in)the final color is an weighted average of color1 and color2 add a new instance of the specified pose
cpp
void addInstance(
    const Eigen::Vector3d &pos,
    const Eigen::Vector4d &ori,
    float colorWeight=0.f)

Parameters

ParameterDescription
pos (in)position of the visual object in Eigen::Vector3d.
ori (in)quaternion of the visual object in Eigen::Vector4d.
colorWeight (in)the final color is an weighted average of color1 and color2 add a new instance of the specified pose
cpp
void addInstance(const Eigen::Vector3d &pos, float colorWeight=0.f)

Parameters

ParameterDescription
pos (in)position of the visual object in Eigen::Vector3d.
colorWeight (in)the final color is a weighted average of color1 and color2 add a new instance of the specified position and an identity rotation

removeInstance ​

cpp
void removeInstance(size_t id)

Remove a single instance by moving the last instance into its slot (the order is not preserved; the former last instance now has this id).

Parameters

ParameterDescription
id (in)instance id

setPosition ​

cpp
void setPosition(size_t id, const Eigen::Vector3d &pos)

Parameters

ParameterDescription
id (in)instance id.
pos (in)position of the visual object in Eigen::Vector3d. set the position of the specified instance of the visual object.

setOrientation ​

cpp
void setOrientation(size_t id, const Eigen::Vector4d &ori)

Parameters

ParameterDescription
id (in)instance id.
ori (in)quaternion of the visual object in Eigen::Vector4d. set the orientation of the specified instance of the visual object.

setScale ​

cpp
void setScale(size_t id, const Eigen::Vector3d &scale)

Parameters

ParameterDescription
id (in)instance id.
scale (in)absolute per-axis size of the instance (not multiplied by the base size). set the scale of the specified instance of the visual object.

setColor ​

cpp
void setColor(const Vec<4> &color1, const Vec<4> &color2)

Parameters

ParameterDescription
color1 (in)first color.
color2 (in)second color. The color of the instance is interpolated between the two colors. 100% color1 when weight is 0.

setColorWeight ​

cpp
void setColorWeight(size_t id, float weight)

Parameters

ParameterDescription
id (in)instance id
weight (in)the color weight The actual color is linearly interpolated between color1 and color2 which are set by setColor method. 100% color1 when weight is 0.

getPosition ​

cpp
Eigen::Vector3d getPosition(size_t id)

Parameters

ParameterDescription
id (in)instance id.

Returns the position of the specified instance.

getOrientation ​

cpp
Eigen::Vector4d getOrientation(size_t id)

Parameters

ParameterDescription
id (in)instance id.

Returns the orientation of the specified instance as a quaternion (w, x, y, z).

getScale ​

cpp
Eigen::Vector3d getScale(size_t id)

Parameters

ParameterDescription
id (in)instance id.

Returns the absolute per-axis size of the specified instance.

lockMutex ​

cpp
void lockMutex()

Lock this instanced visual's mutex. The server holds it while serializing this instanced visual, so lock it while modifying the instanced visual from another thread. Same as lock().

lock ​

cpp
void lock()

Lock the mutex (BasicLockable interface for std::lock_guard / std::unique_lock).

try_lock ​

cpp
bool try_lock()

Returns true if the mutex was acquired without blocking (Lockable interface).

unlockMutex ​

cpp
void unlockMutex()

Unlock the mutex locked by lockMutex(). Same as unlock().

unlock ​

cpp
void unlock()

Unlock the mutex (BasicLockable interface).

RaiSim — physics for robotics and AI.