diff --git a/python/src/gz/sim/Link.cc b/python/src/gz/sim/Link.cc index f6c425fcb4..dc286f53a9 100644 --- a/python/src/gz/sim/Link.cc +++ b/python/src/gz/sim/Link.cc @@ -191,6 +191,16 @@ void defineSimLink(py::object module) "Add a wrench expressed in world coordinates and applied to " "the link at an offset from the link's origin. This wrench is applied " "for one simulation step.") + .def("axis_aligned_box", + py::overload_cast + (&gz::sim::Link::AxisAlignedBox, py::const_), + py::arg("ecm"), + "Get the Link's axis-aligned box represented in the link frame.") + .def("world_axis_aligned_box", + py::overload_cast + (&gz::sim::Link::WorldAxisAlignedBox, py::const_), + py::arg("ecm"), + "Get the Link's axis-aligned box represented in the world frame.") .def("__copy__", [](const gz::sim::Link &self) { diff --git a/python/test/link_TEST.py b/python/test/link_TEST.py index d28c48d9e6..cf5858c1e5 100755 --- a/python/test/link_TEST.py +++ b/python/test/link_TEST.py @@ -18,7 +18,7 @@ from gz_test_deps.common import set_verbosity from gz_test_deps.sim import K_NULL_ENTITY, TestFixture, Link, Model, World, world_entity -from gz_test_deps.math import Inertiald, Matrix3d, Vector3d, Pose3d +from gz_test_deps.math import AxisAlignedBox, Inertiald, Matrix3d, Vector3d, Pose3d class TestModel(unittest.TestCase): post_iterations = 0 @@ -88,6 +88,18 @@ def on_pre_udpate_cb(_info, _ecm): self.assertEqual(0, link.world_kinetic_energy(_ecm)) link.enable_velocity_checks(_ecm, False) link.enable_acceleration_checks(_ecm, False) + # Axis Aligned Box Test + # Offset of 0.5 meters along z-axis + self.assertEqual( + AxisAlignedBox(Vector3d(-0.5, -0.5, 0), Vector3d(0.5, 0.5, 1)), + link.axis_aligned_box(_ecm) + ) + # World Axis Aligned Box Test + # Same as above since the link is at the origin + self.assertEqual( + AxisAlignedBox(Vector3d(-0.5, -0.5, 0), Vector3d(0.5, 0.5, 1)), + link.world_axis_aligned_box(_ecm) + ) def on_udpate_cb(_info, _ecm):