Skip to content

Commit 7b50576

Browse files
committed
include newest changes from perception team
1 parent 71ae7ef commit 7b50576

3 files changed

Lines changed: 44 additions & 51 deletions

File tree

GEMstack/knowledge/calibration/cameras.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ cameras:
1010
- [-0.0094993062, -0.0003122155, -0.999954834, -0.386689354 ]
1111
- [ 0.999534999, 0.0289731321, -0.0095043721, -0.671425124 ]
1212
- [ 0.0, 0.0, 0.0, 1.0 ]
13-
13+
T_l2v:
14+
- [ 0.99939639, 0.02547917, 0.023615, 1.1 ]
15+
- [ -0.02530848, 0.99965156, -0.00749882, 0.03773583 ]
16+
- [ -0.02379784, 0.00689664, 0.999693, 1.95320223 ]
17+
- [ 0.0, 0.0, 0.0, 1.0 ]
18+
1419
front_right:
1520
K:
1621
- [1176.25545, 0.0, 966.432645]
@@ -27,5 +32,3 @@ cameras:
2732
- [-0.02530848, 0.99965156, -0.00749882, 0.03773583]
2833
- [-0.02379784, 0.00689664, 0.999693, 1.95320223]
2934
- [0.0, 0.0, 0.0, 1.0 ]
30-
31-
# add other cameras (back_left, front_right, back_right) similarly...

GEMstack/onboard/perception/cone_detection.py

