Skip to content

Commit 702c1a7

Browse files
Merge branch 'sensor_fusion_data_processing' into sensor_fusion_tianyu
2 parents baf9bb5 + d393daa commit 702c1a7

6 files changed

Lines changed: 966 additions & 5 deletions

File tree

GEMstack/onboard/perception/cone_detection.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ def __init__(
9797
def rate(self) -> float:
9898
return 8
9999

100+
100101
def state_inputs(self) -> list:
101102
return ['vehicle']
102103

103104
def state_outputs(self) -> list:
104105
return ['agents']
105106

106107
def initialize(self):
108+
107109
# --- Determine the correct RGB topic for this camera ---
108110
rgb_topic_map = {
109111
'front': '/oak/rgb/image_raw',
@@ -176,6 +178,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
176178
self.start_time = current_time
177179
time_elapsed = current_time - self.start_time
178180

181+
179182
# Ensure data/ exists and build timestamp
180183
if self.save_data:
181184
self.save_sensor_data(vehicle=vehicle, latest_image=latest_image)
@@ -222,6 +225,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
222225
cx, cy, w, h = box
223226
combined_boxes.append((cx, cy, w, h, AgentActivityEnum.STANDING))
224227

228+
225229
# Visualize the received images in 2D with their corresponding labels
226230
# It draws rectangles and labels on the images:
227231
if getattr(self, 'visualize_2d', False):
@@ -247,6 +251,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
247251
cv2.FONT_HERSHEY_SIMPLEX, 0.6, color, 2)
248252
cv2.imshow("Detection - Cone 2D", undistorted_img)
249253

254+
250255
start = time.time()
251256
# Transform the lidar points from lidar frame of reference to camera EXTRINSIC frame of reference.
252257
# Then project the pixels onto the lidar points to "paint them" (essentially determine which points are associated with detected objects)
@@ -274,6 +279,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
274279
if roi_pts.shape[0] < 5:
275280
continue
276281

282+
277283
points_3d = roi_pts[:, 2:5]
278284
points_3d = filter_points_within_threshold(points_3d, 40)
279285
points_3d = remove_ground_by_min_range(points_3d, z_range=0.08)
@@ -337,7 +343,8 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
337343
)
338344
if existing_id is not None:
339345
old_state = self.tracked_agents[existing_id]
340-
if vehicle.v < 100:
346+
347+
if vehicle.v < 100: # 0.1?
341348
alpha = 0.1
342349
avg_x = alpha * new_pose.x + (1 - alpha) * old_state.pose.x
343350
avg_y = alpha * new_pose.y + (1 - alpha) * old_state.pose.y
@@ -401,6 +408,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
401408

402409
# If tracking not enabled, return only current frame detections
403410
if not self.enable_tracking:
411+
404412
for agent_id, agent in self.current_agents.items():
405413
p = agent.pose
406414
rospy.loginfo(
@@ -502,7 +510,6 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
502510
rospy.loginfo("Detected a Cone (simulated)")
503511
return res
504512

505-
506513
def box_to_fake_agent(box):
507514
x, y, w, h = box
508515
pose = ObjectPose(t=0, x=x + w / 2, y=y + h / 2, z=0, yaw=0, pitch=0, roll=0, frame=ObjectFrameEnum.CURRENT)
@@ -511,6 +518,7 @@ def box_to_fake_agent(box):
511518
type=AgentEnum.CONE, activity=AgentActivityEnum.MOVING,
512519
velocity=(0, 0, 0), yaw_rate=0)
513520

521+
514522

515523
if __name__ == '__main__':
516-
pass
524+
pass

0 commit comments

Comments
 (0)