Add built-in hemisphere mesh.

PiperOrigin-RevId: 791148546
Change-Id: Ic9ff0c9b0f5fa4fd22d5f7f848f150cf74d378ba
This commit is contained in:
Yuval Tassa
2025-08-05 04:15:27 -07:00
committed by Copybara-Service
parent a5a6379f83
commit 5220767457
8 changed files with 179 additions and 2 deletions
+9
View File
@@ -1014,6 +1014,15 @@ PYBIND11_MODULE(_specs, m) {
},
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_hemisphere",
[](raw::MjsMesh* self, int subdivision) {
double params[1] = {static_cast<double>(subdivision)};
if (mjs_makeMesh(self, mjMESH_BUILTIN_HEMISPHERE, params, 1)) {
throw pybind11::value_error(mjs_getError(mjs_getSpec(self->element)));
}
},
py::arg("subdivision"));
mjsMesh.def(
"make_cone",
[](raw::MjsMesh* self, int nedge, double radius) {
+5 -1
View File
@@ -496,11 +496,15 @@ class SpecsTest(absltest.TestCase):
mesh = spec.add_mesh(name='cone')
mesh.make_cone(nedge=6, radius=0)
mesh = spec.add_mesh(name='hemisphere')
mesh.make_hemisphere(subdivision=4)
model = spec.compile()
self.assertEqual(model.nmesh, 3)
self.assertEqual(model.nmesh, 4)
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)
def test_compile_errors_with_line_info(self):
spec = mujoco.MjSpec()