Skip to content

Commit 43df8ba

Browse files
committed
Add python bindings for new methods
Signed-off-by: Steve Peters <[email protected]>
1 parent 3ef40ee commit 43df8ba

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

python/src/gz/sim/Link.cc

+12
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ void defineSimLink(py::object module)
5757
py::arg("name"),
5858
"Get the ID of a collision entity which is an immediate child of "
5959
"this link.")
60+
.def("sensor_by_name", &gz::sim::Link::SensorByName,
61+
py::arg("ecm"),
62+
py::arg("name"),
63+
"Get the ID of a sensor entity which is an immediate child of "
64+
"this link.")
6065
.def("visual_by_name", &gz::sim::Link::VisualByName,
6166
py::arg("ecm"),
6267
py::arg("name"),
@@ -65,13 +70,20 @@ void defineSimLink(py::object module)
6570
.def("collisions", &gz::sim::Link::Collisions,
6671
py::arg("ecm"),
6772
"Get all collisions which are immediate children of this link.")
73+
.def("sensors", &gz::sim::Link::Sensors,
74+
py::arg("ecm"),
75+
"Get all sensors which are immediate children of this link.")
6876
.def("visuals", &gz::sim::Link::Visuals,
6977
py::arg("ecm"),
7078
"Get all visuals which are immediate children of this link.")
7179
.def("collision_count", &gz::sim::Link::CollisionCount,
7280
py::arg("ecm"),
7381
"Get the number of collisions which are immediate children of "
7482
"this link.")
83+
.def("sensor_count", &gz::sim::Link::SensorCount,
84+
py::arg("ecm"),
85+
"Get the number of sensors which are immediate children of this "
86+
"link.")
7587
.def("visual_count", &gz::sim::Link::VisualCount,
7688
py::arg("ecm"),
7789
"Get the number of visuals which are immediate children of this "

python/test/link_TEST.py

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def on_pre_udpate_cb(_info, _ecm):
5656
# Collisions Test
5757
self.assertNotEqual(K_NULL_ENTITY, link.collision_by_name(_ecm, 'collision_test'))
5858
self.assertEqual(1, link.collision_count(_ecm))
59+
# Sensors Test
60+
self.assertNotEqual(K_NULL_ENTITY, link.sensor_by_name(_ecm, 'my_sensor'))
61+
self.assertEqual(1, link.sensor_count(_ecm))
5962
# Visuals Test
6063
self.assertNotEqual(K_NULL_ENTITY, link.visual_by_name(_ecm, 'visual_test'))
6164
self.assertEqual(1, link.visual_count(_ecm))

0 commit comments

Comments
 (0)