Rename <required> tag to <plugin>.
PiperOrigin-RevId: 509237786 Change-Id: I35e812830b479004ac5025cbd9477888f51fb43e
This commit is contained in:
committed by
Copybara-Service
parent
239e00e3b1
commit
db28c31f05
+1
-1
@@ -446,7 +446,7 @@
|
||||
| |_|:el:`extension` | \* | *no attribute* |
|
||||
| | | |
|
||||
+--------------------------+----+------------------------------------------------------------------------------------+
|
||||
| |_2|:el:`required` | \* | .. table:: |
|
||||
| |_2|:el:`plugin` | \* | .. table:: |
|
||||
| | | :class: mjcf-attributes |
|
||||
| | | |
|
||||
| | | +-------------------------+-------------------------+-------------------------+ |
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<include file="scene.xml"/>
|
||||
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.cable"/>
|
||||
<plugin plugin="mujoco.elasticity.cable"/>
|
||||
</extension>
|
||||
|
||||
<statistic center="0 0 .2" extent="1"/>
|
||||
@@ -74,4 +74,4 @@
|
||||
<actuator>
|
||||
<motor site="S_last" gear="0 0 0 1 0 0" ctrlrange="-.2 .2"/>
|
||||
</actuator>
|
||||
</mujoco>
|
||||
</mujoco>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<include file="scene.xml"/>
|
||||
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.cable"/>
|
||||
<plugin plugin="mujoco.elasticity.cable"/>
|
||||
</extension>
|
||||
|
||||
<statistic center="0 0 .3" extent="1"/>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<include file="scene.xml"/>
|
||||
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.cable"/>
|
||||
<plugin plugin="mujoco.elasticity.cable"/>
|
||||
</extension>
|
||||
|
||||
<statistic center="0 0 .2" extent="1"/>
|
||||
@@ -103,4 +103,4 @@
|
||||
<actuator>
|
||||
<position joint="slide" name="extend" gear="1 0 0 0 0 0" ctrlrange="-.25 1" kp="100"/>
|
||||
</actuator>
|
||||
</mujoco>
|
||||
</mujoco>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<include file="scene.xml"/>
|
||||
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.solid"/>
|
||||
<plugin plugin="mujoco.elasticity.solid"/>
|
||||
</extension>
|
||||
|
||||
<compiler autolimits="true"/>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<include file="scene.xml"/>
|
||||
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.solid"/>
|
||||
<plugin plugin="mujoco.elasticity.solid"/>
|
||||
</extension>
|
||||
|
||||
<option solver="CG" tolerance="1e-6" timestep=".001"/>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<include file="scene.xml"/>
|
||||
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.solid"/>
|
||||
<plugin plugin="mujoco.elasticity.solid"/>
|
||||
</extension>
|
||||
|
||||
<compiler autolimits="true"/>
|
||||
|
||||
@@ -72,7 +72,7 @@ TEST_XML_SENSOR = r"""
|
||||
TEST_XML_PLUGIN = r"""
|
||||
<mujoco model="test">
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.cable"/>
|
||||
<plugin plugin="mujoco.elasticity.cable"/>
|
||||
</extension>
|
||||
</mujoco>
|
||||
"""
|
||||
|
||||
@@ -190,11 +190,11 @@ static const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
|
||||
{"extension", "*", "0"},
|
||||
{"<"},
|
||||
{"required", "*", "1", "plugin"},
|
||||
{"plugin", "*", "1", "plugin"},
|
||||
{"<"},
|
||||
{"instance", "*", "1", "name"},
|
||||
{"<"},
|
||||
{"config", "*", "2", "key", "value"},
|
||||
{"config", "*", "2", "key", "value"},
|
||||
{">"},
|
||||
{">"},
|
||||
{">"},
|
||||
@@ -2196,7 +2196,7 @@ void mjXReader::Extension(XMLElement* section) {
|
||||
// get sub-element name
|
||||
std::string_view name = elem->Value();
|
||||
|
||||
if (name == "required") {
|
||||
if (name == "plugin") {
|
||||
std::string plugin_name;
|
||||
int plugin_slot = -1;
|
||||
ReadAttrTxt(elem, "plugin", plugin_name, /* required = */ true);
|
||||
|
||||
@@ -1081,12 +1081,12 @@ void mjXWriter::Extension(XMLElement* root) {
|
||||
// create section
|
||||
XMLElement* section = InsertEnd(root, "extension");
|
||||
|
||||
// keep track of plugins whose <required> section have been created
|
||||
// keep track of plugins whose <plugin> section have been created
|
||||
std::unordered_set<const mjpPlugin*> seen_plugins;
|
||||
|
||||
// write all plugins
|
||||
const mjpPlugin* last_plugin = nullptr;
|
||||
XMLElement* required_elem = nullptr;
|
||||
XMLElement* plugin_elem = nullptr;
|
||||
for (int i = 0; i < model->plugins.size(); ++i) {
|
||||
mjCPlugin* pp = static_cast<mjCPlugin*>(model->GetObject(mjOBJ_PLUGIN, i));
|
||||
|
||||
@@ -1096,17 +1096,17 @@ void mjXWriter::Extension(XMLElement* root) {
|
||||
break;
|
||||
}
|
||||
|
||||
// check if we need to open a new <required> section
|
||||
// check if we need to open a new <plugin> section
|
||||
const mjpPlugin* plugin = mjp_getPluginAtSlot(pp->plugin_slot);
|
||||
if (plugin != last_plugin) {
|
||||
required_elem = InsertEnd(section, "required");
|
||||
WriteAttrTxt(required_elem, "plugin", plugin->name);
|
||||
plugin_elem = InsertEnd(section, "plugin");
|
||||
WriteAttrTxt(plugin_elem, "plugin", plugin->name);
|
||||
seen_plugins.insert(plugin);
|
||||
last_plugin = plugin;
|
||||
}
|
||||
|
||||
// write instance element
|
||||
XMLElement* elem = InsertEnd(required_elem, "instance");
|
||||
XMLElement* elem = InsertEnd(plugin_elem, "instance");
|
||||
WriteAttrTxt(elem, "name", pp->name);
|
||||
|
||||
// write plugin config attributes
|
||||
@@ -1123,11 +1123,11 @@ void mjXWriter::Extension(XMLElement* root) {
|
||||
}
|
||||
}
|
||||
|
||||
// write <required> elements for plugins without explicit instances
|
||||
// write <plugin> elements for plugins without explicit instances
|
||||
for (const auto& [plugin, slot] : model->active_plugins) {
|
||||
if (seen_plugins.find(plugin) == seen_plugins.end()) {
|
||||
required_elem = InsertEnd(section, "required");
|
||||
WriteAttrTxt(required_elem, "plugin", plugin->name);
|
||||
plugin_elem = InsertEnd(section, "plugin");
|
||||
WriteAttrTxt(plugin_elem, "plugin", plugin->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,19 +343,19 @@ class PluginTest : public MujocoTest {
|
||||
constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<extension>
|
||||
<required plugin="mujoco.test.sensor">
|
||||
<plugin plugin="mujoco.test.sensor">
|
||||
<instance name="twosensors"/>
|
||||
<instance name="threesensors">
|
||||
<config key="stride" value="3"/>
|
||||
</instance>
|
||||
</required>
|
||||
<required plugin="mujoco.test.actuator">
|
||||
</plugin>
|
||||
<plugin plugin="mujoco.test.actuator">
|
||||
<instance name="actuator2">
|
||||
<config key="stride" value="2"/>
|
||||
<config key="multiplier" value="0.125"/>
|
||||
</instance>
|
||||
</required>
|
||||
<required plugin="mujoco.test.passive"/>
|
||||
</plugin>
|
||||
<plugin plugin="mujoco.test.passive"/>
|
||||
</extension>
|
||||
<worldbody>
|
||||
<body>
|
||||
|
||||
@@ -56,7 +56,7 @@ TEST_F(PluginTest, ElasticEnergy) {
|
||||
static constexpr char cantilever_xml[] = R"(
|
||||
<mujoco>
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.solid"/>
|
||||
<plugin plugin="mujoco.elasticity.solid"/>
|
||||
</extension>
|
||||
|
||||
<worldbody>
|
||||
@@ -114,7 +114,7 @@ TEST_F(PluginTest, CantileverIntoCircle) {
|
||||
<mujoco>
|
||||
<option gravity="0 0 0"/>
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.cable"/>
|
||||
<plugin plugin="mujoco.elasticity.cable"/>
|
||||
</extension>
|
||||
<worldbody>
|
||||
<geom type="plane" size="0 0 1" quat="1 0 0 0"/>
|
||||
@@ -167,12 +167,12 @@ TEST_F(PluginTest, InvalidTxtAttribute) {
|
||||
static constexpr char cantilever_xml[] = R"(
|
||||
<mujoco>
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.cable">
|
||||
<plugin plugin="mujoco.elasticity.cable">
|
||||
<instance name="invalid">
|
||||
<config key="twist" value="one"/>
|
||||
<config key="bend" value="1"/>
|
||||
</instance>
|
||||
</required>
|
||||
</plugin>
|
||||
</extension>
|
||||
<worldbody>
|
||||
<geom type="plane" size="0 0 1" quat="1 0 0 0"/>
|
||||
@@ -190,12 +190,12 @@ TEST_F(PluginTest, InvalidMixedAttribute) {
|
||||
static constexpr char cantilever_xml[] = R"(
|
||||
<mujoco>
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.cable">
|
||||
<plugin plugin="mujoco.elasticity.cable">
|
||||
<instance name="invalid">
|
||||
<config key="twist" value="1"/>
|
||||
<config key="bend" value="1 is not a number"/>
|
||||
</instance>
|
||||
</required>
|
||||
</plugin>
|
||||
</extension>
|
||||
<worldbody>
|
||||
<geom type="plane" size="0 0 1" quat="1 0 0 0"/>
|
||||
@@ -213,12 +213,12 @@ TEST_F(PluginTest, ValidAttributes) {
|
||||
static constexpr char cantilever_xml[] = R"(
|
||||
<mujoco>
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.cable">
|
||||
<plugin plugin="mujoco.elasticity.cable">
|
||||
<instance name="invalid">
|
||||
<config key="twist" value="0.0"/>
|
||||
<config key="bend" value=" 0 "/>
|
||||
</instance>
|
||||
</required>
|
||||
</plugin>
|
||||
</extension>
|
||||
<worldbody>
|
||||
<geom type="plane" size="0 0 1" quat="1 0 0 0"/>
|
||||
|
||||
Reference in New Issue
Block a user