Add elasticity parameters to the schema.
PiperOrigin-RevId: 675115200 Change-Id: Ic6608ce61cbb857dca71b3d9cbdac057e8f1ac7a
This commit is contained in:
committed by
Copybara-Service
parent
015bdeb756
commit
b15de2c951
@@ -3746,6 +3746,23 @@ element is used to adjust the properties of all edges in the flex.
|
||||
Edge stiffness and damping, passed through to the automatically generated flex.
|
||||
|
||||
|
||||
.. _flexcomp-elasticity:
|
||||
|
||||
:el-prefix:`flexcomp/` |-| **elasticity** (*)
|
||||
'''''''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
.. _flexcomp-elasticity-young:
|
||||
.. _flexcomp-elasticity-poisson:
|
||||
.. _flexcomp-elasticity-damping:
|
||||
.. _flexcomp-elasticity-thickness:
|
||||
|
||||
.. |body/flexcomp/elasticity attrib list| replace::
|
||||
:at:`young`, :at:`poisson`, :at:`damping`, :at:`thickness`
|
||||
|
||||
|body/flexcomp/elasticity attrib list|
|
||||
Same as in :ref:`flex/elasticity<flex-elasticity>`.
|
||||
All attributes are passed through to the automatically-generated flex.
|
||||
|
||||
.. _flexcomp-pin:
|
||||
|
||||
:el-prefix:`flexcomp/` |-| **pin** (*)
|
||||
@@ -4131,6 +4148,39 @@ these mechanisms to be combined as desired.
|
||||
:at:`damping`: :at-val:`real(1), "0"`
|
||||
Damping of all edges.
|
||||
|
||||
|
||||
.. _flex-elasticity:
|
||||
|
||||
:el-prefix:`flex/` |-| **elasticity** (?)
|
||||
'''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
.. _flex-elasticity-young:
|
||||
|
||||
:at:`young`: :at-val:`real(1), "0"`
|
||||
Young's elastic modulus, a measure of tensile and compressive stiffness for continuum elastic materials.
|
||||
Units of :math:`\textrm{pressure}=\textrm{force}/\textrm{area}`.
|
||||
|
||||
.. _flex-elasticity-poisson:
|
||||
|
||||
:at:`poisson`: :at-val:`real(1), "0"`
|
||||
Poisson's ratio, the ratio of transverse deformation to applied longitudinal strain.
|
||||
This unitless quantity is in the range :math:`[0, 0.5)`.
|
||||
Small or large values imply compressibility or incompressiblity, respectively.
|
||||
|
||||
.. _flex-elasticity-damping:
|
||||
|
||||
:at:`damping`: :at-val:`real(1), "0"`
|
||||
Rayleigh's damping coefficient, units of time.
|
||||
This quantity scales the stiffness defined by Young's modulus to produce the damping matrix.
|
||||
|
||||
.. _flex-elasticity-thickness:
|
||||
|
||||
:at:`thickness`: :at-val:`real(1), "-1"`
|
||||
Shell thickness, units of length; only for used 2D flexes. Used to scale the stretching stiffness.
|
||||
This thickness can be set equal to 2 times the :ref:`radius <deformable-flex-radius>` in order to match the geometry,
|
||||
but is exposed seperately since the radius might be constrained by considerations related to collision detection.
|
||||
|
||||
|
||||
.. _flex-contact:
|
||||
|
||||
:el-prefix:`flex/` |-| **contact** (?)
|
||||
|
||||
@@ -514,6 +514,13 @@
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| |_2| flexcomp |br| |_2| |L| | | .. table:: |
|
||||
| :ref:`elasticity | ? | :class: mjcf-attributes |
|
||||
| <flexcomp-elasticity>` | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`young<flexcomp-elasticity-young>` | :ref:`poisson<flexcomp-elasticity-poisson>` | :ref:`damping<flexcomp-elasticity-damping>` | :ref:`thickness<flexcomp-elasticity-thickness>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| |_2| flexcomp |br| |_2| |L| | | .. table:: |
|
||||
| :ref:`contact | ? | :class: mjcf-attributes |
|
||||
| <flexcomp-contact>` | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
@@ -581,6 +588,13 @@
|
||||
| | | | :ref:`stiffness<flex-edge-stiffness>` | :ref:`damping<flex-edge-damping>` | | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| |_2| flex |br| |_2| |L| | | .. table:: |
|
||||
| :ref:`elasticity | ? | :class: mjcf-attributes |
|
||||
| <flex-elasticity>` | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`young<flex-elasticity-young>` | :ref:`poisson<flex-elasticity-poisson>` | :ref:`damping<flex-elasticity-damping>` | :ref:`thickness<flex-elasticity-thickness>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| |_| deformable |br| |_| |L| | | .. table:: |
|
||||
| :ref:`skin | \* | :class: mjcf-attributes |
|
||||
| <deformable-skin>` | | |
|
||||
|
||||
@@ -1961,6 +1961,10 @@ typedef struct mjsFlex_ { // flex specification
|
||||
double edgedamping; // edge damping
|
||||
float rgba[4]; // rgba when material is omitted
|
||||
mjString* material; // name of material used for rendering
|
||||
double young; // Young's modulus
|
||||
double poisson; // Poisson's ratio
|
||||
double damping; // Rayleigh's damping
|
||||
double thickness; // thickness (2D only)
|
||||
|
||||
// mesh properties
|
||||
mjStringVec* vertbody; // vertex body names
|
||||
|
||||
@@ -424,6 +424,10 @@ typedef struct mjsFlex_ { // flex specification
|
||||
double edgedamping; // edge damping
|
||||
float rgba[4]; // rgba when material is omitted
|
||||
mjString* material; // name of material used for rendering
|
||||
double young; // Young's modulus
|
||||
double poisson; // Poisson's ratio
|
||||
double damping; // Rayleigh's damping
|
||||
double thickness; // thickness (2D only)
|
||||
|
||||
// mesh properties
|
||||
mjStringVec* vertbody; // vertex body names
|
||||
|
||||
@@ -9631,6 +9631,26 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
||||
),
|
||||
doc='name of material used for rendering',
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='young',
|
||||
type=ValueType(name='double'),
|
||||
doc="Young's modulus",
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='poisson',
|
||||
type=ValueType(name='double'),
|
||||
doc="Poisson's ratio",
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='damping',
|
||||
type=ValueType(name='double'),
|
||||
doc="Rayleigh's damping",
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='thickness',
|
||||
type=ValueType(name='double'),
|
||||
doc='thickness (2D only)',
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='vertbody',
|
||||
type=PointerType(
|
||||
|
||||
@@ -34,12 +34,8 @@
|
||||
<flexcomp type="grid" count="24 4 4" spacing=".1 .1 .1" pos=".1 0 1.5"
|
||||
radius=".0" rgba="0 .7 .7 1" name="softbody" dim="3" mass="25">
|
||||
<contact condim="3" solref="0.01 1" solimp=".95 .99 .0001" selfcollide="none"/>
|
||||
<plugin plugin="mujoco.elasticity.solid">
|
||||
<config key="poisson" value="0.2"/>
|
||||
<!--Units are in Pa (SI)-->
|
||||
<config key="young" value="5e4"/>
|
||||
<config key="damping" value="0.002"/>
|
||||
</plugin>
|
||||
<elasticity young="5e4" damping="0.002" poisson="0.2"/>
|
||||
<plugin plugin="mujoco.elasticity.solid"/>
|
||||
</flexcomp>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -46,11 +46,8 @@
|
||||
radius=".005" rgba="0 .7 .7 1" mass="5" name="softbody">
|
||||
<edge damping="1"/>
|
||||
<contact selfcollide="none"/>
|
||||
<plugin plugin="mujoco.elasticity.solid">
|
||||
<config key="poisson" value="0"/>
|
||||
<!--Units are in Pa (SI)-->
|
||||
<config key="young" value="5e4"/>
|
||||
</plugin>
|
||||
<elasticity young="5e4"/>
|
||||
<plugin plugin="mujoco.elasticity.solid"/>
|
||||
</flexcomp>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
|
||||
@@ -35,22 +35,16 @@
|
||||
radius=".005" rgba="0 .7 .7 1" dim="3" mass="5">
|
||||
<contact condim="3" solref="0.01 1" solimp=".95 .99 .0001" selfcollide="none"/>
|
||||
<edge damping="1"/>
|
||||
<plugin plugin="mujoco.elasticity.solid">
|
||||
<config key="poisson" value="0.4"/>
|
||||
<!--Units are in Pa (SI)-->
|
||||
<config key="young" value="1e4"/>
|
||||
</plugin>
|
||||
<elasticity young="1e4" poisson="0.4"/>
|
||||
<plugin plugin="mujoco.elasticity.solid"/>
|
||||
</flexcomp>
|
||||
|
||||
<flexcomp name="B" type="grid" count="4 4 4" spacing=".2 .2 .2" pos="1 0 .5"
|
||||
radius=".005" rgba="0 .7 .7 1" dim="3" mass="5">
|
||||
<contact condim="3" solref="0.01 1" solimp=".95 .99 .0001" selfcollide="none"/>
|
||||
<edge damping="1"/>
|
||||
<plugin plugin="mujoco.elasticity.solid">
|
||||
<config key="poisson" value="0"/>
|
||||
<!--Units are in Pa (SI)-->
|
||||
<config key="young" value="5e4"/>
|
||||
</plugin>
|
||||
<elasticity young="5e4" poisson="0"/>
|
||||
<plugin plugin="mujoco.elasticity.solid"/>
|
||||
</flexcomp>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -44,13 +44,9 @@
|
||||
radius=".001" mass="10" name="plate" dim="2">
|
||||
<contact condim="3" solref="0.01 1" solimp=".95 .99 .0001"/>
|
||||
<edge equality="false" damping="10"/>
|
||||
<elasticity young="3e5" poisson="0" thickness="1e-2"/>
|
||||
<pin id="0 15 240 255"/>
|
||||
<plugin plugin="mujoco.elasticity.membrane">
|
||||
<config key="poisson" value="0"/>
|
||||
<config key="thickness" value="1e-2"/>
|
||||
<!--Units are in Pa (SI)-->
|
||||
<config key="young" value="3e5"/>
|
||||
</plugin>
|
||||
<plugin plugin="mujoco.elasticity.membrane"/>
|
||||
</flexcomp>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
|
||||
@@ -37,11 +37,7 @@ Implemented in [membrane.cc](membrane.cc).
|
||||
|
||||
The membrane plugin discretized an extensible 2D continuum. It is intended to simulate the stretching of membranes subjected to tensile stresses, where the bending is negligible.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `young` [Pa]: Young's modulus.
|
||||
- `poisson` [Pa]: Poisson's ratio; if 0, then the material only opposed shear deformations; if near 0.5, then the material is nearly incompressible (rubber-like).
|
||||
- `thickness` [m]: shell thickness, used to scale the stretching stiffness.
|
||||
Parameters: see [flex parameters](mujoco.readthedocs.io/en/latest/XMLreference.html#flexcomp-elasticity) in the XML Reference docs.
|
||||
|
||||
### Solid
|
||||
|
||||
@@ -49,8 +45,5 @@ Implemented in [solid.cc](solid.cc).
|
||||
|
||||
The membrane plugin discretized an extensible 3D continuum. It is Saint Venant–Kirchhoff model intended to simulate the compression or elongation of hyperelastic materials subjected to large displacements (finite rotations) and small strains, since it uses a nonlinear strain-displacement but a linear stress-strain relationship.
|
||||
|
||||
Parameters:
|
||||
Parameters: see [flex parameters](mujoco.readthedocs.io/en/latest/XMLreference.html#flexcomp-elasticity) in the XML Reference docs.
|
||||
|
||||
- `young` [Pa]: Young's modulus.
|
||||
- `poisson` [Pa]: Poisson's ratio; if 0, then the material only opposed shear deformations; if near 0.5, then the material is nearly incompressible (rubber-like).
|
||||
- `damping` [Ns/m^2]: damping coefficient for Rayleigh damping.
|
||||
|
||||
@@ -242,7 +242,7 @@ void Shell::RegisterPlugin() {
|
||||
plugin.capabilityflags |= mjPLUGIN_PASSIVE;
|
||||
|
||||
const char* attributes[] = {"face", "edge", "young",
|
||||
"poisson", "thickness"};
|
||||
"poisson", "thickness", "damping"};
|
||||
plugin.nattribute = sizeof(attributes) / sizeof(attributes[0]);
|
||||
plugin.attributes = attributes;
|
||||
plugin.nstate = +[](const mjModel* m, int instance) { return 0; };
|
||||
|
||||
@@ -222,7 +222,7 @@ void Solid::RegisterPlugin() {
|
||||
plugin.name = "mujoco.elasticity.solid";
|
||||
plugin.capabilityflags |= mjPLUGIN_PASSIVE;
|
||||
|
||||
const char* attributes[] = {"face", "edge", "young", "poisson", "damping"};
|
||||
const char* attributes[] = {"face", "edge", "young", "poisson", "damping", "thickness"};
|
||||
plugin.nattribute = sizeof(attributes) / sizeof(attributes[0]);
|
||||
plugin.attributes = attributes;
|
||||
plugin.nstate = +[](const mjModel* m, int instance) { return 0; };
|
||||
|
||||
@@ -236,6 +236,7 @@ void mjs_defaultFlex(mjsFlex* flex) {
|
||||
flex->activelayers = 1;
|
||||
flex->rgba[0] = flex->rgba[1] = flex->rgba[2] = 0.5f;
|
||||
flex->rgba[3] = 1.0f;
|
||||
flex->thickness = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2675,6 +2675,18 @@ void mjCFlex::Compile(const mjVFS* vfs) {
|
||||
if (model->Bodies()[vbodyid]->plugin.instance) {
|
||||
mjCPlugin* plugin_instance =
|
||||
static_cast<mjCPlugin*>(model->Bodies()[vbodyid]->plugin.instance);
|
||||
if (young > 0) {
|
||||
plugin_instance->config_attribs["young"] = std::to_string(young);
|
||||
}
|
||||
if (poisson > 0) {
|
||||
plugin_instance->config_attribs["poisson"] = std::to_string(poisson);
|
||||
}
|
||||
if (thickness > 0) {
|
||||
plugin_instance->config_attribs["thickness"] = std::to_string(thickness);
|
||||
}
|
||||
if (damping > 0) {
|
||||
plugin_instance->config_attribs["damping"] = std::to_string(damping);
|
||||
}
|
||||
plugin_instance->config_attribs["face"] = userface;
|
||||
plugin_instance->config_attribs["edge"] = useredge;
|
||||
}
|
||||
|
||||
@@ -326,6 +326,7 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
"flatskin", "pos", "quat", "axisangle", "xyaxes", "zaxis", "euler"},
|
||||
{"<"},
|
||||
{"edge", "?", "5", "equality", "solref", "solimp", "stiffness", "damping"},
|
||||
{"elasticity", "?", "4", "young", "poisson", "damping", "thickness"},
|
||||
{"contact", "?", "13", "contype", "conaffinity", "condim", "priority",
|
||||
"friction", "solmix", "solref", "solimp", "margin", "gap",
|
||||
"internal", "selfcollide", "activelayers"},
|
||||
@@ -346,6 +347,7 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
"friction", "solmix", "solref", "solimp", "margin", "gap",
|
||||
"internal", "selfcollide", "activelayers"},
|
||||
{"edge", "?", "2", "stiffness", "damping"},
|
||||
{"elasticity", "?", "4", "young", "poisson", "damping", "thickness"},
|
||||
{">"},
|
||||
{"skin", "*", "9", "name", "file", "material", "rgba", "inflate",
|
||||
"vertex", "texcoord", "face", "group"},
|
||||
@@ -1388,6 +1390,15 @@ void mjXReader::OneFlex(XMLElement* elem, mjsFlex* flex) {
|
||||
ReadAttr(edge, "damping", 1, &flex->edgedamping, text);
|
||||
}
|
||||
|
||||
// elasticity subelement
|
||||
XMLElement* elasticity = FirstChildElement(elem, "elasticity");
|
||||
if (elasticity) {
|
||||
ReadAttr(elasticity, "young", 1, &flex->young, text);
|
||||
ReadAttr(elasticity, "poisson", 1, &flex->poisson, text);
|
||||
ReadAttr(elasticity, "thickness", 1, &flex->thickness, text);
|
||||
ReadAttr(elasticity, "damping", 1, &flex->damping, text);
|
||||
}
|
||||
|
||||
// write error info
|
||||
mjs_setString(flex->info, ("line " + std::to_string(elem->GetLineNum())).c_str());
|
||||
}
|
||||
@@ -2674,6 +2685,15 @@ void mjXReader::OneFlexcomp(XMLElement* elem, mjsBody* body, const mjVFS* vfs) {
|
||||
ReadAttr(edge, "damping", 1, &dflex.edgedamping, text);
|
||||
}
|
||||
|
||||
// elasticity
|
||||
XMLElement* elasticity = FirstChildElement(elem, "elasticity");
|
||||
if (elasticity) {
|
||||
ReadAttr(elasticity, "young", 1, &dflex.young, text);
|
||||
ReadAttr(elasticity, "poisson", 1, &dflex.poisson, text);
|
||||
ReadAttr(elasticity, "damping", 1, &dflex.damping, text);
|
||||
ReadAttr(elasticity, "thickness", 1, &dflex.thickness, text);
|
||||
}
|
||||
|
||||
// contact
|
||||
XMLElement* cont = FirstChildElement(elem, "contact");
|
||||
if (cont) {
|
||||
|
||||
@@ -101,7 +101,7 @@ class mjXReader : public mjXBase {
|
||||
};
|
||||
|
||||
// MJCF schema
|
||||
#define nMJCF 243
|
||||
#define nMJCF 245
|
||||
extern const char* MJCF[nMJCF][mjXATTRNUM];
|
||||
|
||||
#endif // MUJOCO_SRC_XML_XML_NATIVE_READER_H_
|
||||
|
||||
@@ -44,10 +44,8 @@ TEST_F(ElasticityTest, FlexCompatibility) {
|
||||
<flexcomp name="soft" type="grid" count="3 3 3"
|
||||
radius="0.01" dim="3"mass="1">
|
||||
<pin id="2"/>
|
||||
<plugin plugin="mujoco.elasticity.solid">
|
||||
<config key="poisson" value="0.2"/>
|
||||
<config key="young" value="5e4"/>
|
||||
</plugin>
|
||||
<elasticity young="5e4" poisson="0.2"/>
|
||||
<plugin plugin="mujoco.elasticity.solid"/>
|
||||
</flexcomp>
|
||||
</body>
|
||||
</worldbody>
|
||||
@@ -128,11 +126,8 @@ TEST_F(PluginTest, ElasticEnergyMembrane) {
|
||||
<worldbody>
|
||||
<flexcomp type="grid" count="8 8 1" spacing="1 1 1"
|
||||
radius=".025" name="test" dim="2">
|
||||
<plugin plugin="mujoco.elasticity.membrane">
|
||||
<config key="poisson" value="0"/>
|
||||
<config key="young" value="2"/>
|
||||
<config key="thickness" value="1"/>
|
||||
</plugin>
|
||||
<elasticity young="2" poisson="0" thickness="1"/>
|
||||
<plugin plugin="mujoco.elasticity.membrane"/>
|
||||
<edge equality="false"/>
|
||||
</flexcomp>
|
||||
</worldbody>
|
||||
@@ -214,10 +209,8 @@ TEST_F(ElasticityTest, ElasticEnergySolid) {
|
||||
<worldbody>
|
||||
<flexcomp type="grid" count="8 8 8" spacing="1 1 1"
|
||||
radius=".025" name="test" dim="3">
|
||||
<plugin plugin="mujoco.elasticity.solid">
|
||||
<config key="poisson" value="0"/>
|
||||
<config key="young" value="2"/>
|
||||
</plugin>
|
||||
<elasticity young="2" poisson="0"/>
|
||||
<plugin plugin="mujoco.elasticity.solid"/>
|
||||
<edge equality="false"/>
|
||||
</flexcomp>
|
||||
</worldbody>
|
||||
|
||||
Reference in New Issue
Block a user