Skip to content

Commit c86127f

Browse files
committed
merge s2025 into s2025_perception_merge_Tianyu
2 parents 86cb561 + 711bb3c commit c86127f

206 files changed

Lines changed: 22703 additions & 1857 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/python-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Lint with flake8
3131
run: |
3232
# stop the build if there are Python syntax errors or undefined names
33-
flake8 ./GEMstack --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=__init__.py || exit 1
33+
flake8 ./GEMstack --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics --exclude=__init__.py || exit 1
3434
# to enable more advanced checks on the repo, uncomment the lines below (There are around 3000 violations)
3535
# flake8 ./GEMstack --ignore=D,C901,E402,E231 --count --max-complexity=10 --max-line-length=127 --statistics --exclude=__init__.py || exit 1
3636
# if we want to enable documentation checks, uncomment the line below

.gitignore

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ downloads/
2222
eggs/
2323
.eggs/
2424
lib/
25+
!frontend/*
2526
lib64/
2627
parts/
2728
sdist/
@@ -166,8 +167,11 @@ cython_debug/
166167
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
167168
# and can be added to the global gitignore or merged into this file. For a more nuclear
168169
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
169-
#.idea/
170170

171+
.idea/
172+
173+
# ZED run files
174+
**/*.run
171175
.vscode/
172176
setup/zed_sdk.run
173177

@@ -182,3 +186,14 @@ cuda/
182186
/5.9
183187
/parking_data
184188
/perception_4.9
189+
#Ignore ROS bags
190+
*.bag
191+
192+
cuda/
193+
homework/yolov8n.pt
194+
homework/yolo11n.pt
195+
yolov8n.pt
196+
yolo11n.pt
197+
198+
# Computation Graph of Launch File Outputs
199+
launch_visualization/graph
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#%%
2+
import yaml
3+
from yaml import SafeDumper
4+
import numpy as np
5+
import cv2
6+
def represent_flow_style_list(dumper, data):
7+
return dumper.represent_sequence(yaml.resolver.BaseResolver.DEFAULT_SEQUENCE_TAG, data, flow_style=True)
8+
SafeDumper.add_representer(list, represent_flow_style_list)
9+
#%%
10+
class FlowListDumper(yaml.Dumper):
11+
def represent_list(self, data):
12+
return self.represent_sequence('tag:yaml.org,2002:seq', data, flow_style=True)
13+
14+
def load_ex(path,mode,ref='rear_axle_center'):
15+
with open(path) as stream:
16+
y = yaml.safe_load(stream)
17+
assert y['reference'] == ref
18+
if mode == 'matrix':
19+
ret = np.eye(4)
20+
ret[0:3,0:3] = y['rotation']
21+
ret[:-1,3] = y['position']
22+
return ret
23+
elif mode == 'tuple':
24+
return np.array(y['rotation']),np.array(y['position'])
25+
26+
27+
def save_ex(path,rotation=None,translation=None,matrix=None,ref='rear_axle_center'):
28+
if matrix is not None:
29+
rot = matrix[0:3,0:3]
30+
trans = matrix[0:3,3]
31+
save_ex(path,rot,trans,ref=ref)
32+
return
33+
ret = {}
34+
ret['reference'] = ref
35+
ret['rotation'] = rotation
36+
ret['position'] = translation
37+
for i in ret:
38+
if type(ret[i]) == np.ndarray:
39+
ret[i] = ret[i].tolist()
40+
print(yaml.dump(ret,Dumper=SafeDumper,default_flow_style=False))
41+
with open(path,'w') as stream:
42+
yaml.dump(ret,stream,Dumper=SafeDumper,default_flow_style=False)
43+
44+
def load_in(path,mode='matrix',return_distort=False):
45+
with open(path) as stream:
46+
y = yaml.safe_load(stream)
47+
if 'skew' not in y: y['skew'] = 0
48+
if 'distort' not in y: y['distort'] = [0,0,0,0,0]
49+
if mode == 'matrix':
50+
ret = np.zeros((3,3))
51+
ret[0,0],ret[1,1] = y['focal']
52+
ret[2,2] = 1.
53+
ret[0:2,2] = y['center']
54+
ret[0,1] = y['skew']
55+
if return_distort:
56+
return ret,np.array(y['distort'])
57+
else:
58+
return ret
59+
elif mode == 'tuple':
60+
return {'focal':np.array(y['focal']),
61+
'center':np.array(y['center']),
62+
'skew':np.array(y['skew']),
63+
'distort':np.array(y['distort'])}
64+
65+
from collections.abc import Iterable
66+
def save_in(path,focal=None,center=None,skew=0,distort=[0.0]*5,matrix=None):
67+
if matrix is not None:
68+
focal = matrix.diagonal()[0:2]
69+
skew = matrix[0,1]
70+
center = matrix[0:2,2]
71+
save_in(path,focal,center,skew,distort)
72+
return
73+
ret = {}
74+
ret['focal'] = focal
75+
ret['center'] = center
76+
ret['skew'] = skew
77+
assert len(distort) in [4,5]
78+
ret['distort'] = distort
79+
if len(ret['distort']) == 4:
80+
ret['distort'] = list(ret['distort'])+[0.0]
81+
for i in ret:
82+
if type(ret[i]) == np.ndarray:
83+
ret[i] = ret[i].tolist()
84+
if isinstance(ret[i],Iterable):
85+
ret[i] = [*map(float,ret[i])]
86+
print(yaml.dump(ret,Dumper=SafeDumper,default_flow_style=False))
87+
with open(path,'w') as stream:
88+
yaml.dump(ret,stream,Dumper=SafeDumper,default_flow_style=False)
89+
90+
def undistort_image(image, camera_matrix, distortion_coefficients):
91+
h, w = image.shape[:2]
92+
newK, roi = cv2.getOptimalNewCameraMatrix(camera_matrix, distortion_coefficients, (w,h), 1, (w,h))
93+
image = cv2.undistort(image, camera_matrix, distortion_coefficients, None, newK)
94+
return image, newK
95+
96+
97+
#%%
98+
if __name__ == "__main__":
99+
#%%
100+
rot, trans = load_ex('/mnt/GEMstack/GEMstack/knowledge/calibration/gem_e4_ouster.yaml',mode='tuple')
101+
save_ex('/tmp/test.yaml',rot,trans)
102+
#%%
103+
focal = [1,2,3]
104+
center = [400,500]
105+
save_in('/tmp/test.yaml',focal,center)
106+
load_in('/tmp/test.yaml',mode='tuple')

