Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging changes from the hilti challenge #515

Closed
wants to merge 164 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
10aa568
Changing image name format
ayushbaid May 13, 2022
5ad2ebc
Fixing stack of delayed calls inside two-view-estimator
ayushbaid May 13, 2022
62251ae
Adding script to run hilti
ayushbaid May 13, 2022
282049f
Killing 2view reports
ayushbaid May 13, 2022
0b1935c
Setting higher memory limit to prevent crashes
ayushbaid May 13, 2022
b6e6255
fixing types
ayushbaid May 13, 2022
fab40c0
Using for-loop based run to cache frontend
ayushbaid May 13, 2022
ed95438
cleaning up unused client
ayushbaid May 13, 2022
1b3d369
moving model loading to init to play well with the for loop
ayushbaid May 13, 2022
28ef8d5
Adding subsampling in hilti loader
ayushbaid May 14, 2022
f8c5665
Merge branch 'feature/hilti-subsample' into hkust-cluster
ayushbaid May 14, 2022
b4a9e4b
reverting changes to deep model loading
ayushbaid May 14, 2022
26904b1
revert to using dask
ayushbaid May 14, 2022
2c29c3b
enhancing run script
ayushbaid May 14, 2022
8787689
fixing 2-view estimator duplicate function and cleaning up configs
ayushbaid May 14, 2022
0591611
changing params and adding subsampling
ayushbaid May 14, 2022
abeb231
Adding cacher for two-view-estimator plate
ayushbaid May 14, 2022
9fa1f41
using 2-view-estimator cache
ayushbaid May 14, 2022
d0b65aa
Allow using old-style image numbering
dellaert May 14, 2022
a7df688
"fix" config to not do view_graph
dellaert May 14, 2022
44df604
Add more logging and rename run functions
dellaert May 14, 2022
8fde20a
flake issues
dellaert May 14, 2022
867984b
Rename run -> run_ba
dellaert May 14, 2022
4a84c4e
Add more logging
dellaert May 14, 2022
237a39e
Rename more run methods
dellaert May 14, 2022
432d9de
Option to turn off MFAS
dellaert May 14, 2022
f5f5662
Re-center to trajectory mean
dellaert May 13, 2022
d4d3309
Allow centering on trajectory
dellaert May 14, 2022
2736efc
More logging and run renaming
dellaert May 14, 2022
b1c944d
Added more logging
dellaert May 14, 2022
b55d569
Added NaN test case
dellaert May 14, 2022
678ebc0
Fix small comments
dellaert May 14, 2022
b3694e4
Parallelized error compute
dellaert May 14, 2022
f68ef09
Merge pull request #494 from borglab/feature/hkust-clusterFD
ayushbaid May 14, 2022
5abe1c2
Adding all cam2-cam2 pairs
ayushbaid May 14, 2022
1322ba3
Decoupling relative pose priors from edges for visual correspondences
ayushbaid May 14, 2022
2af9a5d
Adding full subsampling in visual correspondences
ayushbaid May 14, 2022
dd5a8ec
no more absolute pose priors
ayushbaid May 14, 2022
120ceb4
removing prior filtering logic and fixin coordinate frame convention
ayushbaid May 14, 2022
74c9b2e
using new coordinate frame convention
ayushbaid May 14, 2022
54587a9
fixes for unit tests
ayushbaid May 14, 2022
2f9ac97
temporarily using fixed prior in shonan
ayushbaid May 14, 2022
f4f2004
fixing noise model construction
ayushbaid May 14, 2022
a84d905
adding tests for TA helper methods
akshay-krishnan May 14, 2022
88adac4
Fixing misc to get hilti to run again
ayushbaid May 14, 2022
7717be9
removing ordering imposition on pairs
ayushbaid May 14, 2022
9c87dc9
Turning off 2-view BA and more bug fixes
ayushbaid May 14, 2022
88fc414
removing buggy rig-ba code
ayushbaid May 14, 2022
3fba293
fixing default value or arg
ayushbaid May 14, 2022
13b5147
Adding backbone to the cameras which we should model
ayushbaid May 14, 2022
0446d80
ensuring backbone is in the filtered output
ayushbaid May 14, 2022
9dc9bdb
update TA test
akshay-krishnan May 15, 2022
7719bbf
fixing cam2-cam2 pose computation for prior
ayushbaid May 15, 2022
dc17651
adding eval script with some fixes
ayushbaid May 15, 2022
2966d83
fixing dataset length detection
ayushbaid May 15, 2022
fc3c3c6
turning on 2-view BA
ayushbaid May 15, 2022
314947a
make image optional in case of no image found
ayushbaid May 15, 2022
ef5d144
removing cache for matcher as we use cache for the full 2-view now
ayushbaid May 15, 2022
95350c8
handle no image found in hilti
ayushbaid May 15, 2022
94540c4
Move model loading to constructor to save time for frontend run
ayushbaid May 15, 2022
e36e09d
add script to run frontend without using dask
ayushbaid May 15, 2022
10e18bb
fixing handling of no keypoints in 2-view estimation
ayushbaid May 15, 2022
82adc20
transform covariance from IMU to camera frame
akshay-krishnan May 15, 2022
961a00f
Merge pull request #496 from borglab/rig-covariance
akshay-krishnan May 15, 2022
3b79b65
setting up script to run frontend
ayushbaid May 15, 2022
65eb1f5
Adding hacky solution to run full sfm with cached frontend
ayushbaid May 15, 2022
bd8e25f
actually adding changes to scene optimizer
ayushbaid May 15, 2022
09f6586
Changing image idx collection to set for feature extraction
ayushbaid May 15, 2022
5c0e03a
removing image graph as DA input as we dont need track viz
ayushbaid May 15, 2022
dff004b
Making full image objects for multiview optimizer optional
ayushbaid May 15, 2022
ef99443
passing on image shape to fix crash
ayushbaid May 15, 2022
ce541dc
fix flake8 for eval_hilti
dellaert May 15, 2022
f4f05fc
reusing image shapes
ayushbaid May 15, 2022
e07090b
Removing dask from the full runner and trying to get BA to work with …
ayushbaid May 15, 2022
9ece446
Merge pull request #497 from borglab/fix/hilti_val_flake
dellaert May 15, 2022
63649e3
add method in loader to filter 1-step relative poses
akshay-krishnan May 15, 2022
475921e
add type hint
akshay-krishnan May 15, 2022
bf21450
cleaning up code
ayushbaid May 15, 2022
963a16c
adding backbone for pose slam initialization
ayushbaid May 15, 2022
3c96e4b
use pose3 initializer
ayushbaid May 15, 2022
58cc361
use flags for model init
ayushbaid May 15, 2022
ba349ed
fixing docstring and removing commented code
ayushbaid May 15, 2022
1d19b71
Merge pull request #495 from borglab/hkust-cluster-sat
ayushbaid May 15, 2022
e2b0a32
Merge branch 'hkust-cluster' into hkust-cluster-sun
ayushbaid May 15, 2022
43d2d4d
remove script to run front-end in favor of new script
ayushbaid May 15, 2022
0c3d9fe
test skeleton
akshay-krishnan May 15, 2022
c2aa50e
simple example passes
akshay-krishnan May 15, 2022
8585f6a
docstring, formatting
akshay-krishnan May 15, 2022
24efdd8
update MVO code to use poseslam
akshay-krishnan May 15, 2022
8f5c3a0
Update init_cameras
akshay-krishnan May 15, 2022
3fdc446
cleaning up horrible dask usage
ayushbaid May 15, 2022
3abf1ac
add metrics, fix reports
akshay-krishnan May 15, 2022
2a6f38b
using a single base path
ayushbaid May 16, 2022
030d469
changing default color to black
ayushbaid May 16, 2022
f844bab
adding support to set base path from environment variable
ayushbaid May 16, 2022
e505787
Merge pull request #501 from borglab/hkust-cluster-sun
ayushbaid May 16, 2022
c6401d2
update bool position, remove default arg
akshay-krishnan May 16, 2022
fa3ca0f
adding backbone for pose slam initialization
ayushbaid May 15, 2022
d3ecca9
test skeleton
akshay-krishnan May 15, 2022
58710e2
simple example passes
akshay-krishnan May 15, 2022
b86fdf6
docstring, formatting
akshay-krishnan May 15, 2022
d707cd9
update MVO code to use poseslam
akshay-krishnan May 15, 2022
32dbf03
Update init_cameras
akshay-krishnan May 15, 2022
186581a
add metrics, fix reports
akshay-krishnan May 15, 2022
c1cceb5
integrating pose slam into the runner
ayushbaid May 16, 2022
7a40e6d
Merge remote-tracking branch 'origin/feature/pose-slam-init' into fea…
ayushbaid May 16, 2022
23a4a75
Merge remote-tracking branch 'origin/feature/pose-slam-init' into fea…
ayushbaid May 16, 2022
e04a2a7
Merge pull request #502 from borglab/feature/pose-slam-init
akshay-krishnan May 16, 2022
32afb4f
Merge pull request #498 from borglab/filter-constraints
akshay-krishnan May 16, 2022
f72e7cc
add method in loader to filter 1-step relative poses
akshay-krishnan May 15, 2022
499e06e
add type hint
akshay-krishnan May 15, 2022
a427f94
Merge branch 'hkust-cluster' into use-poseslam-in-hilti
ayushbaid May 16, 2022
bec86a8
Merge pull request #503 from borglab/use-poseslam-in-hilti
ayushbaid May 16, 2022
3c32f03
loose covariance for filtered priors
akshay-krishnan May 16, 2022
89bbc1b
switching order of saving files
ayushbaid May 16, 2022
55fe731
improvements
dellaert May 16, 2022
be3b5df
Merge branch 'hkust-cluster' into feature/switch
ayushbaid May 16, 2022
3f5eacd
Merge pull request #505 from borglab/feature/switch
ayushbaid May 16, 2022
8a5bd4b
reduce prior to 10m
akshay-krishnan May 16, 2022
db1e6fd
Merge pull request #504 from borglab/fix-outlier-filtering
dellaert May 16, 2022
638b2b5
update stationary constraints
akshay-krishnan May 16, 2022
e56ebb3
update condition, add tests
akshay-krishnan May 16, 2022
762e763
merge, add test
akshay-krishnan May 16, 2022
011cfcd
format, change covariance, log
akshay-krishnan May 16, 2022
4ba6d08
Merge pull request #506 from borglab/stationary-priors
ayushbaid May 16, 2022
ac96832
make gt optional in eval script to use for tum generation
ayushbaid May 16, 2022
1d4aafb
creating full output in memory before persisting
ayushbaid May 16, 2022
9bac609
comparing gtsfm with fastlio
ayushbaid May 16, 2022
08ae56f
Code from notebook works
dellaert May 16, 2022
75b96fd
Check in exp07 test
dellaert May 16, 2022
9e1c6b2
Refactor
dellaert May 16, 2022
2cf16ab
Now creating relative_pose_priors
dellaert May 16, 2022
74b6703
Use Pose3 not vectors
dellaert May 16, 2022
1e314ad
No need to check error anymore
dellaert May 16, 2022
e932ba6
get_relative_transform
dellaert May 16, 2022
e9e5afe
Moved code to class
dellaert May 16, 2022
fa1747c
Check Pose3Initialize
dellaert May 16, 2022
316178b
Split function
dellaert May 16, 2022
5a5b932
Add constraints in loader
dellaert May 16, 2022
a1860ea
More checking
dellaert May 16, 2022
ed45ba0
Adding backbone to relative pose priors
ayushbaid May 17, 2022
5429c83
Switch R, T order in covariance
akshay-krishnan May 17, 2022
c6ce5e3
Don't save metrics unless asked
dellaert May 17, 2022
5be29c3
Don't save metrics if None passed
dellaert May 17, 2022
2f9a08b
More optimizations for fast running
dellaert May 17, 2022
5742762
eval now saves with correct filename
dellaert May 17, 2022
2dc9440
Add missing arguments in runners, switched to Dict for delayed_io
dellaert May 17, 2022
d53c3df
just pass the loader
dellaert May 17, 2022
69d183b
Fix regression tests after fixing covariances
dellaert May 19, 2022
febc69a
Moved *all* Constraint handling to HiltiLoader, as Constraint should …
dellaert May 21, 2022
f149580
Merge pull request #508 from borglab/feature/filtering
dellaert May 22, 2022
cfc6b92
Merge pull request #509 from borglab/fix/dask_issues
dellaert May 22, 2022
6bb652a
Merge branch 'master' into hkust-cluster
ayushbaid Jun 5, 2022
d174ad8
fixing naming convention, tests, and flake8 errors
ayushbaid Jun 7, 2022
c35ab71
addressing review comments
ayushbaid Jun 12, 2022
f02fd9f
adding back code to align visualizations
ayushbaid Jun 12, 2022
df2b398
addressing comments
ayushbaid Jul 11, 2022
1b7ea0d
removing old attribute
ayushbaid Jul 12, 2022
8af8da7
removing hilti trajectory eval script
ayushbaid Jul 13, 2022
9cfdb92
fixing astronet runner
ayushbaid Jul 13, 2022
39c384c
Addressing comments
ayushbaid Jul 20, 2022
ece601a
Merge branch 'master' into hkust-cluster
ayushbaid Jul 20, 2022
4468b48
adressing comments
ayushbaid Jul 21, 2022
237047a
Fixing logging
ayushbaid Jul 21, 2022
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
57 changes: 0 additions & 57 deletions gtsfm/averaging/rotation/rig_shonan.py

