Skip to content

Commit ce4bba3

Browse files
authored
Update cone_detection.py
1 parent 16f1ac4 commit ce4bba3

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

GEMstack/onboard/perception/cone_detection.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ...state import AllState, VehicleState, ObjectPose, ObjectFrameEnum, ObstacleState, ObstacleMaterialEnum, \
1+
from ...state import AllState, VehicleState, ObjectPose, ObjectFrameEnum, Obstacle, ObstacleMaterialEnum, \
22
ObstacleStateEnum
33
from ..interface.gem import GEMInterface
44
from ..component import Component
@@ -146,7 +146,7 @@ def undistort_image(self, image, K, D):
146146
# print('--------undistort', end-start)
147147
return undistorted, newK
148148

149-
def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
149+
def update(self, vehicle: VehicleState) -> Dict[str, Obstacle]:
150150
downsample = False
151151
# Gate guards against data not being present for both sensors:
152152
if self.latest_image is None or self.latest_lidar is None:
@@ -221,18 +221,18 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
221221
# Visualize the received images in 2D with their corresponding labels
222222
# It draws rectangles and labels on the images:
223223
if getattr(self, 'visualize_2d', False):
224-
for (cx, cy, w, h, activity) in combined_boxes:
224+
for (cx, cy, w, h, state) in combined_boxes:
225225
left = int(cx - w / 2)
226226
right = int(cx + w / 2)
227227
top = int(cy - h / 2)
228228
bottom = int(cy + h / 2)
229-
if activity == ObstacleStateEnum.STANDING:
229+
if state == ObstacleStateEnum.STANDING:
230230
color = (255, 0, 0)
231231
label = "STANDING"
232-
elif activity == ObstacleStateEnum.RIGHT:
232+
elif state == ObstacleStateEnum.RIGHT:
233233
color = (0, 255, 0)
234234
label = "RIGHT"
235-
elif activity == ObstacleStateEnum.LEFT:
235+
elif state == ObstacleStateEnum.LEFT:
236236
color = (0, 0, 255)
237237
label = "LEFT"
238238
else:
@@ -259,7 +259,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
259259
obstacles = {}
260260

261261
for i, box_info in enumerate(combined_boxes):
262-
cx, cy, w, h, activity = box_info
262+
cx, cy, w, h, state = box_info
263263
# print(cx, cy, w, h)
264264
left = int(cx - w / 1.6)
265265
right = int(cx + w / 1.6)
@@ -355,12 +355,12 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
355355
roll=avg_roll,
356356
frame=new_pose.frame
357357
)
358-
updated_obstacle = ObstacleState(
358+
updated_obstacle = Obstacle(
359359
pose=updated_pose,
360360
dimensions=dims,
361361
outline=None,
362-
type=ObstacleMaterialEnum.TRAFFIC_CONE,
363-
activity=activity,
362+
material=ObstacleMaterialEnum.TRAFFIC_CONE,
363+
state=state,
364364
)
365365
else:
366366
updated_obstacle = old_state
@@ -369,24 +369,24 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
369369
else:
370370
obstacle_id = f"Cone{self.cone_counter}"
371371
self.cone_counter += 1
372-
new_obstacle = ObstacleState(
372+
new_obstacle = Obstacle(
373373
pose=new_pose,
374374
dimensions=dims,
375375
outline=None,
376-
type=ObstacleMaterialEnum.TRAFFIC_CONE,
377-
activity=activity,
376+
material=ObstacleMaterialEnum.TRAFFIC_CONE,
377+
state=state,
378378
)
379379
obstacles[obstacle_id] = new_obstacle
380380
self.tracked_obstacles[obstacle_id] = new_obstacle
381381
else:
382382
obstacle_id = f"Cone{self.cone_counter}"
383383
self.cone_counter += 1
384-
new_obstacle = ObstacleState(
384+
new_obstacle = Obstacle(
385385
pose=new_pose,
386386
dimensions=dims,
387387
outline=None,
388-
type=ObstacleMaterialEnum.TRAFFIC_CONE,
389-
activity=activity,
388+
material=ObstacleMaterialEnum.TRAFFIC_CONE,
389+
state=state,
390390
)
391391
obstacles[obstacle_id] = new_obstacle
392392

@@ -400,7 +400,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
400400
f"Cone ID: {obstacle_id}\n"
401401
f"Pose: (x: {p.x:.3f}, y: {p.y:.3f}, z: {p.z:.3f}, "
402402
f"yaw: {p.yaw:.3f}, pitch: {p.pitch:.3f}, roll: {p.roll:.3f})\n"
403-
f"type:{obstacle.activity}"
403+
f"state:{obstacle.state}"
404404
)
405405
end = time.time()
406406
# print('-------processing time', end -start)
@@ -418,7 +418,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
418418
f"Cone ID: {obstacle_id}\n"
419419
f"Pose: (x: {p.x:.3f}, y: {p.y:.3f}, z: {p.z:.3f}, "
420420
f"yaw: {p.yaw:.3f}, pitch: {p.pitch:.3f}, roll: {p.roll:.3f})\n"
421-
f"type:{obstacle.activity}"
421+
f"state:{obstacle.state}"
422422
)
423423
end = time.time()
424424
# print('-------processing time', end -start)
@@ -482,7 +482,7 @@ def state_inputs(self):
482482
def state_outputs(self):
483483
return ['obstacles']
484484

485-
def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
485+
def update(self, vehicle: VehicleState) -> Dict[str, Obstacle]:
486486
if self.t_start is None:
487487
self.t_start = self.vehicle_interface.time()
488488
t = self.vehicle_interface.time() - self.t_start
@@ -498,8 +498,8 @@ def box_to_fake_obstacle(box):
498498
x, y, w, h = box
499499
pose = ObjectPose(t=0, x=x + w / 2, y=y + h / 2, z=0, yaw=0, pitch=0, roll=0, frame=ObjectFrameEnum.CURRENT)
500500
dims = (w, h, 0)
501-
return ObstacleState(pose=pose, dimensions=dims, outline=None,
502-
type=ObstacleMaterialEnum.TRAFFIC_CONE, activity=ObstacleStateEnum.STANDING)
501+
return Obstacle(pose=pose, dimensions=dims, outline=None,
502+
material=ObstacleMaterialEnum.TRAFFIC_CONE, state=ObstacleStateEnum.STANDING)
503503

504504

505505
if __name__ == '__main__':

0 commit comments

Comments
 (0)