Skip to content

Commit 38b52d4

Browse files
Add python bindings to new methods and corresponding tests
Signed-off-by: Gabriel Pacheco <[email protected]>
1 parent 40c0324 commit 38b52d4

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

python/src/gz/sim/Link.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ void defineSimLink(py::object module)
191191
"Add a wrench expressed in world coordinates and applied to "
192192
"the link at an offset from the link's origin. This wrench is applied "
193193
"for one simulation step.")
194+
.def("axis_aligned_box",
195+
py::overload_cast<const EntityComponentManager &>
196+
(&gz::sim::Link::AxisAlignedBox, py::const_),
197+
py::arg("ecm"),
198+
"Get the Link's axis-aligned box represented in the link frame.")
199+
.def("world_axis_aligned_box",
200+
py::overload_cast<const EntityComponentManager &>
201+
(&gz::sim::Link::WorldAxisAlignedBox, py::const_),
202+
py::arg("ecm"),
203+
"Get the Link's axis-aligned box represented in the world frame.")
194204
.def("__copy__",
195205
[](const gz::sim::Link &self)
196206
{

python/test/link_TEST.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from gz_test_deps.common import set_verbosity
2020
from gz_test_deps.sim import K_NULL_ENTITY, TestFixture, Link, Model, World, world_entity
21-
from gz_test_deps.math import Inertiald, Matrix3d, Vector3d, Pose3d
21+
from gz_test_deps.math import AxisAlignedBox, Inertiald, Matrix3d, Vector3d, Pose3d
2222

2323
class TestModel(unittest.TestCase):
2424
post_iterations = 0
@@ -88,6 +88,18 @@ def on_pre_udpate_cb(_info, _ecm):
8888
self.assertEqual(0, link.world_kinetic_energy(_ecm))
8989
link.enable_velocity_checks(_ecm, False)
9090
link.enable_acceleration_checks(_ecm, False)
91+
# Axis Aligned Box Test
92+
# Offset of 0.5 meters along z-axis
93+
self.assertEqual(
94+
AxisAlignedBox(Vector3d(-0.5, -0.5, 0), Vector3d(0.5, 0.5, 1)),
95+
link.axis_aligned_box(_ecm)
96+
)
97+
# World Axis Aligned Box Test
98+
# Same as above since the link is at the origin
99+
self.assertEqual(
100+
AxisAlignedBox(Vector3d(-0.5, -0.5, 0), Vector3d(0.5, 0.5, 1)),
101+
link.world_axis_aligned_box(_ecm)
102+
)
91103

92104

93105
def on_udpate_cb(_info, _ecm):

0 commit comments

Comments
 (0)