Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
266 commits
Select commit Hold shift + click to select a range
4dc8dda
Tabs to spaces
krishauser Dec 24, 2023
396b14c
Got logging to work, multiprocessing works, visualization works
krishauser Dec 31, 2023
5c11d3b
Renamed gem settings to gem_e2
krishauser Dec 31, 2023
cff0b6c
Calibration date added
krishauser Dec 31, 2023
5187c33
Renamed courses to more descriptive names. Changed interface to allow…
krishauser Jan 3, 2024
bb77bdf
Ignoring movie files
krishauser Jan 3, 2024
ee7e244
Moved most logging functions functions to logging.py. Added descripti…
krishauser Jan 4, 2024
5f94f58
Simulator now split into deterministic and threaded parts
krishauser Jan 4, 2024
efded9d
Removed homework assignments section
krishauser Jan 4, 2024
bc71b63
Tentative methods for drawing roadgraph in matplotlib
krishauser Jan 6, 2024
038b2c9
Added some information about installing hardware drivers
krishauser Jan 7, 2024
2ec29e9
Added docker file
krishauser Jan 8, 2024
bc644a2
Merge branch 'main' of https://github.com/krishauser/GEMstack into main
krishauser Jan 8, 2024
f35fc38
Corrected PointCloud2 location
krishauser Jan 8, 2024
be52375
Moved things to setup/ folder. added catkin_ws to gitignore
krishauser Jan 8, 2024
f59b997
Moved things to setup/ folder. added catkin_ws to gitignore
krishauser Jan 8, 2024
bc41209
Merge branch 'main' of github.com:krishauser/GEMstack into main
krishauser Jan 8, 2024
288b033
ignoring catkin_ws
krishauser Jan 8, 2024
9bb689b
Using more recent package
krishauser Jan 8, 2024
b73b49c
Added data gathering mode, info about enabling GEM
krishauser Jan 12, 2024
37518d9
Merge branch 'main' of https://github.com/krishauser/GEMstack
krishauser Jan 12, 2024
3526374
Fixed message location
krishauser Jan 15, 2024
2c983f7
Merge branch 'main' of github.com:krishauser/GEMstack into main
krishauser Jan 15, 2024
528c4d0
Changed ros topics logged by default
krishauser Jan 16, 2024
a19d0ff
Added instructions for setting up a machine with script. Added TODO list
krishauser Jan 16, 2024
7a80d45
Added ROS topics to log
krishauser Jan 16, 2024
6bd7606
Using spawn method to make multiprocessing faster
krishauser Jan 16, 2024
d3fbac5
Checking for vehicle faults
krishauser Jan 16, 2024
ef42a4e
Added GlobalRpt, hardware faults
krishauser Jan 16, 2024
85cfb7e
Added image extraction script
krishauser Jan 16, 2024
e672636
Added log clearing utility
krishauser Jan 16, 2024
51d1fff
Cleaned up Ctrl+C exit on linux while movie is being saved
krishauser Jan 16, 2024
ed6ac2f
Less verbose defaults
krishauser Jan 16, 2024
c39bb79
Fixed loop overrun message
krishauser Jan 16, 2024
9f1386e
start() Pauses for initialization in subprocess
krishauser Jan 16, 2024
cb75fb5
More specific README
krishauser Jan 17, 2024
ad5ee46
Merge branch 'main' of https://github.com/krishauser/GEMstack
krishauser Jan 17, 2024
f4dc00e
Fixed rosbag tools
Jan 17, 2024
b07f2ec
Fixed gather data launch
Jan 17, 2024
1b62daf
Fixed rosbag tools
Jan 17, 2024
988e88f
fixed bugs
Jan 17, 2024
cd8927f
Fixed ROS node execution
krishauser Jan 18, 2024
acfc371
Added light visualization, fixed gear problem
krishauser Jan 18, 2024
dba5f3c
Added hazard lights, used enum properly
krishauser Jan 18, 2024
d2fc851
Added utility to maintain current readings
krishauser Jan 18, 2024
10e7097
minor fixes
krishauser Jan 18, 2024
f061023
Moved launch files to top-level directory
krishauser Jan 18, 2024
8c08913
Moved hardware fault printing / logging into its own function
krishauser Jan 19, 2024
53e39c5
Fixed pure pursuit to be more accurate. Speed filter added to state …
krishauser Jan 24, 2024
e43f379
Added forward drive route
krishauser Jan 24, 2024
245fcbd
Fixed some corner cases in trajectory evaluation. Added trim function
krishauser Jan 24, 2024
7685027
Added frame argument to StaticRoutePlanner
krishauser Jan 24, 2024
9f7f2c6
Added vector_mul function
krishauser Jan 24, 2024
4ac745d
Added sensor callback error checking, zed image topic.
krishauser Jan 24, 2024
cc5a5e8
Fixed exception handling in executor
krishauser Jan 24, 2024
25b3e79
Implementation of IDM. Not tested.
krishauser Jan 24, 2024
e452ebf
Fixed typo with method prototype
krishauser Jan 26, 2024
57ffc1d
A vehicle interface that doesn't drive the vehicle but uses live sens…
krishauser Jan 26, 2024
7486c82
Warning message on invalid sensor
krishauser Jan 26, 2024
ff39432
Added global pose test
krishauser Jan 30, 2024
f050c63
Fixed test fixtures to account for convention in google maps, yaw in …
krishauser Jan 30, 2024
2431c35
Setting radians as expected by ObjectPose
krishauser Jan 30, 2024
0cb3094
Fixed rotation component of GLOBAL frame conversions, added direction…
krishauser Jan 30, 2024
c214700
Added Hang's pedal dynamic model, hardware limits, rate limitations i…
krishauser Jan 30, 2024
c4b6bd9
Added angle wrapping check
krishauser Jan 30, 2024
276dca5
Added new queries
krishauser Jan 31, 2024
e4c7325
Fixed typo in model order
krishauser Jan 31, 2024
ced1d5c
Better naming of sensors, added depth subscribing
Feb 6, 2024
91637b9
Added image /lidar saving and viewing utilities
Feb 6, 2024
ee41538
Can now load calib config file
Feb 6, 2024
b2de34b
Added URDF
krishauser Feb 6, 2024
850132c
Better model name
krishauser Feb 6, 2024
f04dbb6
Added simulator and changed launch to --variant=sim
krishauser Feb 7, 2024
b50a618
Removed print
krishauser Feb 7, 2024
808391b
Added Klampt visualizer
krishauser Feb 7, 2024
f090548
Better error messages
krishauser Feb 7, 2024
754d3b1
More flexible in accepting timed vs untimed trajectories
krishauser Feb 7, 2024
5bfdd76
Utility needed for --variants flag
krishauser Feb 7, 2024
1356b54
Fixed --KEY=VALUE where VALUE is simple
krishauser Feb 7, 2024
0c0c588
Fixed simulator, added brake pedal / accel pedal state
krishauser Feb 7, 2024
9247af9
kris_v1 model now accepts active range
krishauser Feb 7, 2024
f13d6f7
State now has accelerator and brake pedal positions
krishauser Feb 7, 2024
ac10a83
Renamed to Omniscient state estimator. added agent sim
krishauser Feb 7, 2024
56b6517
Noted about sim variants in readme.
krishauser Feb 7, 2024
8903391
Added filter for velocity in visualization
krishauser Feb 7, 2024
3e9fee6
Fixed agent simulation, looks nicer now
krishauser Feb 7, 2024
ceed729
Better warnings with variants
krishauser Feb 7, 2024
81a2981
moved ros logging to variant
krishauser Feb 7, 2024
13899a9
Cleaner cleanup of visualization. Lights look better
krishauser Feb 10, 2024
dc1a46e
Moved format conversions to utils/conversions. Added numpy subscriber…
krishauser Feb 10, 2024
15c75cb
fixed problem with closest point
krishauser Feb 10, 2024
2a7d46d
Fixed trajectory closest point and arc length parameterization
krishauser Feb 11, 2024
cab69a3
Fixed corner cases in pure pursuit
krishauser Feb 11, 2024
e2b09cc
Better debug information for malformed config files
krishauser Feb 11, 2024
6801fce
Fixed some issues with cameras and agent demo
krishauser Feb 11, 2024
7e2ad07
Added reference speed argument
krishauser Feb 11, 2024
eb89d98
Moved zed and lidar configuration to separate files. Tuned PID constants
krishauser Feb 11, 2024
f73a607
Updated args for more demos on how to run the computation graph
krishauser Feb 11, 2024
cbe4bbe
Added debug functionality
krishauser Feb 11, 2024
fd54041
Added reference speed = None for untimed path. Fixed pure pursuit rec…
krishauser Feb 11, 2024
a6874ae
Fixed some typos
krishauser Feb 12, 2024
1bab1b8
Fixed pickle problem :(
krishauser Feb 12, 2024
6113fa9
Fixed typo
Feb 13, 2024
97577c6
Avoid exception if start_pose_abs is None
Feb 13, 2024
fc4b765
Remove annoying print messages and multithreading issues
Feb 13, 2024
d9efda2
Allow setting items to None in config files, showing log folders in L…
Feb 13, 2024
615a95f
More informative delay messages
Feb 13, 2024
a2169bf
Shrunk acceleration deadband, moved to parameter file
krishauser Feb 18, 2024
b7ab3a4
Fixed absolute value in tracking speed scaling, added option to use t…
krishauser Feb 18, 2024
31b246e
Better control limit for steering wheel angle
krishauser Feb 18, 2024
23e0971
Added ability to simulate sensors at different rate, adding noise
krishauser Feb 18, 2024
71ff6ea
Removed errors from simulator
krishauser Feb 18, 2024
27750b5
Smoother simulation with accurate inversion of acceleration_to_pedals
krishauser Feb 18, 2024
647bffe
Made visualization work better with simulator
krishauser Feb 19, 2024
b6578fe
Perception normalizer doesn't mess with frames except for the vehicle…
krishauser Feb 19, 2024
af6d98e
Better error message on invalid variant
krishauser Feb 19, 2024
3f698bb
Fixed bugs identified by sonarqube
krishauser Feb 20, 2024
262591d
Fixed identified bugs
krishauser Feb 21, 2024
d2b3061
Fixed possible bug loading text files
krishauser Feb 21, 2024
5ed5c8d
Added tools for selecting lidar points
krishauser Feb 28, 2024
80b9f97
Added GEM e4 model with hand-calibrated stuff
Mar 6, 2024
c8327ae
Added ability to read from both GEM e2 and e4 sensors
Mar 6, 2024
7d1c737
Added speed to GNSS reading, using it for velocity estimation
krishauser Mar 19, 2024
a5ffdf3
Fixed typos
krishauser Apr 1, 2024
25b4ac4
Changed subscribers to go last in case subscriber callback is called …
krishauser Apr 2, 2024
18bf800
convert coordinate demo
onemapl3 Apr 23, 2024
885ba44
Adds Kalman Tracker class
ABS510 Apr 24, 2024
d9bdc41
Moved config file to knowledge directory
ABS510 Apr 26, 2024
ff1e168
Merge pull request #39 from krishauser/s2024_behavior_track_kalman_fi…
krishauser Apr 29, 2024
52aba58
Top Down Multi class detection and tracking
AprameyH May 1, 2024
91bda35
Add calibration files from State Estimation
AprameyH May 1, 2024
0e2fc98
Merge pull request #49 from krishauser/s2024_behavior_tracking_mc_tra…
krishauser May 1, 2024
83c0022
Revert "S2024 Integrate Kalman Filter with Detection/Tracking"
anan-ya-y May 1, 2024
0ee8810
Revert "Adds Kalman Tracker class"
krishauser May 1, 2024
e6c0f6e
refactor
onemapl3 May 2, 2024
a4b4c14
add unittest
onemapl3 May 2, 2024
a655641
refactor end to end test
onemapl3 May 2, 2024
aca4c59
Merge pull request #54 from krishauser/revert-49-s2024_behavior_track…
krishauser May 2, 2024
bbef1a3
Merge pull request #56 from krishauser/revert-39-s2024_behavior_track…
krishauser May 2, 2024
b78a83c
integrate conversion samples into onboard
onemapl3 May 7, 2024
b5e2c23
Merge pull request #82 from krishauser/s2024_curbside_googlemap
krishauser May 7, 2024
f06178c
Revert "S2024 curbside googlemap"
onemapl3 May 8, 2024
1130525
Merge pull request #86 from krishauser/revert-82-s2024_curbside_googl…
krishauser May 8, 2024
1960c99
Fixed Klampt drawing problem onboard... still mysterious
krishauser Jan 28, 2025
6c94fae
Moved GNSSReading to gem.py to avoid reliance on rospy
krishauser Jan 29, 2025
4c679fe
Merge branch 'main' into s2025
krishauser Jan 29, 2025
a8a897d
Adding github action for linting and documentation
animeshsingh98 Feb 2, 2025
ee9ed62
Adding github action trigger on all commits
animeshsingh98 Feb 2, 2025
b12a0e2
Upgrading version of upload artifact
animeshsingh98 Feb 2, 2025
97577d6
Optimizing the workflow yaml
animeshsingh98 Feb 2, 2025
3374b79
Optimizing the workflow yaml
animeshsingh98 Feb 2, 2025
7faab51
Correcting in the key names
animeshsingh98 Feb 2, 2025
766ac70
Removing requirements.txt installation in documentation
animeshsingh98 Feb 2, 2025
5437cac
Correcting name of build artifact for documentation folder
animeshsingh98 Feb 2, 2025
1eacdb9
Removing action trigger on PR
animeshsingh98 Feb 2, 2025
5290b70
Better docstring
krishauser Feb 3, 2025
9723a93
Merge pull request #100 from krishauser/s2025_linting
krishauser Feb 3, 2025
6ca5300
Fixed to work with Klampt 0.10
krishauser Feb 3, 2025
49a7476
Better docstring
krishauser Feb 3, 2025
4fd94dc
Fixed to work with Klampt 0.10
krishauser Feb 3, 2025
a90e361
Fixed diff that was somehow committed
krishauser Feb 3, 2025
df1ee24
Fixed ROS type typo
krishauser Feb 17, 2025
c1fb33d
Fixed ROS type typo
krishauser Feb 17, 2025
b9ab89b
Typo
krishauser Feb 18, 2025
d5c1ece
Merge branch 'main' into s2025
krishauser Feb 18, 2025
88c65bb
Added items committed to s2024
krishauser Feb 24, 2025
308ba55
Changed time.time to self.time
krishauser Feb 24, 2025
5cdfb6b
Include data capture code
michalj1 Mar 13, 2025
08fa470
Include data capture code
michalj1 Mar 13, 2025
073bf49
Add collection from additional sensors
michalj1 Mar 13, 2025
c67909e
Add collection from additional sensors
michalj1 Mar 13, 2025
e2a689b
Collect GNSS latitude and longitude from septentrio
michalj1 Mar 13, 2025
d8dceb9
Collect GNSS latitude and longitude from septentrio
michalj1 Mar 13, 2025
f1ef086
Attempt to add component to track state in local frame
michalj1 Mar 13, 2025
da59317
Attempt to add component to track state in local frame
michalj1 Mar 13, 2025
1798d5b
calibration scripts
rjsun06 Mar 24, 2025
84105be
calibration scripts
rjsun06 Mar 24, 2025
b041270
Collect all camera intrinsics and write to files
michalj1 Mar 24, 2025
b75d59f
Collect all camera intrinsics and write to files
michalj1 Mar 24, 2025
e88e422
file rename and play with pycolmap
rjsun06 Mar 24, 2025
b269829
file rename and play with pycolmap
rjsun06 Mar 24, 2025
d44c8e0
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
rjsun06 Mar 24, 2025
79fdd6e
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
rjsun06 Mar 24, 2025
2e6b444
typo
rjsun06 Mar 24, 2025
f9cf542
typo
rjsun06 Mar 24, 2025
f242fa7
typo
rjsun06 Mar 24, 2025
09011b0
typo
rjsun06 Mar 24, 2025
65784dc
Versions working on GEM
michalj1 Mar 26, 2025
10a5b92
Versions working on GEM
michalj1 Mar 26, 2025
b4a68ef
ok
rjsun06 Apr 2, 2025
880f08e
ok
rjsun06 Apr 2, 2025
f6e846d
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
rjsun06 Apr 2, 2025
a308ec9
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
rjsun06 Apr 2, 2025
d6b2c02
ok
rjsun06 Apr 3, 2025
69675a9
ok
rjsun06 Apr 3, 2025
5a50c75
Add code to manually tune calibration
michalj1 Apr 7, 2025
a5423d9
Add code to manually tune calibration
michalj1 Apr 7, 2025
a2063eb
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
michalj1 Apr 7, 2025
413f55d
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
michalj1 Apr 7, 2025
1f5c120
Add script to rectify images
michalj1 Apr 7, 2025
4431f7f
Add script to rectify images
michalj1 Apr 7, 2025
3e354a3
cali by segmentation
rjsun06 Apr 7, 2025
2789ce3
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
rjsun06 Apr 7, 2025
974f368
Clean code and allow it to collect scans when not all sensors are wor…
michalj1 Apr 7, 2025
577d49e
Clean code and allow it to collect scans when not all sensors are wor…
michalj1 Apr 7, 2025
7f5876c
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
michalj1 Apr 7, 2025
03f084b
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
michalj1 Apr 7, 2025
ad16ed0
Merge branch 'main' of https://github.com/krishauser/GEMstack into s2…
whizkid42 Apr 7, 2025
19f7521
Add camera intrinsics and minor changes in some calibration scripts
michalj1 Apr 8, 2025
d8c79db
Add camera intrinsics and minor changes in some calibration scripts
michalj1 Apr 8, 2025
9faafd8
Add intrinsics and minor changes in some calibration scripts
michalj1 Apr 8, 2025
b3609fd
Add intrinsics and minor changes in some calibration scripts
michalj1 Apr 8, 2025
a316c63
SfM with hand-eye calibration
rjsun06 Apr 13, 2025
4102339
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
rjsun06 Apr 13, 2025
19aebf6
include distortion and skew in xxx_in.yaml
rjsun06 Apr 13, 2025
8be544d
removed accidentally added large file
rjsun06 Apr 13, 2025
cd28d13
Add script for intrinsic calibration
michalj1 Apr 16, 2025
6ac0eee
Resolve merge conflicts
michalj1 Apr 16, 2025
2951536
Standardize interface for scripts and clean messy code
michalj1 Apr 25, 2025
2f4aba4
readme
rjsun06 Apr 29, 2025
27ce08a
readme-followup
rjsun06 Apr 29, 2025
5813a01
readme
rjsun06 Apr 29, 2025
f62fb8a
readme
rjsun06 Apr 29, 2025
ccef5f6
Merge branches 's2025_EstCal' and 's2025_EstCal' of https://github.co…
rjsun06 Apr 29, 2025
bbfbcc3
Fix bugs and standardize inputs
michalj1 Apr 30, 2025
ca6b137
Corner camera extrinsic calibrations v2.1
michalj1 Apr 30, 2025
5e87e70
Allow variable checkerboard sizes
michalj1 Apr 30, 2025
18ff86e
Update README and fix bugs
michalj1 Apr 30, 2025
78caddc
mapping based localization using lidar scans
rjsun06 Apr 30, 2025
9b23c88
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
rjsun06 Apr 30, 2025
374f10d
cli argument clarified
rjsun06 Apr 30, 2025
66cb580
Move and update utility functions and README
michalj1 Apr 30, 2025
87ea902
Merge README changes
michalj1 Apr 30, 2025
e09e8a2
Rename intrinsic_calibration.py to get_intrinsic_by_chessboard.py
michalj1 Apr 30, 2025
ac2ce48
New oak extrinsics calibration
whizkid42 May 1, 2025
0e061b8
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack…
whizkid42 May 1, 2025
01f2427
Resolve merge conflicts in calibration scripts
whizkid42 May 1, 2025
0699c43
Updated oak extrinsic calibration
whizkid42 May 1, 2025
9812d36
Fix incorrect linear algebra
michalj1 May 5, 2025
b6a67d2
Delete unnecessary files
michalj1 May 5, 2025
9f41ecc
Remove unnecessary files
michalj1 May 5, 2025
e849ebb
Organize calibration file
michalj1 May 5, 2025
fa7bdbf
Update README
michalj1 May 5, 2025
b071e38
Update README
michalj1 May 5, 2025
c46dbe1
Merge remote-tracking branch 'origin/s2025' into s2025_EstCal_Calibra…
michalj1 May 14, 2025
c07d042
Include updated lidar calibration from homework
michalj1 May 14, 2025
2292ef4
Change format to use text keys instead of lists
michalj1 May 14, 2025
7aaa606
Add helper script to create cameras.yaml for perception
michalj1 May 14, 2025
f3517e9
Merge branch 's2025_EstCal_Calibration_PR' of https://github.com/kris…
michalj1 May 14, 2025
991e77e
Remove cameras yaml, allowing other teams to run script as needed
michalj1 May 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions GEMstack/knowledge/calibration/calib_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#%%
import yaml
from yaml import SafeDumper
import numpy as np
import cv2
def represent_flow_style_list(dumper, data):
return dumper.represent_sequence(yaml.resolver.BaseResolver.DEFAULT_SEQUENCE_TAG, data, flow_style=True)
SafeDumper.add_representer(list, represent_flow_style_list)
#%%
class FlowListDumper(yaml.Dumper):
def represent_list(self, data):
return self.represent_sequence('tag:yaml.org,2002:seq', data, flow_style=True)

def load_ex(path,mode,ref='rear_axle_center'):
with open(path) as stream:
y = yaml.safe_load(stream)
assert y['reference'] == ref
if mode == 'matrix':
ret = np.eye(4)
ret[0:3,0:3] = y['rotation']
ret[:-1,3] = y['position']
return ret
elif mode == 'tuple':
return np.array(y['rotation']),np.array(y['position'])


def save_ex(path,rotation=None,translation=None,matrix=None,ref='rear_axle_center'):
if matrix is not None:
rot = matrix[0:3,0:3]
trans = matrix[0:3,3]
save_ex(path,rot,trans,ref=ref)
return
ret = {}
ret['reference'] = ref
ret['rotation'] = rotation
ret['position'] = translation
for i in ret:
if type(ret[i]) == np.ndarray:
ret[i] = ret[i].tolist()
print(yaml.dump(ret,Dumper=SafeDumper,default_flow_style=False))
with open(path,'w') as stream:
yaml.dump(ret,stream,Dumper=SafeDumper,default_flow_style=False)

def load_in(path,mode='matrix',return_distort=False):
with open(path) as stream:
y = yaml.safe_load(stream)
if 'skew' not in y: y['skew'] = 0
if 'distort' not in y: y['distort'] = [0,0,0,0,0]
if mode == 'matrix':
ret = np.zeros((3,3))
ret[0,0],ret[1,1] = y['focal']
ret[2,2] = 1.
ret[0:2,2] = y['center']
ret[0,1] = y['skew']
if return_distort:
return ret,np.array(y['distort'])
else:
return ret
elif mode == 'tuple':
return {'focal':np.array(y['focal']),
'center':np.array(y['center']),
'skew':np.array(y['skew']),
'distort':np.array(y['distort'])}

from collections.abc import Iterable
def save_in(path,focal=None,center=None,skew=0,distort=[0.0]*5,matrix=None):
if matrix is not None:
focal = matrix.diagonal()[0:2]
skew = matrix[0,1]
center = matrix[0:2,2]
save_in(path,focal,center,skew,distort)
return
ret = {}
ret['focal'] = focal
ret['center'] = center
ret['skew'] = skew
assert len(distort) in [4,5]
ret['distort'] = distort
if len(ret['distort']) == 4:
ret['distort'] = list(ret['distort'])+[0.0]
for i in ret:
if type(ret[i]) == np.ndarray:
ret[i] = ret[i].tolist()
if isinstance(ret[i],Iterable):
ret[i] = [*map(float,ret[i])]
print(yaml.dump(ret,Dumper=SafeDumper,default_flow_style=False))
with open(path,'w') as stream:
yaml.dump(ret,stream,Dumper=SafeDumper,default_flow_style=False)

def undistort_image(image, camera_matrix, distortion_coefficients):
h, w = image.shape[:2]
newK, roi = cv2.getOptimalNewCameraMatrix(camera_matrix, distortion_coefficients, (w,h), 1, (w,h))
image = cv2.undistort(image, camera_matrix, distortion_coefficients, None, newK)
return image, newK


#%%
if __name__ == "__main__":
#%%
rot, trans = load_ex('/mnt/GEMstack/GEMstack/knowledge/calibration/gem_e4_ouster.yaml',mode='tuple')
save_ex('/tmp/test.yaml',rot,trans)
#%%
focal = [1,2,3]
center = [400,500]
save_in('/tmp/test.yaml',focal,center)
load_in('/tmp/test.yaml',mode='tuple')
16 changes: 15 additions & 1 deletion GEMstack/knowledge/calibration/gem_e4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@ rear_axle_height: 0.33 # height of rear axle center above flat ground
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?
gnss_yaw: 0.0 # radians
top_lidar: !include "gem_e4_ouster.yaml"
front_camera: !include "gem_e4_oak.yaml"
front_camera:
extrinsics: !include "gem_e4_oak.yaml"
intrinsics: !include "gem_e4_oak_in.yaml"
front_right_camera:
extrinsics: !include "gem_e4_fr.yaml"
intrinsics: !include "gem_e4_fr_in.yaml"
front_left_camera:
extrinsics: !include "gem_e4_fl.yaml"
intrinsics: !include "gem_e4_fl_in.yaml"
rear_right_camera:
extrinsics: !include "gem_e4_rr.yaml"
intrinsics: !include "gem_e4_rr_in.yaml"
rear_left_camera:
extrinsics: !include "gem_e4_rl.yaml"
intrinsics: !include "gem_e4_rl_in.yaml"
5 changes: 5 additions & 0 deletions GEMstack/knowledge/calibration/gem_e4_fl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
position: [2.008491967178938, 0.9574436688609637, 1.7222845229507735]
reference: rear_axle_center
rotation: [[0.7229102844527417, -0.13938889438297952, 0.6767358840457229], [-0.6904150547378912,
-0.18396833469067211, 0.6996304053015531], [0.026977264941612008, -0.9729986577348562,
-0.22922879230680995]]
5 changes: 5 additions & 0 deletions GEMstack/knowledge/calibration/gem_e4_fl_in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
center: [971.5122150421694, 601.7847095069886]
distort: [-0.2625420437513607, 0.1425651774165483, -0.0004946279626072071, -0.00033457504102070386,
-0.042732740327368145]
focal: [1183.2337731693713, 1182.3831532373445]
skew: 0
5 changes: 5 additions & 0 deletions GEMstack/knowledge/calibration/gem_e4_fr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
position: [1.8861563355156226, -0.7733611068168774, 1.6793040225335112]
reference: rear_axle_center
rotation: [[-0.7168464770690616, -0.10046018208578958, 0.6899557088168523], [-0.6970911725372957,
0.12308618950445319, -0.7063382243117325], [-0.01396515249660048, -0.9872981017750231,
-0.15826380744561577]]
5 changes: 5 additions & 0 deletions GEMstack/knowledge/calibration/gem_e4_fr_in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
center: [966.4326452411585, 608.5803255934914]
distort: [-0.2701363254469883, 0.16439325523243875, -0.001607207824773341, -7.412467081891699e-05,
-0.06199397580030171]
focal: [1176.2554468073797, 1175.1456876174707]
skew: 0
8 changes: 5 additions & 3 deletions GEMstack/knowledge/calibration/gem_e4_oak.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
reference: rear_axle_center # rear axle center
rotation: [[0,0,1],[-1,0,0],[0,-1,0]] # rotation matrix mapping z to forward, x to left, y to down, guesstimated
center_position: [1.78,0,1.58] # meters, center camera, guesstimated
position: [1.8680678362969751, 0.03483728869549903, 1.6545932338230158]
reference: rear_axle_center
rotation: [[0.020064651878799838, -0.013111205776054045, 0.99971271174677], [-0.9997929081548379,
0.0031358785499412617, 0.020107388418472497], [-0.003398609756043868, -0.9999091271454714,
-0.013045570240818732]]
2 changes: 2 additions & 0 deletions GEMstack/knowledge/calibration/gem_e4_oak_in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
center: [573.37109375, 363.700927734375]
focal: [684.8333129882812, 684.6096801757812]
6 changes: 4 additions & 2 deletions GEMstack/knowledge/calibration/gem_e4_ouster.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
reference: rear_axle_center # rear axle center
position: [1.10,0,2.03] # meters, calibrated by Hang's watchful eye
rotation: [[1,0,0],[0,1,0],[0,0,1]] #rotation matrix mapping lidar frame to vehicle frame
position: [1.10, 0.03773583, 1.95320223] # meters, calibrated by Hang's watchful eye
rotation: [[0.99939639, 0.02547917, 0.023615],
[-0.02530848, 0.99965156, -0.00749882],
[-0.02379784, 0.00689664, 0.999693]] #rotation matrix mapping lidar frame to vehicle frame
5 changes: 5 additions & 0 deletions GEMstack/knowledge/calibration/gem_e4_rl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
position: [0.0898392124024201, 0.71876803481624, 1.71024199833245]
reference: rear_axle_center
rotation: [[0.6847850928670124, 0.19803293816635642, -0.7013218462220591], [0.728026894383745,
-0.14318896257364072, 0.6704280439025839], [0.03234528777238433, -0.9696802959730001,
-0.2422269719924619]]
5 changes: 5 additions & 0 deletions GEMstack/knowledge/calibration/gem_e4_rl_in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
center: [953.302889408274, 608.1966398872765]
distort: [-0.2522996862206216, 0.12482113115174773, -0.0005993692936397102, -0.00017949453391219192,
-0.03499498178003368]
focal: [1181.6177321982138, 1180.0783789769903]
skew: 0
5 changes: 5 additions & 0 deletions GEMstack/knowledge/calibration/gem_e4_rr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
position: [0.11419591502518789, -0.6896311735924415, 1.711181163333824]
reference: rear_axle_center
rotation: [[-0.7359657309159472, 0.15986191414426415, -0.6578743127098735], [0.6768157805459531,
0.14993386619459964, -0.7207220233709469], [-0.016578363047300385, -0.9756864271752846,
-0.21854325362408236]]
5 changes: 5 additions & 0 deletions GEMstack/knowledge/calibration/gem_e4_rr_in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
center: [956.2663906909728, 569.2039945552984]
distort: [-0.25040910859151444, 0.1109210921906881, -0.00041247665414900384, 0.0008205455176671751,
-0.026395952816984845]
focal: [1162.3787554048329, 1162.855381183851]
skew: 0
48 changes: 48 additions & 0 deletions GEMstack/knowledge/calibration/make_camera_lidar_yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import yaml
import numpy as np
from calib_util import load_ex, load_in

#
# THIS FILE SHOULD BE RUN FROM ITS LOCAL DIRECTORY FOR THE PATHS TO WORK
#

# Destination files name
output_file = 'gem_e4_perception_cameras.yaml'

# Collect names of all sensors and associated extrinsic/intrinsic files
camera_files = {'front': ['gem_e4_oak.yaml', 'gem_e4_oak_in.yaml'],
'front_right': ['gem_e4_fr.yaml', 'gem_e4_oak_in.yaml'],
'front_left': ['gem_e4_fl.yaml', 'gem_e4_fl_in.yaml'],
'back_right': ['gem_e4_rr.yaml', 'gem_e4_rr_in.yaml'],
'back_left': ['gem_e4_rl.yaml', 'gem_e4_rl_in.yaml']}
lidar_file = 'gem_e4_ouster.yaml'

# Initialize variables
output_dict = {'cameras': {}}
T_lidar_to_vehicle = load_ex(lidar_file, 'matrix')

# Collect data for all cameras
for camera in camera_files:
# Load from files
ex_file = camera_files[camera][0]
in_file = camera_files[camera][1]
T_camera_to_vehicle = load_ex(ex_file, 'matrix')
K, D = load_in(in_file, 'matrix', return_distort=True)

# Calculate necessary values
T_lidar_to_camera = np.linalg.inv(T_camera_to_vehicle) @ T_lidar_to_vehicle

# Store in the proper format
camera_dict = {}
camera_dict['K'] = K
camera_dict['D'] = D
camera_dict['T_l2c'] = T_lidar_to_camera
camera_dict['T_l2v'] = T_lidar_to_vehicle
for key in camera_dict:
if type(camera_dict[key]) == np.ndarray:
camera_dict[key] = camera_dict[key].tolist()
output_dict['cameras'][camera] = camera_dict

# Write to file
with open(output_file,'w') as stream:
yaml.safe_dump(output_dict, stream)
2 changes: 2 additions & 0 deletions GEMstack/offboard/calibration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__

Loading