Skip to content

raisim::MaterialManager ​

class · #include <raisim/Materials.hpp>

Table of contact properties per material pair. Materials are identified by name; a pair without its own properties uses the default material properties. The World owns one (see World::setMaterialPairProp() and World::updateMaterialProp()).

Constructors & destructor ​

MaterialManager ​

cpp
MaterialManager()

Creates a table that contains only the "default" material.

cpp
explicit MaterialManager(const std::string &xmlFile)

upload material data from file

Parameters

ParameterDescription
xmlFile (in)RaiSim XML file whose <raisim> root contains a <material> element with an optional <default> child and <pair_prop> children

Public member functions ​

setMaterialPairProp ​

cpp
void setMaterialPairProp(
    const std::string &mat1,
    const std::string &mat2,
    double friction,
    double restitution,
    double resThreshold,
    double staticFriction,
    double staticFrictionVelocityThreshold)

Set the properties of a material pair (rolling and spinning friction are set to 0). Unknown material names are registered. The order of mat1 and mat2 does not matter.

Parameters

ParameterDescription
mat1 (in)first material name
mat2 (in)second material name
friction (in)dynamic friction coefficient
restitution (in)restitution coefficient
resThreshold (in)restitution threshold velocity (m/s)
staticFriction (in)static friction coefficient
staticFrictionVelocityThreshold (in)static friction transition speed (m/s)
cpp
void setMaterialPairProp(
    const std::string &mat1,
    const std::string &mat2,
    double friction,
    double restitution,
    double resThreshold,
    double staticFriction,
    double staticFrictionVelocityThreshold,
    double rollingFriction,
    double spinningFriction)

Set the properties of a material pair, including rolling and spinning friction.

Parameters

ParameterDescription
mat1 (in)first material name
mat2 (in)second material name
friction (in)dynamic friction coefficient
restitution (in)restitution coefficient
resThreshold (in)restitution threshold velocity (m/s)
staticFriction (in)static friction coefficient
staticFrictionVelocityThreshold (in)static friction transition speed (m/s)
rollingFriction (in)rolling friction coefficient
spinningFriction (in)spinning friction coefficient
cpp
void setMaterialPairProp(
    const std::string &mat1,
    const std::string &mat2,
    double friction,
    double restitution,
    double resThreshold)

Set the properties of a material pair. The static friction coefficient equals friction and its transition speed is 1e-3 m/s.

Parameters

ParameterDescription
mat1 (in)first material name
mat2 (in)second material name
friction (in)friction coefficient
restitution (in)restitution coefficient
resThreshold (in)restitution threshold velocity (m/s)

getMaterialPairProp ​

cpp
const MaterialPairProperties &getMaterialPairProp(
    const std::string &mat1,
    const std::string &mat2) const

Parameters

ParameterDescription
mat1 (in)first material name; unknown names are treated as "default"
mat2 (in)second material name; unknown names are treated as "default"

Returns properties of the pair (order-independent), or the default properties if the pair has none

cpp
const MaterialPairProperties &getMaterialPairProp(
    unsigned int mat1,
    unsigned int mat2) const

Parameters

ParameterDescription
mat1 (in)first material id
mat2 (in)second material id

Returns properties of the pair, or the default properties if the pair has none or an id is out of range

getMaterialIdOrDefault ​

cpp
unsigned int getMaterialIdOrDefault(const std::string &matName) const

Parameters

ParameterDescription
matName (in)material name

Returns the id of the material, or the "default" material id if the name is unknown

getDefaultMaterialId ​

cpp
unsigned int getDefaultMaterialId() const

Returns the id of the "default" material

setDefaultMaterialProperties ​

cpp
void setDefaultMaterialProperties(
    double friction,
    double restitution,
    double resThreshold,
    double staticFriction,
    double staticFrictionVelocityThreshold,
    double rollingFriction=0.0,
    double spinningFriction=0.0)

Set the properties used by pairs without their own properties.

Parameters

ParameterDescription
friction (in)dynamic friction coefficient
restitution (in)restitution coefficient
resThreshold (in)restitution threshold velocity (m/s)
staticFriction (in)static friction coefficient
staticFrictionVelocityThreshold (in)static friction transition speed (m/s)
rollingFriction (in)rolling friction coefficient
spinningFriction (in)spinning friction coefficient

Public attributes ​

materials_ ​

cpp
std::unordered_map<unsigned int, MaterialPairProperties> materials_

Pair properties set by setMaterialPairProp(), keyed by larger id * 10000 + smaller id.

materialKeys_ ​

cpp
std::unordered_map<std::string, unsigned int> materialKeys_

Map from material name to material id.

defaultMaterial_ ​

cpp
MaterialPairProperties defaultMaterial_

Default material properties (used when no override exists).

nextMaterialIdx_ ​

cpp
unsigned int nextMaterialIdx_

Next material id to allocate.

RaiSim — physics for robotics and AI.