Skip to content

Commit 8839322

Browse files
committed
added & fixed vision lunch
1 parent e14780b commit 8839322

File tree

6 files changed

+21
-60
lines changed

6 files changed

+21
-60
lines changed

rb_ws/src/buggy/launch/sim_single_vision.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
</node>
1414

1515
<node pkg="buggy" exec="watchdog_node.py" name="SC_watchdog" namespace="SC"/>
16-
<node name="detector" pkg="buggy" exec="detector_node.py" output="screen" namespace="SC"/>
16+
<node pkg="buggy" exec="detector_node.py" name="detector" output="screen" namespace="SC"/>
1717

1818
</launch>
Binary file not shown.

rb_ws/src/buggy/scripts/vision/detector_node.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
#!/usr/bin/env python3
2+
13
import rclpy
24
from rclpy.node import Node
3-
from sensor_msgs import Image
4-
from std_msgs import Int32
5-
from nav_msgs import Odometry
6-
from zed_msgs import Object
5+
from sensor_msgs.msg import Image
6+
from std_msgs.msg import Int32
7+
from nav_msgs.msg import Odometry
8+
# from zed_msgs import Object
79
import pyzed.sl as sl
810
from ultralytics import YOLO
911
import cv2
@@ -24,7 +26,7 @@ def __init__(self):
2426
self.initialize_camera()
2527
self.raw_image = sl.Mat()
2628
self.objects = sl.Objects()
27-
self.model = YOLO("model")
29+
self.model = YOLO("src/buggy/scripts/vision/01-15-25_no_pushbar_yolov11n.pt")
2830

2931
self.runtime_params = sl.RuntimeParameters()
3032
self.object_det_params = sl.ObjectDetectionRuntimeParameters()
@@ -169,15 +171,16 @@ def loop(self):
169171
image_net = self.raw_image.get_data()
170172

171173
# publish raw frame
172-
self.raw_image = cv2.cvtColor(image_net, cv2.COLOR_RGBA2RGB)
173-
raw_frame_publish = self.bridge.cv2_to_imgmsg(image_net, encoding="rgb8")
174+
raw_image_np = cv2.cvtColor(image_net, cv2.COLOR_RGBA2RGB)
175+
# raw_frame_publish = self.bridge.cv2_to_imgmsg(raw_image_np, encoding="rgb8")
174176

175177
# pass frame into YOLO model (get 2D)
176-
detections = self.model.predict(self.raw_image, save=False)
177-
custom_boxes = self.detections_to_custom_box(detections, image_net)
178+
detections = self.model.predict(raw_image_np, save=False)
179+
detection_boxes = detections[0].cpu().numpy().boxes # what is the [0] indexing into, does this pull out the first detection
180+
custom_boxes = self.detections_to_custom_box(detection_boxes, image_net)
178181

179182
# publish annotated frame
180-
annotated_frame_publish = detections[0].plot()
183+
# annotated_frame_publish = self.bridge.cv2_to_imgmsg(detections[0].plot(), encoding="rgb8")
181184

182185
# pass into 2D to 3D to get approximate depth
183186
self.cam.ingest_custom_box_objects(custom_boxes)
@@ -188,19 +191,21 @@ def loop(self):
188191
self.objects.object_list.sort(key=lambda obj: obj.confidence, reverse=True)
189192

190193
num_detections = len(self.objects.object_list)
194+
NAND_pose = None
191195
if num_detections > 0:
192196
utms = self.objects_to_utm()
193197
# NOTE: we're currently defining NAND to just be the first bounding box, we might change how we figure out what NAND is if there are multiple detections
194-
NAND_utm = utms[0]
195198
NAND_pose = Odometry()
199+
NAND_utm = utms[0]
196200
NAND_pose.pose.pose.position.x = NAND_utm[0]
197201
NAND_pose.pose.pose.position.y = NAND_utm[1]
198202
NAND_pose.pose.pose.position.z = NAND_utm[2]
199203

200-
self.raw_camera_frame_publisher.publish(raw_frame_publish)
201-
self.annotated_camera_frame_publisher.publish(annotated_frame_publish)
202-
self.num_detections_publisher.publish(num_detections)
203-
self.observed_NAND_odom_publisher.publish(NAND_pose)
204+
# self.raw_camera_frame_publisher.publish(raw_frame_publish)
205+
# self.annotated_camera_frame_publisher.publish(annotated_frame_publish)
206+
self.num_detections_publisher.publish(Int32(data=num_detections))
207+
if (NAND_pose is not None):
208+
self.observed_NAND_odom_publisher.publish(NAND_pose)
204209

205210

206211
def main(args=None):

rb_ws/src/buggy/vision/README.md

Whitespace-only changes.

rb_ws/src/buggy/vision/test_track.py

Lines changed: 0 additions & 44 deletions
This file was deleted.
-5.35 MB
Binary file not shown.

0 commit comments

Comments
 (0)