Skip to content

Commit 9c45098

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

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

python/src/gz/sim/Link.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ 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", &gz::sim::Link::AxisAlignedBox,
195+
py::arg("ecm"),
196+
"Get the Link's axis-aligned box represented in the link frame.")
197+
.def("world_axis_aligned_box", &gz::sim::Link::WorldAxisAlignedBox,
198+
py::arg("ecm"),
199+
"Get the Link's axis-aligned box represented in the world frame.")
194200
.def("__copy__",
195201
[](const gz::sim::Link &self)
196202
{

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)