Add built-in cone mesh type.
Also delete `prism` type since it is subsumed by cone. PiperOrigin-RevId: 790992343 Change-Id: I7a9c6f2a4377489173acd64b23086c748d2cee8e
This commit is contained in:
committed by
Copybara-Service
parent
4a91c34239
commit
a5a6379f83
@@ -800,11 +800,10 @@ ENUMS: Mapping[str, EnumDecl] = dict([
|
||||
('mjMESH_BUILTIN_NONE', 0),
|
||||
('mjMESH_BUILTIN_SPHERE', 1),
|
||||
('mjMESH_BUILTIN_HEMISPHERE', 2),
|
||||
('mjMESH_BUILTIN_PRISM', 3),
|
||||
('mjMESH_BUILTIN_CONE', 4),
|
||||
('mjMESH_BUILTIN_TORUS', 5),
|
||||
('mjMESH_BUILTIN_WEDGE', 6),
|
||||
('mjMESH_BUILTIN_PLATE', 7),
|
||||
('mjMESH_BUILTIN_CONE', 3),
|
||||
('mjMESH_BUILTIN_TORUS', 4),
|
||||
('mjMESH_BUILTIN_WEDGE', 5),
|
||||
('mjMESH_BUILTIN_PLATE', 6),
|
||||
]),
|
||||
)),
|
||||
('mjtBuiltin',
|
||||
|
||||
+7
-10
@@ -1003,7 +1003,7 @@ PYBIND11_MODULE(_specs, m) {
|
||||
py::return_value_policy::reference_internal);
|
||||
mjsMesh.def(
|
||||
"make_wedge",
|
||||
[](raw::MjsMesh* self, std::array<int, 2>& resolution, double radius,
|
||||
[](raw::MjsMesh* self, std::array<int, 2>& resolution,
|
||||
std::array<double, 2>& fov, double gamma) {
|
||||
double params[5] = {static_cast<double>(resolution[0]),
|
||||
static_cast<double>(resolution[1]), fov[0], fov[1],
|
||||
@@ -1011,21 +1011,18 @@ PYBIND11_MODULE(_specs, m) {
|
||||
if (mjs_makeMesh(self, mjMESH_BUILTIN_WEDGE, params, 5)) {
|
||||
throw pybind11::value_error(mjs_getError(mjs_getSpec(self->element)));
|
||||
}
|
||||
self->scale[0] = radius;
|
||||
self->scale[1] = radius;
|
||||
self->scale[2] = radius;
|
||||
},
|
||||
py::arg("resolution") = std::array<int, 2>{0, 0}, py::arg("radius"),
|
||||
py::arg("resolution") = std::array<int, 2>{0, 0},
|
||||
py::arg("fov") = std::array<double, 2>{0, 0}, py::arg("gamma") = 0);
|
||||
mjsMesh.def(
|
||||
"make_prism",
|
||||
[](raw::MjsMesh* self, int nedge) {
|
||||
double params[1] = {static_cast<double>(nedge)};
|
||||
if (mjs_makeMesh(self, mjMESH_BUILTIN_PRISM, params, 1)) {
|
||||
"make_cone",
|
||||
[](raw::MjsMesh* self, int nedge, double radius) {
|
||||
double params[2] = {static_cast<double>(nedge), radius};
|
||||
if (mjs_makeMesh(self, mjMESH_BUILTIN_CONE, params, 2)) {
|
||||
throw pybind11::value_error(mjs_getError(mjs_getSpec(self->element)));
|
||||
}
|
||||
},
|
||||
py::arg("nedge"));
|
||||
py::arg("nedge"), py::arg("radius"));
|
||||
mjsMesh.def(
|
||||
"make_plate",
|
||||
[](raw::MjsMesh* self, std::array<int, 2>& resolution) {
|
||||
|
||||
@@ -486,12 +486,21 @@ class SpecsTest(absltest.TestCase):
|
||||
|
||||
def test_make_mesh(self):
|
||||
spec = mujoco.MjSpec()
|
||||
|
||||
mesh = spec.add_mesh(name='wedge')
|
||||
mesh.make_wedge(resolution=[25, 25], radius=.1, fov=[90, 45], gamma=0)
|
||||
mesh.make_wedge(resolution=[25, 25], fov=[90, 45], gamma=0)
|
||||
|
||||
mesh = spec.add_mesh(name='prism')
|
||||
mesh.make_cone(nedge=5, radius=1)
|
||||
|
||||
mesh = spec.add_mesh(name='cone')
|
||||
mesh.make_cone(nedge=6, radius=0)
|
||||
|
||||
model = spec.compile()
|
||||
self.assertEqual(model.nmesh, 1)
|
||||
self.assertEqual(model.nmeshvert, 25 * 25)
|
||||
np.testing.assert_array_equal(model.mesh_scale[0], [0.1, 0.1, 0.1])
|
||||
self.assertEqual(model.nmesh, 3)
|
||||
self.assertEqual(model.mesh_vertnum[0], 25 * 25)
|
||||
self.assertEqual(model.mesh_vertnum[1], 10)
|
||||
self.assertEqual(model.mesh_vertnum[2], 7)
|
||||
|
||||
def test_compile_errors_with_line_info(self):
|
||||
spec = mujoco.MjSpec()
|
||||
|
||||
Reference in New Issue
Block a user