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
MaterialManager()Creates a table that contains only the "default" material.
explicit MaterialManager(const std::string &xmlFile)upload material data from file
Parameters
| Parameter | Description |
|---|---|
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
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
| Parameter | Description |
|---|---|
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) |
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
| Parameter | Description |
|---|---|
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 |
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
| Parameter | Description |
|---|---|
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
const MaterialPairProperties &getMaterialPairProp(
const std::string &mat1,
const std::string &mat2) constParameters
| Parameter | Description |
|---|---|
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
const MaterialPairProperties &getMaterialPairProp(
unsigned int mat1,
unsigned int mat2) constParameters
| Parameter | Description |
|---|---|
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
unsigned int getMaterialIdOrDefault(const std::string &matName) constParameters
| Parameter | Description |
|---|---|
matName (in) | material name |
Returns the id of the material, or the "default" material id if the name is unknown
getDefaultMaterialId
unsigned int getDefaultMaterialId() constReturns the id of the "default" material
setDefaultMaterialProperties
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
| Parameter | Description |
|---|---|
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_
std::unordered_map<unsigned int, MaterialPairProperties> materials_Pair properties set by setMaterialPairProp(), keyed by larger id * 10000 + smaller id.
materialKeys_
std::unordered_map<std::string, unsigned int> materialKeys_Map from material name to material id.
defaultMaterial_
MaterialPairProperties defaultMaterial_Default material properties (used when no override exists).
nextMaterialIdx_
unsigned int nextMaterialIdx_Next material id to allocate.