Skip to content

Commit 2168cff

Browse files
Add python bindings to new public method
Signed-off-by: Gabriel Pacheco <gabriel.fpacheco@gmail.com>
1 parent 0c79183 commit 2168cff

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

python/src/gz/sim/Link.cc

+7
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ void defineSimLink(py::object module)
205205
.def("world_axis_aligned_box", &gz::sim::Link::WorldAxisAlignedBox,
206206
py::arg("ecm"),
207207
"Get the Link's axis-aligned box represented in the world frame.")
208+
.def("compute_axis_aligned_box", &gz::sim::Link::ComputeAxisAlignedBox,
209+
py::arg("ecm"),
210+
"Compute the Link's axis-aligned box represented in the link frame. "
211+
"It generates an axis-aligned bounding box for a link based on the "
212+
"collision shapes attached to the it. The link bounding box is "
213+
"generated by merging all the bounding boxes of the collision "
214+
"geometry shapes attached to the link.")
208215
.def("__copy__",
209216
[](const gz::sim::Link &self)
210217
{

python/test/link_TEST.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,28 @@ 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-
link.enable_bounding_box_checks(_ecm, True)
91+
# Compute Axis Aligned Box Test
9392
# 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.compute_axis_aligned_box(_ecm)
96+
)
97+
# Axis Aligned Box Test with disabled bounding box checks
98+
link.enable_bounding_box_checks(_ecm, False)
99+
self.assertEqual(None, link.axis_aligned_box(_ecm))
100+
self.assertEqual(None, link.world_axis_aligned_box(_ecm))
101+
# Axis Aligned Box Test with enabled bounding box checks
102+
link.enable_bounding_box_checks(_ecm, True)
94103
self.assertEqual(
95104
AxisAlignedBox(Vector3d(-0.5, -0.5, 0), Vector3d(0.5, 0.5, 1)),
96105
link.axis_aligned_box(_ecm)
97106
)
98-
# World Axis Aligned Box Test
99-
# Same as above since the link is at the origin
107+
# Same as above since the link is at the world origin
100108
self.assertEqual(
101109
AxisAlignedBox(Vector3d(-0.5, -0.5, 0), Vector3d(0.5, 0.5, 1)),
102110
link.world_axis_aligned_box(_ecm)
103111
)
104112

105-
106113
def on_udpate_cb(_info, _ecm):
107114
self.iterations += 1
108115

0 commit comments

Comments
 (0)