Add built-in supertoroid mesh.
PiperOrigin-RevId: 791180080 Change-Id: I3a70f50ff4a52a1bd4b88fc30334a574895145b4
This commit is contained in:
committed by
Copybara-Service
parent
e543ba95c5
commit
a5d4d1000e
@@ -801,7 +801,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([
|
||||
('mjMESH_BUILTIN_SPHERE', 1),
|
||||
('mjMESH_BUILTIN_HEMISPHERE', 2),
|
||||
('mjMESH_BUILTIN_CONE', 3),
|
||||
('mjMESH_BUILTIN_TORUS', 4),
|
||||
('mjMESH_BUILTIN_SUPERTORUS', 4),
|
||||
('mjMESH_BUILTIN_WEDGE', 5),
|
||||
('mjMESH_BUILTIN_PLATE', 6),
|
||||
]),
|
||||
|
||||
@@ -1041,6 +1041,16 @@ PYBIND11_MODULE(_specs, m) {
|
||||
}
|
||||
},
|
||||
py::arg("nedge"), py::arg("radius"));
|
||||
mjsMesh.def(
|
||||
"make_supertorus",
|
||||
[](raw::MjsMesh* self, int resolution, double radius, double s,
|
||||
double t) {
|
||||
double params[4] = {static_cast<double>(resolution), radius, s, t};
|
||||
if (mjs_makeMesh(self, mjMESH_BUILTIN_SUPERTORUS, params, 4)) {
|
||||
throw pybind11::value_error(mjs_getError(mjs_getSpec(self->element)));
|
||||
}
|
||||
},
|
||||
py::arg("resolution"), py::arg("radius"), py::arg("s"), py::arg("t"));
|
||||
mjsMesh.def(
|
||||
"make_plate",
|
||||
[](raw::MjsMesh* self, std::array<int, 2>& resolution) {
|
||||
|
||||
@@ -502,13 +502,17 @@ class SpecsTest(absltest.TestCase):
|
||||
mesh = spec.add_mesh(name='sphere')
|
||||
mesh.make_sphere(subdivision=2)
|
||||
|
||||
mesh = spec.add_mesh(name='supertoroid')
|
||||
mesh.make_supertorus(resolution=10, radius=0.5, s=1, t=1)
|
||||
|
||||
model = spec.compile()
|
||||
self.assertEqual(model.nmesh, 5)
|
||||
self.assertEqual(model.nmesh, 6)
|
||||
self.assertEqual(model.mesh_vertnum[0], 25 * 25)
|
||||
self.assertEqual(model.mesh_vertnum[1], 10)
|
||||
self.assertEqual(model.mesh_vertnum[2], 7)
|
||||
self.assertEqual(model.mesh_vertnum[3], 2 * (4 + 1) * (4 + 2) + 2)
|
||||
self.assertEqual(model.mesh_vertnum[4], 2 + 10 * 4**2)
|
||||
self.assertEqual(model.mesh_vertnum[5], 100)
|
||||
|
||||
def test_compile_errors_with_line_info(self):
|
||||
spec = mujoco.MjSpec()
|
||||
|
||||
Reference in New Issue
Block a user