Skip to content

Commit

Permalink
Add python bindings for new methods
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
scpeters committed Dec 7, 2024
1 parent 3ef40ee commit 43df8ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/src/gz/sim/Link.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ void defineSimLink(py::object module)
py::arg("name"),
"Get the ID of a collision entity which is an immediate child of "
"this link.")
.def("sensor_by_name", &gz::sim::Link::SensorByName,
py::arg("ecm"),
py::arg("name"),
"Get the ID of a sensor entity which is an immediate child of "
"this link.")
.def("visual_by_name", &gz::sim::Link::VisualByName,
py::arg("ecm"),
py::arg("name"),
Expand All @@ -65,13 +70,20 @@ void defineSimLink(py::object module)
.def("collisions", &gz::sim::Link::Collisions,
py::arg("ecm"),
"Get all collisions which are immediate children of this link.")
.def("sensors", &gz::sim::Link::Sensors,
py::arg("ecm"),
"Get all sensors which are immediate children of this link.")
.def("visuals", &gz::sim::Link::Visuals,
py::arg("ecm"),
"Get all visuals which are immediate children of this link.")
.def("collision_count", &gz::sim::Link::CollisionCount,
py::arg("ecm"),
"Get the number of collisions which are immediate children of "
"this link.")
.def("sensor_count", &gz::sim::Link::SensorCount,
py::arg("ecm"),
"Get the number of sensors which are immediate children of this "
"link.")
.def("visual_count", &gz::sim::Link::VisualCount,
py::arg("ecm"),
"Get the number of visuals which are immediate children of this "
Expand Down
3 changes: 3 additions & 0 deletions python/test/link_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def on_pre_udpate_cb(_info, _ecm):
# Collisions Test
self.assertNotEqual(K_NULL_ENTITY, link.collision_by_name(_ecm, 'collision_test'))
self.assertEqual(1, link.collision_count(_ecm))
# Sensors Test
self.assertNotEqual(K_NULL_ENTITY, link.sensor_by_name(_ecm, 'my_sensor'))
self.assertEqual(1, link.sensor_count(_ecm))
# Visuals Test
self.assertNotEqual(K_NULL_ENTITY, link.visual_by_name(_ecm, 'visual_test'))
self.assertEqual(1, link.visual_count(_ecm))
Expand Down

0 comments on commit 43df8ba

Please sign in to comment.