Skip to content

Commit

Permalink
Add proper image annotations for post sync node
Browse files Browse the repository at this point in the history
  • Loading branch information
Miniapple8888 committed Jun 14, 2024
1 parent c218956 commit f42f5f7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
class CameraSyncNode(Node): # synchronizes visualizations
def __init__(self):
super().__init__('camera_sync_node')
self.get_logger().info("Camera Sync Node")

self.camera_img_sub = Subscriber(self, Image , '/camera/right/image_color')

self.camera1_sub = Subscriber(self, Detection2DArray, '/camera/left/camera_detections')
self.camera2_sub = Subscriber(self, Detection2DArray, '/camera/center/camera_detections')
self.camera3_sub = Subscriber(self, Detection2DArray, '/camera/right/camera_detections')
self.camera1_sub = Subscriber(self, Detection2DArray, '/camera/right/camera_detections')
self.camera2_sub = Subscriber(self, Detection2DArray, '/traffic_signs')
self.camera3_sub = Subscriber(self, Detection2DArray, '/traffic_lights')

self.ts = ApproximateTimeSynchronizer(
[self.camera_img_sub, self.camera1_sub, self.camera2_sub, self.camera3_sub],
Expand All @@ -28,7 +29,7 @@ def __init__(self):
self.ts.registerCallback(self.callback)

self.combined_detection_publisher = self.create_publisher(Detection2DArray, '/combined_detections', 10)
self.vis_publisher = self.create_publisher(Image, '/annotated_img')
self.vis_publisher = self.create_publisher(Image, '/annotated_img', 10)

def process_img(self, image):
try:

Check failure on line 35 in src/perception/camera_object_detection/camera_object_detection/post_synchronizer.py

View workflow job for this annotation

GitHub Actions / Autopep8

src/perception/camera_object_detection/camera_object_detection/post_synchronizer.py#L9-L35

from ultralytics.utils.plotting import Annotator, colors from cv_bridge import CvBridgeError - -class CameraSyncNode(Node): # synchronizes visualizations + + +class CameraSyncNode(Node): # synchronizes visualizations def __init__(self): super().__init__('camera_sync_node') self.get_logger().info("Camera Sync Node") - self.camera_img_sub = Subscriber(self, Image , '/camera/right/image_color') - + self.camera_img_sub = Subscriber(self, Image, '/camera/right/image_color') + self.camera1_sub = Subscriber(self, Detection2DArray, '/camera/right/camera_detections') self.camera2_sub = Subscriber(self, Detection2DArray, '/traffic_signs') self.camera3_sub = Subscriber(self, Detection2DArray, '/traffic_lights') - + self.ts = ApproximateTimeSynchronizer( [self.camera_img_sub, self.camera1_sub, self.camera2_sub, self.camera3_sub], queue_size=10, slop=0.1) - + self.ts.registerCallback(self.callback) - - self.combined_detection_publisher = self.create_publisher(Detection2DArray, '/combined_detections', 10) + + self.combined_detection_publisher = self.create_publisher( + Detection2DArray, '/combined_detections', 10) self.vis_publisher = self.create_publisher(Image, '/annotated_img', 10) def process_img(self, image):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
post_synchronizer_node:
ros__parameters:
camera_topic: /camera/right/image_color
publish_vis_topic: /annotated_img
7 changes: 7 additions & 0 deletions src/perception/camera_object_detection/launch/eve.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ def generate_launch_description():
condition=LaunchConfigurationEquals("launch_traffic_signs", "True"),
)

post_synchronizer_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[camera_object_detection_launch_include_dir, "/post_synchronizer.launch.py"]
)
)

return LaunchDescription(
launch_args
+ [
pretrained_yolov8_launch,
traffic_light_launch,
traffic_signs_launch,
post_synchronizer_launch,
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
import os


def generate_launch_description():
config = os.path.join(
get_package_share_directory('camera_object_detection'),
'config',
'post_synchronizer_config.yaml'
)

camera_object_detection_node = Node(
package='camera_object_detection',
executable='camera_sync_node',
name='post_synchronizer_node',
parameters=[config]
)

return LaunchDescription([camera_object_detection_node])
3 changes: 2 additions & 1 deletion src/perception/camera_object_detection/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
tests_require=['pytest'],
entry_points={
'console_scripts': [
'camera_object_detection_node = camera_object_detection.yolov8_detection:main'
'camera_object_detection_node = camera_object_detection.yolov8_detection:main',
'camera_sync_node = camera_object_detection.post_synchronizer:main'
],
},
)

0 comments on commit f42f5f7

Please sign in to comment.