Fix "actrange" parsing for "intvelocity" actuators.

PiperOrigin-RevId: 468759706
Change-Id: I1d9eeb723d28cccb64a6112b103345fcf451700f
This commit is contained in:
Kevin Zakka
2022-08-19 12:22:13 -07:00
committed by Copybara-Service
parent ee6fed1230
commit 0b2f19bbe7
3 changed files with 37 additions and 6 deletions
+2 -1
View File
@@ -12,7 +12,7 @@ General
:align: right
:height: 150px
- Added :ref:`adhesion actuators<adhesion>` mimicking vaccum grippers and adhesive biomechanical appendages.
- Added :ref:`adhesion actuators<adhesion>` mimicking vacuum grippers and adhesive biomechanical appendages.
- Added related `example model <https://github.com/deepmind/mujoco/tree/main/model/adhesion>`_ and video:
- Added :ref:`mj_jacSubtreeCom` for computing the translational Jacobian of the center-of-mass of a subtree.
- Added moment of inertia computation for concave meshes. This is currently activated by setting the compiler flag
@@ -48,6 +48,7 @@ Deleted/deprecated features
Bug fixes
^^^^^^^^^
- Fixed rendering of some transparent geoms in reflection.
- Fixed ``intvelocity`` defaults parsing.
Version 2.2.1 (July 18, 2022)
-----------------------------
-4
View File
@@ -1509,10 +1509,6 @@ void mjXReader::OneActuator(XMLElement* elem, mjCActuator* pact) {
pact->biastype = mjBIAS_AFFINE;
pact->actlimited = 1;
pact->biasprm[1] = -pact->gainprm[0];
// require actrange
if (!ReadAttr(elem, "actrange", 2, pact->actrange, text)) {
throw mjXError(elem, "actrange is required for an intvelocity actuator", type.c_str());
}
}
// damper
+35 -1
View File
@@ -648,7 +648,41 @@ TEST_F(IntegratedVelocityTest, NoActrangeThrowsError) {
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
ASSERT_THAT(model, IsNull());
EXPECT_THAT(error.data(), HasSubstr("actrange is required for an intvelocity actuator"));
EXPECT_THAT(error.data(), HasSubstr("invalid activation range for actuator"));
}
TEST_F(IntegratedVelocityTest, DefaultsPropagate) {
static constexpr char xml[] = R"(
<mujoco>
<default>
<intvelocity kp="5"/>
<default class="withactrange">
<intvelocity kp="1" actrange="-1 1"/>
</default>
</default>
<worldbody>
<body>
<joint name="hinge1"/>
<joint name="hinge2"/>
<geom type="box" size=".025 .025 .025"/>
</body>
</worldbody>
<actuator>
<intvelocity joint="hinge1" actrange="0 1"/>
<intvelocity joint="hinge2" class="withactrange"/>
</actuator>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
ASSERT_THAT(model, testing::NotNull());
EXPECT_DOUBLE_EQ(model->actuator_gainprm[0], 5);
EXPECT_DOUBLE_EQ(model->actuator_gainprm[mjNGAIN], 1);
EXPECT_DOUBLE_EQ(model->actuator_actrange[0 + 0], 0);
EXPECT_DOUBLE_EQ(model->actuator_actrange[0 + 1], 1);
EXPECT_DOUBLE_EQ(model->actuator_actrange[0 + 2], -1);
EXPECT_DOUBLE_EQ(model->actuator_actrange[0 + 3], 1);
mj_deleteModel(model);
}
} // namespace