Allow partial specification of polycoef attribute of equality constraints.
- Usually the user only wants to tweak `polycoef[1]`, after this change `"0 2"` is equivalent to `"0 2 0 0 0"`. - Also improve documentation of this attribute. - Tighten margins of documentation display equations. PiperOrigin-RevId: 639720742 Change-Id: Ibafa0e093cebe1c1c75bf2e47ff3bd2ad7619414
This commit is contained in:
committed by
Copybara-Service
parent
14a3ce5ffa
commit
8fa0fea02d
@@ -34,8 +34,13 @@
|
||||
namespace mujoco {
|
||||
namespace {
|
||||
|
||||
std::vector<mjtNum> AsVector(const mjtNum* array, int n) {
|
||||
return std::vector<mjtNum>(array, array + n);
|
||||
}
|
||||
|
||||
using ::std::string;
|
||||
using ::testing::AllOf;
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::Eq;
|
||||
using ::testing::FloatEq;
|
||||
using ::testing::HasSubstr;
|
||||
@@ -834,8 +839,43 @@ TEST_F(XMLReaderTest, IncludeAbsoluteTest) {
|
||||
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
// ------------------------ test frame parsing ---------------------------------
|
||||
|
||||
TEST_F(XMLReaderTest, ParsePolycoef) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<worldbody>
|
||||
<body>
|
||||
<joint name="0"/>
|
||||
<geom size="1"/>
|
||||
</body>
|
||||
<body>
|
||||
<joint name="1"/>
|
||||
<geom size="1"/>
|
||||
</body>
|
||||
</worldbody>
|
||||
<equality>
|
||||
<joint joint1="0" joint2="1"/>
|
||||
<joint joint1="0" joint2="1" polycoef="2"/>
|
||||
<joint joint1="0" joint2="1" polycoef="3 4"/>
|
||||
<joint joint1="0" joint2="1" polycoef="5 6 7 8 9"/>
|
||||
</equality>
|
||||
</mujoco>
|
||||
)";
|
||||
std::array<char, 1024> error;
|
||||
mjModel* m = LoadModelFromString(xml, error.data(), error.size());
|
||||
EXPECT_THAT(m, NotNull()) << error.data();
|
||||
EXPECT_THAT(AsVector(m->eq_data + 0*mjNEQDATA, 5),
|
||||
ElementsAre(0, 1, 0, 0, 0));
|
||||
EXPECT_THAT(AsVector(m->eq_data + 1*mjNEQDATA, 5),
|
||||
ElementsAre(2, 1, 0, 0, 0));
|
||||
EXPECT_THAT(AsVector(m->eq_data + 2*mjNEQDATA, 5),
|
||||
ElementsAre(3, 4, 0, 0, 0));
|
||||
EXPECT_THAT(AsVector(m->eq_data + 3*mjNEQDATA, 5),
|
||||
ElementsAre(5, 6, 7, 8, 9));
|
||||
mj_deleteModel(m);
|
||||
}
|
||||
|
||||
// ------------------------ test frame parsing ---------------------------------
|
||||
TEST_F(XMLReaderTest, ParseFrame) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
|
||||
Reference in New Issue
Block a user