Runtime disabling of actuators according to group.

Added `option-actuatorgroupdisable` attribute and associated `mjOption.disableactuator` integer bitfield, used to disable sets of actuators at runtime according to their group.

- The first 6 actuator groups are toggleable in the `simulate` viewer.
- Minor refactor and cleanup of actuator documentation.

https://youtu.be/H9qG9Zf2W44

Fixes #1092.

PiperOrigin-RevId: 578335600
Change-Id: I4cf663b90ea768e4380acfa2fe3b8c15c7cbb568
This commit is contained in:
Yuval Tassa
2023-10-31 16:23:58 -07:00
committed by Copybara-Service
parent 45878b7eef
commit 893c404230
25 changed files with 525 additions and 125 deletions
+38
View File
@@ -1049,6 +1049,44 @@ TEST_F(ActuatorParseTest, MusclesSmoothdynNegative) {
EXPECT_THAT(error.data(), HasSubstr("muscle tausmooth cannot be negative"));
}
TEST_F(ActuatorParseTest, GroupDisable) {
static constexpr char xml[] = R"(
<mujoco>
<option actuatorgroupdisable="0 3 8 3"/>
<!-- note: repeated numbers are okay -->
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
ASSERT_THAT(model, NotNull());
EXPECT_EQ(model->opt.disableactuator, (1<<0) + (1<<3) + (1<<8));
mj_deleteModel(model);
}
TEST_F(ActuatorParseTest, GroupDisableNegative) {
static constexpr char xml[] = R"(
<mujoco>
<option actuatorgroupdisable="0 -3 5"/>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
ASSERT_THAT(model, IsNull());
EXPECT_THAT(error.data(), HasSubstr("must be non-negative"));
}
TEST_F(ActuatorParseTest, GroupDisableTooBig) {
static constexpr char xml[] = R"(
<mujoco>
<option actuatorgroupdisable="0 31"/>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
ASSERT_THAT(model, IsNull());
EXPECT_THAT(error.data(), HasSubstr("cannot exceed 30"));
}
// ------------- test sensor parsing -------------------------------------------
using SensorParseTest = MujocoTest;