Lines changed: 36 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from ...state import AllState, VehicleState, ObjectPose, ObjectFrameEnum, ObstacleState, ObstacleMaterialEnum, ObstacleStateEnum
1+
from ...state import AllState, VehicleState, ObjectPose, ObjectFrameEnum, ObstacleState, ObstacleMaterialEnum, \
2+
ObstacleStateEnum
23
from ..interface.gem import GEMInterface
34
from ..component import Component
45
from .perception_utils import *
@@ -29,50 +30,38 @@ class ConeDetector3D(Component):
2930
"""
3031

3132
def __init__(
32-
self,
33-
vehicle_interface: GEMInterface,
34-
camera_name: str,
35-
camera_calib_file: str,
36-
enable_tracking: bool = True,
37-
visualize_2d: bool = False,
38-
use_cyl_roi: bool = False,
39-
T_l2v: list = None,
40-
save_data: bool = True,
41-
orientation: bool = True,
42-
use_start_frame: bool = True,
43-
**kwargs
33+
self,
34+
vehicle_interface: GEMInterface,
35+
camera_name: str,
36+
camera_calib_file: str,
37+
enable_tracking: bool = True,
38+
visualize_2d: bool = False,
39+
use_cyl_roi: bool = False,
40+
save_data: bool = True,
41+
orientation: bool = True,
42+
use_start_frame: bool = True,
43+
**kwargs
4444
):
4545
# Core interfaces and state
46-
self.vehicle_interface = vehicle_interface
47-
self.current_obstacles = {}
48-
self.tracked_obstacles = {}
49-
self.cone_counter = 0
50-
self.latest_image = None
51-
self.latest_lidar = None
52-
self.bridge = CvBridge()
53-
self.start_pose_abs = None
54-
self.start_time = None
46+
self.vehicle_interface = vehicle_interface
47+
self.current_obstacles = {}
48+
self.tracked_obstacles = {}
49+
self.cone_counter = 0
50+
self.latest_image = None
51+
self.latest_lidar = None
52+
self.bridge = CvBridge()
53+
self.start_pose_abs = None
54+
self.start_time = None
5555

5656
# Config flags
57-
self.camera_name = camera_name
57+
self.camera_name = camera_name
5858
self.enable_tracking = enable_tracking
59-
self.visualize_2d = visualize_2d
60-
self.use_cyl_roi = use_cyl_roi
61-
self.save_data = save_data
62-
self.orientation = orientation
59+
self.visualize_2d = visualize_2d
60+
self.use_cyl_roi = use_cyl_roi
61+
self.save_data = save_data
62+
self.orientation = orientation
6363
self.use_start_frame = use_start_frame
6464

65-
# 1) Load lidar→vehicle transform
66-
if T_l2v is not None:
67-
self.T_l2v = np.array(T_l2v)
68-
else:
69-
self.T_l2v = np.array([
70-
[0.99939639, 0.02547917, 0.023615, 1.1],
71-
[-0.02530848, 0.99965156, -0.00749882, 0.03773583],
72-
[-0.02379784, 0.00689664, 0.999693, 1.95320223],
73-
[0.0, 0.0, 0.0, 1.0]
74-
])
75-
7665
# 2) Load camera intrinsics/extrinsics from the supplied YAML
7766
with open(camera_calib_file, 'r') as f:
7867
calib = yaml.safe_load(f)
@@ -84,16 +73,16 @@ def __init__(
8473
# D: [...]
8574
# T_l2c: [[...], ..., [...]]
8675
cam_cfg = calib['cameras'][camera_name]
87-
self.K = np.array(cam_cfg['K'])
88-
self.D = np.array(cam_cfg['D'])
76+
self.K = np.array(cam_cfg['K'])
77+
self.D = np.array(cam_cfg['D'])
8978
self.T_l2c = np.array(cam_cfg['T_l2c'])
9079
self.T_l2v = np.array(cam_cfg['T_l2v'])
9180

9281
# Derived transforms
9382

9483
self.undistort_map1 = None
9584
self.undistort_map2 = None
96-
self.camera_front = (camera_name=='front')
85+
self.camera_front = (camera_name == 'front')
9786

9887
def rate(self) -> float:
9988
return 8
@@ -127,8 +116,8 @@ def initialize(self):
127116
# Initialize the YOLO detector
128117
self.detector = YOLO('GEMstack/knowledge/detection/cone.pt')
129118
self.detector.to('cuda')
130-
self.T_c2l = np.linalg.inv(self.T_l2c)
131-
self.R_c2l = self.T_c2l[:3, :3]
119+
self.T_c2l = np.linalg.inv(self.T_l2c)
120+
self.R_c2l = self.T_c2l[:3, :3]
132121
self.camera_origin_in_lidar = self.T_c2l[:3, 3]
133122

134123
def synchronized_callback(self, image_msg, lidar_msg):
@@ -163,7 +152,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
163152
if self.latest_image is None or self.latest_lidar is None:
164153
return {}
165154
latest_image = self.latest_image.copy()
166-
155+
167156
# Set up current time variables
168157
start = time.time()
169158
current_time = self.vehicle_interface.time()
@@ -180,7 +169,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
180169
# Ensure data/ exists and build timestamp
181170
if self.save_data:
182171
self.save_sensor_data(vehicle=vehicle, latest_image=latest_image)
183-
172+
184173
if self.camera_front == False:
185174
start = time.time()
186175
undistorted_img, current_K = self.undistort_image(latest_image, self.K, self.D)
@@ -509,8 +498,8 @@ def box_to_fake_obstacle(box):
509498
pose = ObjectPose(t=0, x=x + w / 2, y=y + h / 2, z=0, yaw=0, pitch=0, roll=0, frame=ObjectFrameEnum.CURRENT)
510499
dims = (w, h, 0)
511500
return ObstacleState(pose=pose, dimensions=dims, outline=None,
512-
type=ObstacleMaterialEnum.TRAFFIC_CONE, activity=ObstacleStateEnum.STANDING,
513-
velocity=(0, 0, 0), yaw_rate=0)
501+
type=ObstacleMaterialEnum.TRAFFIC_CONE, activity=ObstacleStateEnum.STANDING,
502+
velocity=(0, 0, 0), yaw_rate=0)
514503

515504

516505
if __name__ == '__main__':

GEMstack/state/agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ class AgentEnum(Enum):
1212
PEDESTRIAN = 3
1313
BICYCLIST = 4
1414

15+
1516
class AgentActivityEnum(Enum):
1617
STOPPED = 0 # standing pedestrians, parked cars, etc. No need to predict motion.
1718
MOVING = 1 # standard motion. Predictions will be used here
1819
FAST = 2 # indicates faster than usual motion, e.g., runners.
1920
UNDETERMINED = 3 # unknown activity
20-
STANDING = 4 # standing
21+
2122

2223
@dataclass
2324
@register

0 commit comments

Comments
 (0)