This file was deleted.

12 changes: 6 additions & 6 deletions gtsfm/averaging/rotation/rotation_averaging_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ class RotationAveragingBase(metaclass=abc.ABCMeta):

# ignored-abstractmethod
@abc.abstractmethod
def run(
def run_rotation_averaging(
self,
num_images: int,
i2Ri1_dict: Dict[Tuple[int, int], Optional[Rot3]],
i2Ti1_priors: Dict[Tuple[int, int], PosePrior],
relative_pose_priors: Dict[Tuple[int, int], PosePrior],
) -> List[Optional[Rot3]]:
"""Run the rotation averaging.

Args:
num_images: number of poses.
i2Ri1_dict: relative rotations as dictionary (i1, i2): i2Ri1.
i2Ti1_priors: priors on relative poses.
relative_pose_priors: priors on relative poses as dictionary(i1, i2): PosePrior on i1Ti2.

Returns:
Global rotations for each camera pose, i.e. wRi, as a list. The number of entries in the list is
Expand Down Expand Up @@ -71,22 +71,22 @@ def create_computation_graph(
self,
num_images: int,
i2Ri1_graph: Delayed,
i2Ti1_priors: Dict[Tuple[int, int], PosePrior],
relative_pose_priors: Dict[Tuple[int, int], PosePrior],
gt_wTi_list: List[Optional[Pose3]],
) -> Tuple[Delayed, Delayed]:
"""Create the computation graph for performing rotation averaging.

Args:
num_images: number of poses.
i2Ri1_graph: dictionary of relative rotations as a delayed task.
i2Ti1_priors: priors on relative poses.
relative_pose_priors: priors on relative poses as (i1, i2): PosePrior on i1Ti2.
gt_wTi_list: ground truth poses, to be used for evaluation.

Returns:
global rotations wrapped using dask.delayed.
"""

wRis = dask.delayed(self.run)(num_images, i2Ri1_graph, i2Ti1_priors)
wRis = dask.delayed(self.run_rotation_averaging)(num_images, i2Ri1_graph, relative_pose_priors)
akshay-krishnan marked this conversation as resolved.
Show resolved Hide resolved
metrics = dask.delayed(self.evaluate)(wRis, gt_wTi_list)

return wRis, metrics
73 changes: 52 additions & 21 deletions gtsfm/averaging/rotation/shonan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Authors: Jing Wu, Ayush Baid, John Lambert
"""
from typing import Dict, List, Optional, Tuple
from typing import Dict, List, Optional, Set, Tuple

import gtsam
import numpy as np
Expand Down Expand Up @@ -71,12 +71,24 @@ def __between_factors_from_2view_relative_rotations(
return between_factors

def _between_factors_from_pose_priors(
self, i2Ti1_priors: Dict[Tuple[int, int], PosePrior], old_to_new_idxs: Dict[int, int]
self, relative_pose_priors: Dict[Tuple[int, int], PosePrior], old_to_new_idxs: Dict[int, int]
) -> BetweenFactorPose3s:
"""Create between factors from the priors on relative poses."""
between_factors = BetweenFactorPose3s()

# TODO(Ayush): use the priors, atleast between disconnected components.
def get_isotropic_noise_model_sigma(covariance: np.ndarray) -> float:
"""Get the sigma to be used for the isotropic noise model.
We compute the average of the diagonal entries of the covariance matrix.
"""
avg_cov = np.average(np.diag(covariance), axis=None)
return np.sqrt(avg_cov)

for (i1, i2), i1Ti2_prior in relative_pose_priors.items():
i1_ = old_to_new_idxs[i1]
i2_ = old_to_new_idxs[i2]
noise_model_sigma = get_isotropic_noise_model_sigma(i1Ti2_prior.covariance)
noise_model = gtsam.noiseModel.Isotropic.Sigma(POSE3_DOF, noise_model_sigma)
between_factors.append(BetweenFactorPose3(i1_, i2_, i1Ti2_prior.value, noise_model))

return between_factors

Expand All @@ -100,58 +112,77 @@ def _run_with_consecutive_ordering(
not be computed (either underconstrained system or ill-constrained system).
"""

obj = ShonanAveraging3(between_factors, self.__get_shonan_params())
logger.info(
"Running Shonan with %d constraints on %d nodes",
len(between_factors),
num_connected_nodes,
)
shonan = ShonanAveraging3(between_factors, self.__get_shonan_params())

initial = obj.initializeRandomly()
result_values, _ = obj.run(initial, self._p_min, self._p_max)
initial = shonan.initializeRandomly()
logger.info("Initial cost: %.5f", shonan.cost(initial))
result, _ = shonan.run(initial, self._p_min, self._p_max)
logger.info("Final cost: %.5f", shonan.cost(result))

wRi_list_consecutive = [None] * num_connected_nodes
for i in range(num_connected_nodes):
if result_values.exists(i):
wRi_list_consecutive[i] = result_values.atRot3(i)
if result.exists(i):
wRi_list_consecutive[i] = result.atRot3(i)
akshay-krishnan marked this conversation as resolved.
Show resolved Hide resolved

num_computed = sum(wRi is not None for wRi in wRi_list_consecutive)
logger.info("Computed %d global rotations", num_computed)
return wRi_list_consecutive

def run(
def _nodes_with_edges(
self, i2Ri1_dict: Dict[Tuple[int, int], Optional[Rot3]], relative_pose_priors: Dict[Tuple[int, int], PosePrior]
) -> Set[int]:
"""Gets the nodes with edges which are to be modelled as between factors."""

unique_nodes_with_edges = set()
for (i1, i2) in i2Ri1_dict.keys():
unique_nodes_with_edges.add(i1)
unique_nodes_with_edges.add(i2)
for (i1, i2) in relative_pose_priors.keys():
unique_nodes_with_edges.add(i1)
unique_nodes_with_edges.add(i2)

return unique_nodes_with_edges

def run_rotation_averaging(
self,
num_images: int,
i2Ri1_dict: Dict[Tuple[int, int], Optional[Rot3]],
i2Ti1_priors: Dict[Tuple[int, int], PosePrior],
relative_pose_priors: Dict[Tuple[int, int], PosePrior],
) -> List[Optional[Rot3]]:
"""Run the rotation averaging on a connected graph with arbitrary keys, where each key is a image/pose index.

Note: run() functions as a wrapper that re-orders keys to prepare a graph w/ N keys ordered [0,...,N-1].
Note: functions as a wrapper that re-orders keys to prepare a graph w/ N keys ordered [0,...,N-1].
All input nodes must belong to a single connected component, in order to obtain an absolute pose for each
camera in a single, global coordinate frame.

Args:
num_images: number of images. Since we have one pose per image, it is also the number of poses.
i2Ri1_dict: relative rotations for each image pair-edge as dictionary (i1, i2): i2Ri1.
i2Ti1_priors: priors on relative poses.
relative_pose_priors: priors on relative poses.

Returns:
Global rotations for each camera pose, i.e. wRi, as a list. The number of entries in the list is
`num_images`. The list may contain `None` where the global rotation could not be computed (either
underconstrained system or ill-constrained system), or where the camera pose had no valid observation
in the input to run().
in the input to run_rotation_averaging().
"""
if len(i2Ri1_dict) == 0:
logger.warning("Shonan cannot proceed: No cycle-consistent triplets found after filtering.")
wRi_list = [None] * num_images
return wRi_list

unique_nodes_with_edges = set()
for (i1, i2) in i2Ri1_dict.keys():
unique_nodes_with_edges.add(i1)
unique_nodes_with_edges.add(i2)

nodes_with_edges = sorted(list(unique_nodes_with_edges))
old_to_new_idxes = {new_idx: i for i, new_idx in enumerate(nodes_with_edges)}
nodes_with_edges = sorted(list(self._nodes_with_edges(i2Ri1_dict, relative_pose_priors)))
old_to_new_idxes = {old_idx: i for i, old_idx in enumerate(nodes_with_edges)}

between_factors: BetweenFactorPose3s = self.__between_factors_from_2view_relative_rotations(
i2Ri1_dict, old_to_new_idxes
)
between_factors.extend(self._between_factors_from_pose_priors(i2Ti1_priors, old_to_new_idxes))
between_factors.extend(self._between_factors_from_pose_priors(relative_pose_priors, old_to_new_idxes))

wRi_list_subset = self._run_with_consecutive_ordering(
num_connected_nodes=len(nodes_with_edges), between_factors=between_factors
Expand Down
Loading