You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-3Lines changed: 30 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1211,9 +1211,34 @@ ros2 run bme_gazebo_sensors_py chase_the_ball
1211
1211
1212
1212
As you can see the `process_image()` function is now just a placeholder and we'll start implementing more features within this function later, but first let's extend the node with better handling of the subscription to the image topic. If `process_image()` will take more time to run it will also block the execution of `rclpy.spin_once(self, timeout_sec=0.05)` that is needed to trigger the `image_callback()`. So let's move the spin functionality to a separate thread:
1213
1213
1214
-
Let's change the `__init__()`function first:
1214
+
Let's change the `__init__()`constructor first:
1215
1215
```python
1216
+
def__init__(self):
1217
+
super().__init__('image_subscriber')
1218
+
1219
+
# Create a subscriber with a queue size of 1 to only keep the last frame
Obviously we don't need `rclpy.spin_once(self, timeout_sec=0.05)` anymore within `display_image()`!
1259
+
Obviously, we don't need `rclpy.spin_once(self, timeout_sec=0.05)` anymore within `display_image()`!
1235
1260
1236
1261
Let's add a `stop()` function, too, to join the therads when we stop the node:
1237
1262
@@ -1258,7 +1283,9 @@ def main(args=None):
1258
1283
rclpy.shutdown()
1259
1284
```
1260
1285
1261
-
Let's rebuild the workspace and try the node! We shouldn't see any difference at this point, but the image callback is triggered by a separate thread now!
1286
+
Let's rebuild the workspace and try the node! We shouldn't see any difference at this point, but the image callback is triggered on a separate thread now!
0 commit comments