GEMstack/knowledge/calibration/gem_e4.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,18 @@ rear_axle_height: 0.2794 # height of rear axle center above flat ground
44
gnss_location: [1.10,0,1.62] # meters, taken from https://github.com/hangcui1201/POLARIS_GEM_e2_Real/blob/main/vehicle_drivers/gem_gnss_control/scripts/gem_gnss_tracker_stanley_rtk.py. Note conflict with pure pursuit location?
55
gnss_yaw: 0.0 # radians
66
top_lidar: !include "gem_e4_ouster.yaml"
7-
front_camera: !include "gem_e4_oak.yaml"
7+
front_camera:
8+
extrinsics: !include "gem_e4_oak.yaml"
9+
intrinsics: !include "gem_e4_oak_in.yaml"
10+
front_right_camera:
11+
extrinsics: !include "gem_e4_fr.yaml"
12+
intrinsics: !include "gem_e4_fr_in.yaml"
13+
front_left_camera:
14+
extrinsics: !include "gem_e4_fl.yaml"
15+
intrinsics: !include "gem_e4_fl_in.yaml"
16+
rear_right_camera:
17+
extrinsics: !include "gem_e4_rr.yaml"
18+
intrinsics: !include "gem_e4_rr_in.yaml"
19+
rear_left_camera:
20+
extrinsics: !include "gem_e4_rl.yaml"
21+
intrinsics: !include "gem_e4_rl_in.yaml"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
position: [2.008491967178938, 0.9574436688609637, 1.7222845229507735]
2+
reference: rear_axle_center
3+
rotation: [[0.7229102844527417, -0.13938889438297952, 0.6767358840457229], [-0.6904150547378912,
4+
-0.18396833469067211, 0.6996304053015531], [0.026977264941612008, -0.9729986577348562,
5+
-0.22922879230680995]]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
center: [971.5122150421694, 601.7847095069886]
2+
distort: [-0.2625420437513607, 0.1425651774165483, -0.0004946279626072071, -0.00033457504102070386,
3+
-0.042732740327368145]
4+
focal: [1183.2337731693713, 1182.3831532373445]
5+
skew: 0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
position: [1.8861563355156226, -0.7733611068168774, 1.6793040225335112]
2+
reference: rear_axle_center
3+
rotation: [[-0.7168464770690616, -0.10046018208578958, 0.6899557088168523], [-0.6970911725372957,
4+
0.12308618950445319, -0.7063382243117325], [-0.01396515249660048, -0.9872981017750231,
5+
-0.15826380744561577]]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
center: [966.4326452411585, 608.5803255934914]
2+
distort: [-0.2701363254469883, 0.16439325523243875, -0.001607207824773341, -7.412467081891699e-05,
3+
-0.06199397580030171]
4+
focal: [1176.2554468073797, 1175.1456876174707]
5+
skew: 0
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# Calibration for front rgb camera->vehicle on GEM e4
2-
# Calibration Date: 02/25/2025 05:09
3-
4-
reference: rear_axle_center # rear axle center
5-
rotation: [[ 0.00349517, -0.03239524, 0.99946903], # rotation component of camera -> vehicle matrix
6-
[-0.99996547, 0.00742285, 0.0037375],
7-
[-0.00753999, -0.99944757, -0.03236817]] # rotation matrix mapping z to forward, x to left, y to down, guesstimated
8-
center_position: [ 1.75864913, 0.01238124, 1.54408419] # translation component of camera -> vehicle matrix (in meters)
1+
position: [1.8680678362969751, 0.03483728869549903, 1.6545932338230158]
2+
reference: rear_axle_center
3+
rotation: [[0.020064651878799838, -0.013111205776054045, 0.99971271174677], [-0.9997929081548379,
4+
0.0031358785499412617, 0.020107388418472497], [-0.003398609756043868, -0.9999091271454714,
5+
-0.013045570240818732]]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
center: [573.37109375, 363.700927734375]
2+
focal: [684.8333129882812, 684.6096801757812]

0 commit comments

Comments
 (0)