Skip to content

Commit 6596f84

Browse files
committed
Correct orientation error
1 parent aeff943 commit 6596f84

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

GEMstack/onboard/perception/cone_detection.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def initialize(self):
110110
self.lidar_sub = Subscriber('/ouster/points', PointCloud2)
111111
self.sync = ApproximateTimeSynchronizer([
112112
self.rgb_sub, self.lidar_sub
113-
], queue_size=500, slop=0.05)
113+
], queue_size=500, slop=0.03)
114114
self.sync.registerCallback(self.synchronized_callback)
115115

116116
# Initialize the YOLO detector
@@ -185,6 +185,8 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
185185
undistorted_img = latest_image.copy()
186186
orig_H, orig_W = latest_image.shape[:2]
187187
self.current_K = self.K
188+
# print(self.K)
189+
# print(self.T_l2c)
188190
results_normal = self.detector(img_normal, conf=0.35, classes=[0])
189191
combined_boxes = []
190192
if not self.enable_tracking:
@@ -198,14 +200,18 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
198200
boxes_right = np.array(results_right[0].boxes.xywh.cpu()) if len(results_right) > 0 else []
199201
for box in boxes_left:
200202
cx, cy, w, h = box
201-
new_cx = cy
202-
new_cy = orig_W - 1 - cx
203-
combined_boxes.append((new_cx, new_cy, h, w, ObstacleStateEnum.RIGHT))
203+
new_cx = orig_W - 1 - cy
204+
new_cy = cx
205+
new_w = h # Swap width and height.
206+
new_h = w
207+
combined_boxes.append((new_cx, new_cy, new_w, new_h, ObstacleStateEnum.RIGHT))
204208
for box in boxes_right:
205209
cx, cy, w, h = box
206-
new_cx = orig_H - 1 - cy
207-
new_cy = cx
208-
combined_boxes.append((new_cx, new_cy, h, w, ObstacleStateEnum.LEFT))
210+
new_cx = cy
211+
new_cy = orig_H - 1 - cx
212+
new_w = h # Swap width and height.
213+
new_h = w
214+
combined_boxes.append((new_cx, new_cy, new_w, new_h, ObstacleStateEnum.LEFT))
209215

210216
boxes_normal = np.array(results_normal[0].boxes.xywh.cpu()) if len(results_normal) > 0 else []
211217
for box in boxes_normal:
@@ -254,17 +260,20 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
254260

255261
for i, box_info in enumerate(combined_boxes):
256262
cx, cy, w, h, activity = box_info
263+
# print(cx, cy, w, h)
257264
left = int(cx - w / 1.6)
258265
right = int(cx + w / 1.6)
259266
top = int(cy - h / 2)
260267
bottom = int(cy + h / 2)
261268
mask = (projected_pts[:, 0] >= left) & (projected_pts[:, 0] <= right) & \
262269
(projected_pts[:, 1] >= top) & (projected_pts[:, 1] <= bottom)
263270
roi_pts = projected_pts[mask]
271+
# print(roi_pts)
264272
if roi_pts.shape[0] < 5:
265273
continue
266274

267275
points_3d = roi_pts[:, 2:5]
276+
268277
points_3d = filter_points_within_threshold(points_3d, 40)
269278
points_3d = remove_ground_by_min_range(points_3d, z_range=0.08)
270279
points_3d = filter_depth_points(points_3d, max_depth_diff=0.5)

GEMstack/onboard/perception/pedestrian_detection.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def initialize(self):
9696
self.rgb_sub = Subscriber(rgb_topic, Image)
9797
self.lidar_sub = Subscriber('/ouster/points', PointCloud2)
9898
self.sync = ApproximateTimeSynchronizer(
99-
[self.rgb_sub, self.lidar_sub], queue_size=500, slop=0.05
99+
[self.rgb_sub, self.lidar_sub], queue_size=500, slop=0.025
100100
)
101101
self.sync.registerCallback(self.synchronized_callback)
102102

@@ -163,6 +163,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
163163

164164
agents: Dict[str, AgentState] = {}
165165
for (cx, cy, w, h) in boxes2d:
166+
# print(cx, cy, w, h)
166167
# Define ROI in image for each detection
167168
left = int(cx - w / 2)
168169
right = int(cx + w / 2)
@@ -257,6 +258,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
257258
)
258259
agents[existing] = updated
259260
self.tracked_agents[existing] = updated
261+
260262
else:
261263
aid = f"Pedestrian{self.pedestrian_counter}"
262264
self.pedestrian_counter += 1
@@ -271,6 +273,15 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
271273
)
272274
agents[aid] = new_agent
273275
self.tracked_agents[aid] = new_agent
276+
for agent_id, agent in self.current_agents.items():
277+
p = agent.pose
278+
rospy.loginfo(
279+
f"Agent ID: {agent_id}\n"
280+
f"Pose: (x: {p.x:.3f}, y: {p.y:.3f}, z: {p.z:.3f}, "
281+
f"yaw: {p.yaw:.3f}, pitch: {p.pitch:.3f}, roll: {p.roll:.3f})\n"
282+
f"Velocity: (vx: {agent.velocity[0]:.3f}, vy: {agent.velocity[1]:.3f}, vz: {agent.velocity[2]:.3f})\n"
283+
f"type:{agent.activity}"
284+
)
274285
else:
275286
aid = f"Pedestrian{self.pedestrian_counter}"
276287
self.pedestrian_counter += 1

0 commit comments

Comments
 (0)