Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tomas789/4ded7dbad8bbd4585e9746866d9d4b7e to your computer and use it in GitHub Desktop.
Save tomas789/4ded7dbad8bbd4585e9746866d9d4b7e to your computer and use it in GitHub Desktop.
camera-to-IMU synchronization
(env) tomaskrejci @ Tomass-MBP-2.RD ➜ pymsckf git:(replay-from-app) ✗ docker run -v ~/ios_recordings:/data -v ~/Developer/pymsckf/examples:/examples -v `pwd`/calibration_output:/output --security-opt seccomp:unconfined -it -e DISPLAY=docker.for.mac.localhost:0 -w /output pymsckf_calibration kalibr_calibrate_imu_camera --bag /data/ios_recording_100.bag --cam /output/camchain-dataios_recording_96.yaml --imu /examples/imu_vins_mobile.yaml --target /examples/april_6x6_50x50cm.yaml
importing libraries
Initializing IMUs:
Update rate: 100.0
Accelerometer:
Noise density: 0.02
Noise density (discrete): 0.2
Random walk: 0.002
Gyroscope:
Noise density: 0.02
Noise density (discrete): 0.2
Random walk: 4e-05
Initializing imu rosbag dataset reader:
Dataset: /data/ios_recording_100.bag
Topic: /imu0
Number of messages: 3626
Reading IMU data (/imu0)
Read 3626 imu readings over 31.5 seconds
Initializing calibration target:
Type: aprilgrid
Tags:
Rows: 6
Cols: 6
Size: 0.055 [m]
Spacing 0.0165 [m]
Initializing camera chain:
Camera chain - cam0:
Camera model: pinhole
Focal length: [525.103347243366, 525.8822399972671]
Principal point: [325.9919034516905, 229.5969467482677]
Distortion model: radtan
Distortion coefficients: [0.03869682944949094, -0.05888424451155317, 0.0015779459175340209, 0.002600150278649132]
baseline: no data available
Initializing camera rosbag dataset reader:
Dataset: /data/ios_recording_100.bag
Topic: /cam0/image_raw
Number of images: 473
Extracting calibration target corners
Extracted corners for 473 images (of 473 images)
Building the problem
Spline order: 6
Pose knots per second: 70
Do pose motion regularization: False
xddot translation variance: 1000000.000000
xddot rotation variance: 100000.000000
Bias knots per second: 50
Do bias motion regularization: True
Blake-Zisserman on reprojection errors -1
Acceleration Huber width (m/s^2): -1.000000
Gyroscope Huber width (rad/s): -1.000000
Do time calibration: False
Max iterations: 30
Time offset padding: 0.020000
Estimating imu-camera rotation prior
Initializing a pose spline with 3147 knots (100.000000 knots per second over 31.466007 seconds)
Orientation prior camera-imu found as: (T_i_c)
[[ 0.00478666 -0.99985992 0.01603835]
[-0.99997006 -0.00488348 -0.00600333]
[ 0.00608081 -0.01600914 -0.99985335]]
Gyro bias prior found as: (b_gyro)
[ 0.0085264 -0.01496454 0.00502386]
Initializing a pose spline with 3155 knots (100.000000 knots per second over 31.546007 seconds)
Initializing the bias splines with 1577 knots
Adding camera error terms (/cam0/image_raw)
Added 473 camera error terms
Adding accelerometer error terms (/imu0)
Added 3623 of 3626 accelerometer error terms (skipped 3 out-of-bounds measurements)
Adding gyroscope error terms (/imu0)
Added 3623 of 3626 gyroscope error terms (skipped 3 out-of-bounds measurements)
Before Optimization
===================
Reprojection error squarred (cam0): mean 1.40229419135, median 0.731813295584, std: 1.982498787
Gyro error squarred (imu0): mean 0.177241610574, median 0.0865393206717, std: 0.280835206972
Accelerometer error squarred (imu0): mean 5.91563587128, median 3.84005308765, std: 6.56737894204
Transformation T_cam0_imu0 (imu0 to cam0, T_ci): [m]
[[ 0.00478666 -0.99985992 0.01603835 0. ]
[-0.99997006 -0.00488348 -0.00600333 0. ]
[ 0.00608081 -0.01600914 -0.99985335 0. ]
[ 0. 0. 0. 1. ]]
Optimizing...
No linear system solver set in the options. Defaulting to the sparse_cholesky solver
Using the sparse_cholesky linear system solver
Using the levenberg_marquardt trust region policy
No linear system solver set in the options. Defaulting to the sparse_cholesky solver
Using the sparse_cholesky linear system solver
Using the levenberg_marquardt trust region policy
Initializing
Optimization problem initialized with 6327 design variables and 72276 error terms
The Jacobian matrix is 202262 x 28460
[0.0]: J: 108843
[1]: J: 12443.6, dJ: 96399.2, deltaX: 0.0236317, LM - lambda:100 mu:2
[2]: J: 12308.8, dJ: 134.861, deltaX: 0.005358, LM - lambda:33.3333 mu:2
[3]: J: 12062.3, dJ: 246.446, deltaX: 0.014439, LM - lambda:11.1111 mu:2
[4]: J: 11688.7, dJ: 373.607, deltaX: 0.048844, LM - lambda:3.7037 mu:2
[5]: J: 11608.5, dJ: 80.2528, deltaX: 0.0438768, LM - lambda:1.23457 mu:2
[6]: J: 11606.7, dJ: 1.7634, deltaX: 0.102191, LM - lambda:0.7783 mu:2
[7]: J: 11604.4, dJ: 2.30652, deltaX: 0.0538279, LM - lambda:1.06305 mu:2
[8]: J: 11597.8, dJ: 6.6291, deltaX: 0.0617901, LM - lambda:0.97951 mu:2
[9]: J: 11590.6, dJ: 7.15347, deltaX: 0.460714, LM - lambda:0.326503 mu:2
Last step was a regression. Reverting
[10]: J: 11595.2, dJ: -4.57442, deltaX: 1.46224, LM - lambda:0.108834 mu:2
Last step was a regression. Reverting
[11]: J: 11595.3, dJ: -4.69394, deltaX: 0.232809, LM - lambda:0.435338 mu:4
Last step was a regression. Reverting
[12]: J: 11595.5, dJ: -4.87038, deltaX: 0.00404637, LM - lambda:3.4827 mu:8
Last step was a regression. Reverting
[13]: J: 11598.3, dJ: -7.67947, deltaX: 0.000430478, LM - lambda:55.7232 mu:16
Last step was a regression. Reverting
[14]: J: 11598.6, dJ: -7.97151, deltaX: 9.16868e-06, LM - lambda:1783.14 mu:32
After Optimization (Results)
==================
Reprojection error squarred (cam0): mean 0.18079617878, median 0.11007291191, std: 0.214420861571
Gyro error squarred (imu0): mean 0.0107246611337, median 0.00517445335993, std: 0.0176427661335
Accelerometer error squarred (imu0): mean 0.098365085658, median 0.0511897738536, std: 0.127217525559
Transformation T_cam0_imu0 (imu0 to cam0, T_ci): [m]
[[ 0.00551488 -0.99988637 0.01402938 0.09380926]
[-0.99998376 -0.00553452 -0.001361 0.01652489]
[ 0.00143849 -0.01402165 -0.99990066 -0.00680862]
[ 0. 0. 0. 1. ]]
Saving calibration to file: camchain-imucam-dataios_recording_100.yaml
Detailed results written to file: results-imucam-dataios_recording_100.txt
(env) tomaskrejci @ Tomass-MBP-2.RD ➜ pymsckf git:(replay-from-app) ✗ docker run -v ~/ios_recordings:/data -v ~/Developer/pymsckf/examples:/examples -v `pwd`/calibration_output:/output --security-opt seccomp:unconfined -it -e DISPLAY=docker.for.mac.localhost:0 -w /output pymsckf_calibration kalibr_calibrate_imu_camera --bag /data/ios_recording_100.bag --cam /output/camchain-dataios_recording_96.yaml --imu /examples/imu_vins_mobile.yaml --target /examples/april_6x6_50x50cm.yaml --time-calibration
importing libraries
Initializing IMUs:
Update rate: 100.0
Accelerometer:
Noise density: 0.02
Noise density (discrete): 0.2
Random walk: 0.002
Gyroscope:
Noise density: 0.02
Noise density (discrete): 0.2
Random walk: 4e-05
Initializing imu rosbag dataset reader:
Dataset: /data/ios_recording_100.bag
Topic: /imu0
Number of messages: 3626
Reading IMU data (/imu0)
Read 3626 imu readings over 31.5 seconds
Initializing calibration target:
Type: aprilgrid
Tags:
Rows: 6
Cols: 6
Size: 0.055 [m]
Spacing 0.0165 [m]
Initializing camera chain:
Camera chain - cam0:
Camera model: pinhole
Focal length: [525.103347243366, 525.8822399972671]
Principal point: [325.9919034516905, 229.5969467482677]
Distortion model: radtan
Distortion coefficients: [0.03869682944949094, -0.05888424451155317, 0.0015779459175340209, 0.002600150278649132]
baseline: no data available
Initializing camera rosbag dataset reader:
Dataset: /data/ios_recording_100.bag
Topic: /cam0/image_raw
Number of images: 473
Extracting calibration target corners
Extracted corners for 473 images (of 473 images)
Building the problem
Spline order: 6
Pose knots per second: 70
Do pose motion regularization: False
xddot translation variance: 1000000.000000
xddot rotation variance: 100000.000000
Bias knots per second: 50
Do bias motion regularization: True
Blake-Zisserman on reprojection errors -1
Acceleration Huber width (m/s^2): -1.000000
Gyroscope Huber width (rad/s): -1.000000
Do time calibration: True
Max iterations: 30
Time offset padding: 0.020000
Estimating time shift camera to imu:
Initializing a pose spline with 3147 knots (100.000000 knots per second over 31.466007 seconds)
Time shift camera to imu (t_imu = t_cam + shift):
0.0
Estimating imu-camera rotation prior
Initializing a pose spline with 3147 knots (100.000000 knots per second over 31.466007 seconds)
Orientation prior camera-imu found as: (T_i_c)
[[ 0.00478666 -0.99985992 0.01603835]
[-0.99997006 -0.00488348 -0.00600333]
[ 0.00608081 -0.01600914 -0.99985335]]
Gyro bias prior found as: (b_gyro)
[ 0.0085264 -0.01496454 0.00502386]
Initializing a pose spline with 3155 knots (100.000000 knots per second over 31.546007 seconds)
Initializing the bias splines with 1577 knots
Adding camera error terms (/cam0/image_raw)
Added 473 camera error terms
Adding accelerometer error terms (/imu0)
Added 3623 of 3626 accelerometer error terms (skipped 3 out-of-bounds measurements)
Adding gyroscope error terms (/imu0)
Added 3623 of 3626 gyroscope error terms (skipped 3 out-of-bounds measurements)
Before Optimization
===================
Reprojection error squarred (cam0): mean 1.40229419135, median 0.731813295584, std: 1.982498787
Gyro error squarred (imu0): mean 0.177241610574, median 0.0865393206717, std: 0.280835206972
Accelerometer error squarred (imu0): mean 5.91563587128, median 3.84005308765, std: 6.56737894204
Transformation T_cam0_imu0 (imu0 to cam0, T_ci): [m]
[[ 0.00478666 -0.99985992 0.01603835 0. ]
[-0.99997006 -0.00488348 -0.00600333 0. ]
[ 0.00608081 -0.01600914 -0.99985335 0. ]
[ 0. 0. 0. 1. ]]
cam0 to imu0 time: [s] (t_imu = t_cam + shift)
0.0
Optimizing...
No linear system solver set in the options. Defaulting to the sparse_cholesky solver
Using the sparse_cholesky linear system solver
Using the levenberg_marquardt trust region policy
No linear system solver set in the options. Defaulting to the sparse_cholesky solver
Using the sparse_cholesky linear system solver
Using the levenberg_marquardt trust region policy
Initializing
Optimization problem initialized with 6328 design variables and 72276 error terms
The Jacobian matrix is 202262 x 28461
[0.0]: J: 108843
[1]: J: 12456.3, dJ: 96386.6, deltaX: 0.0236342, LM - lambda:100 mu:2
[2]: J: 12308.6, dJ: 147.633, deltaX: 0.00526462, LM - lambda:33.3333 mu:2
[3]: J: 12062.4, dJ: 246.206, deltaX: 0.014439, LM - lambda:11.1111 mu:2
[4]: J: 11688.8, dJ: 373.649, deltaX: 0.0488096, LM - lambda:3.7037 mu:2
[5]: J: 11608.4, dJ: 80.3536, deltaX: 0.0438851, LM - lambda:1.23457 mu:2
[6]: J: 11606.6, dJ: 1.78475, deltaX: 0.105478, LM - lambda:0.778376 mu:2
[7]: J: 11604.4, dJ: 2.27815, deltaX: 0.05548, LM - lambda:1.0598 mu:2
[8]: J: 11597.7, dJ: 6.63158, deltaX: 0.062813, LM - lambda:0.985434 mu:2
[9]: J: 11590.6, dJ: 7.17285, deltaX: 0.461479, LM - lambda:0.328478 mu:2
Last step was a regression. Reverting
[10]: J: 11595.1, dJ: -4.58297, deltaX: 1.42992, LM - lambda:0.109493 mu:2
Last step was a regression. Reverting
[11]: J: 11595.3, dJ: -4.69904, deltaX: 0.23254, LM - lambda:0.437971 mu:4
Last step was a regression. Reverting
[12]: J: 11595.4, dJ: -4.87803, deltaX: 0.00405905, LM - lambda:3.50376 mu:8
Last step was a regression. Reverting
[13]: J: 11598.2, dJ: -7.69363, deltaX: 0.000424275, LM - lambda:56.0602 mu:16
Last step was a regression. Reverting
[14]: J: 11598.5, dJ: -7.98339, deltaX: 9.04283e-06, LM - lambda:1793.93 mu:32
After Optimization (Results)
==================
Reprojection error squarred (cam0): mean 0.180788155507, median 0.110079492998, std: 0.214393720646
Gyro error squarred (imu0): mean 0.0107302018843, median 0.00516440631268, std: 0.0177036555339
Accelerometer error squarred (imu0): mean 0.0984792973579, median 0.0511877946001, std: 0.12742473509
Transformation T_cam0_imu0 (imu0 to cam0, T_ci): [m]
[[ 0.00554884 -0.99988682 0.01398431 0.09381501]
[-0.99998358 -0.00556832 -0.00135451 0.01656178]
[ 0.00143222 -0.01397656 -0.9999013 -0.00669805]
[ 0. 0. 0. 1. ]]
cam0 to imu0 time: [s] (t_imu = t_cam + shift)
-0.0002119064223
Saving calibration to file: camchain-imucam-dataios_recording_100.yaml
Detailed results written to file: results-imucam-dataios_recording_100.txt
(env) tomaskrejci @ Tomass-MBP-2.RD ➜ pymsckf git:(replay-from-app) ✗ docker run -v ~/ios_recordings:/data -v ~/Developer/pymsckf/examples:/examples -v `pwd`/calibration_output:/output --security-opt seccomp:unconfined -it -e DISPLAY=docker.for.mac.localhost:0 -w /output pymsckf_calibration kalibr_calibrate_imu_camera --bag /data/ios_recording_100.bag --cam /output/camchain-dataios_recording_96.yaml --imu /examples/imu_vins_mobile.yaml --target /examples/april_6x6_50x50cm.yaml --time-calibration
importing libraries
Initializing IMUs:
Update rate: 100.0
Accelerometer:
Noise density: 0.02
Noise density (discrete): 0.2
Random walk: 0.002
Gyroscope:
Noise density: 0.02
Noise density (discrete): 0.2
Random walk: 4e-05
Initializing imu rosbag dataset reader:
Dataset: /data/ios_recording_100.bag
Topic: /imu0
Number of messages: 3627
Reading IMU data (/imu0)
Read 3627 imu readings over 31.5 seconds
Initializing calibration target:
Type: aprilgrid
Tags:
Rows: 6
Cols: 6
Size: 0.055 [m]
Spacing 0.0165 [m]
Initializing camera chain:
Camera chain - cam0:
Camera model: pinhole
Focal length: [525.103347243366, 525.8822399972671]
Principal point: [325.9919034516905, 229.5969467482677]
Distortion model: radtan
Distortion coefficients: [0.03869682944949094, -0.05888424451155317, 0.0015779459175340209, 0.002600150278649132]
baseline: no data available
Initializing camera rosbag dataset reader:
Dataset: /data/ios_recording_100.bag
Topic: /cam0/image_raw
Number of images: 473
Extracting calibration target corners
Extracted corners for 473 images (of 473 images)
Building the problem
Spline order: 6
Pose knots per second: 70
Do pose motion regularization: False
xddot translation variance: 1000000.000000
xddot rotation variance: 100000.000000
Bias knots per second: 50
Do bias motion regularization: True
Blake-Zisserman on reprojection errors -1
Acceleration Huber width (m/s^2): -1.000000
Gyroscope Huber width (rad/s): -1.000000
Do time calibration: True
Max iterations: 30
Time offset padding: 0.020000
Estimating time shift camera to imu:
Initializing a pose spline with 3147 knots (100.000000 knots per second over 31.466007 seconds)
Time shift camera to imu (t_imu = t_cam + shift):
0.0782664236409
Estimating imu-camera rotation prior
Initializing a pose spline with 3147 knots (100.000000 knots per second over 31.466007 seconds)
Orientation prior camera-imu found as: (T_i_c)
[[ 0.00368206 -0.99989853 0.01376101]
[-0.99997575 -0.00376299 -0.00585931]
[ 0.0059105 -0.0137391 -0.99988815]]
Gyro bias prior found as: (b_gyro)
[ 0.00847488 -0.0147594 0.00513052]
Initializing a pose spline with 3155 knots (100.000000 knots per second over 31.546007 seconds)
Initializing the bias splines with 1577 knots
Adding camera error terms (/cam0/image_raw)
Added 473 camera error terms
Adding accelerometer error terms (/imu0)
Added 3622 of 3627 accelerometer error terms (skipped 5 out-of-bounds measurements)
Adding gyroscope error terms (/imu0)
Added 3622 of 3627 gyroscope error terms (skipped 5 out-of-bounds measurements)
Before Optimization
===================
Reprojection error squarred (cam0): mean 1.40229312987, median 0.731811021134, std: 1.98249700399
Gyro error squarred (imu0): mean 0.17451330715, median 0.0858696319416, std: 0.256668395839
Accelerometer error squarred (imu0): mean 5.94865902507, median 3.92969020673, std: 6.38412400357
Transformation T_cam0_imu0 (imu0 to cam0, T_ci): [m]
[[ 0.00368206 -0.99989853 0.01376101 0. ]
[-0.99997575 -0.00376299 -0.00585931 0. ]
[ 0.0059105 -0.0137391 -0.99988815 0. ]
[ 0. 0. 0. 1. ]]
cam0 to imu0 time: [s] (t_imu = t_cam + shift)
0.0782664236409
Optimizing...
No linear system solver set in the options. Defaulting to the sparse_cholesky solver
Using the sparse_cholesky linear system solver
Using the levenberg_marquardt trust region policy
No linear system solver set in the options. Defaulting to the sparse_cholesky solver
Using the sparse_cholesky linear system solver
Using the levenberg_marquardt trust region policy
Initializing
Optimization problem initialized with 6328 design variables and 72274 error terms
The Jacobian matrix is 202256 x 28461
[0.0]: J: 108946
[1]: J: 12448.6, dJ: 96497.8, deltaX: 0.0246667, LM - lambda:100 mu:2
[2]: J: 12310.7, dJ: 137.934, deltaX: 0.0145349, LM - lambda:33.3333 mu:2
[3]: J: 12064.1, dJ: 246.57, deltaX: 0.0575715, LM - lambda:11.1111 mu:2
[4]: J: 11689.7, dJ: 374.394, deltaX: 0.0820423, LM - lambda:3.7037 mu:2
[5]: J: 11609.6, dJ: 80.1139, deltaX: 0.246237, LM - lambda:1.23457 mu:2
[6]: J: 11606.4, dJ: 3.17898, deltaX: 0.0912885, LM - lambda:0.81507 mu:2
[7]: J: 11604, dJ: 2.42895, deltaX: 0.0167855, LM - lambda:0.932564 mu:2
[8]: J: 11597.6, dJ: 6.4188, deltaX: 0.0170582, LM - lambda:0.80535 mu:2
[9]: J: 11590.5, dJ: 7.07105, deltaX: 0.027376, LM - lambda:0.26845 mu:2
Last step was a regression. Reverting
[10]: J: 11595.4, dJ: -4.89856, deltaX: 0.0338621, LM - lambda:0.0894833 mu:2
Last step was a regression. Reverting
[11]: J: 11595.4, dJ: -4.8979, deltaX: 0.00933416, LM - lambda:0.357933 mu:4
Last step was a regression. Reverting
[12]: J: 11595.5, dJ: -4.98496, deltaX: 0.00333689, LM - lambda:2.86347 mu:8
Last step was a regression. Reverting
[13]: J: 11598, dJ: -7.54644, deltaX: 0.000486456, LM - lambda:45.8155 mu:16
Last step was a regression. Reverting
[14]: J: 11598.5, dJ: -7.99712, deltaX: 1.31065e-05, LM - lambda:1466.1 mu:32
After Optimization (Results)
==================
Reprojection error squarred (cam0): mean 0.180753123972, median 0.110093990392, std: 0.214368852473
Gyro error squarred (imu0): mean 0.0106515979313, median 0.00538856993675, std: 0.0170267127858
Accelerometer error squarred (imu0): mean 0.0991802129636, median 0.0526819700345, std: 0.131019391928
Transformation T_cam0_imu0 (imu0 to cam0, T_ci): [m]
[[ 0.00553923 -0.99988737 0.01394854 0.09390247]
[-0.99998361 -0.00555892 -0.00137389 0.01665995]
[ 0.00145127 -0.0139407 -0.99990177 -0.00684002]
[ 0. 0. 0. 1. ]]
cam0 to imu0 time: [s] (t_imu = t_cam + shift)
0.0779667857562
Saving calibration to file: camchain-imucam-dataios_recording_100.yaml
Detailed results written to file: results-imucam-dataios_recording_100.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment