2
2
3
3
Theia (https://github.com/sweeneychris/TheiaSfM ) is a package for
4
4
global structure-from-motion (SfM). It may be faster and require less
5
- user effort than the method used in Astrobee which consists of
6
- creating submaps using incremental SfM on sequences of images that
7
- overlap with their immediate neighbors, followed by merging the
8
- submaps. Theia uses "cascade matching" to handle non-sequential image
9
- acquisitions.
5
+ user effort than the method used in Astrobee (see \ref map_building)
6
+ which consists of creating submaps using incremental SfM on sequences
7
+ of images that overlap with their immediate neighbors, followed by
8
+ merging the submaps. Theia uses "cascade matching" to handle
9
+ non-sequential image acquisitions.
10
10
11
11
The Theia approach was tested on about 700 images acquired at
12
12
different times and it did well. It is currently studied as an
13
13
alternative to Astrobee's approach.
14
14
15
15
# Install Theia's prerequisites
16
16
17
+ It is suggested to use `` conda `` to install Theia's dependencies. The
18
+ conda toolset does not require root access and creates a set of
19
+ consistent libraries at a custom location in your home directory,
20
+ which are largely independent of your particular Linux system.
21
+
17
22
Fetch and install `` conda `` from:
18
23
19
24
https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html
@@ -34,7 +39,7 @@ Run the following command to install some packages and GCC 11:
34
39
ceres-solver=1.14.0=h0948850_10
35
40
36
41
The Ceres package can be quite particular about the version of Eigen
37
- it uses, and some versions of Ceres are not built with suitesparse
42
+ it uses, and some versions of Ceres are not built with `` suitesparse `` ,
38
43
which is a sparse solver that is needed for best performance, so some
39
44
care is needed with choosing the versions of the packages.
40
45
@@ -53,42 +58,122 @@ view_reconstruction. That visualizer logic is not easy to compile
53
58
and is not needed.
54
59
55
60
Run `` which cmake `` to ensure its version in the `` theia `` environemnt
56
- installed earlier is used. Otherwise run again ``conda activate
57
- theia``. Do:
61
+ installed earlier is used. Otherwise run again:
62
+
63
+ conda activate theia
64
+
65
+ Do:
58
66
59
67
mkdir build
60
68
cd build
61
69
cmake ..
62
70
make -j 20
63
71
64
72
This will create the executables `` build_reconstruction `` and
65
- `` export_to_nvm_file `` in the `` bin `` subdirectory of `` build `` . That
66
- directory needs to be added to the PATH.
73
+ `` export_to_nvm_file `` in the `` bin `` subdirectory of `` build `` .
67
74
68
- # Run the Astrobee wrapper around the Theia tools
75
+ # Hide the conda environment
69
76
70
77
The conda environment set up earlier will confuse the lookup the
71
- dependencies for the Astrobee libraries. Hence the lines `` conda `` added
72
- to one's `` .bashrc `` should be removed, the bash shell restarted, and
73
- one should ensure that the `` env `` command has no mentions of conda.
78
+ dependencies for the Astrobee libraries. Hence remove the block of
79
+ lines starting and ending with `` conda initialize `` which conda added
80
+ to your ~ /.bashrc, then close and reopen your terminal. Ensure that
81
+ the `` env `` command shows no mention of conda.
74
82
75
- Set the environment. The following lines should be adjusted as needed,
76
- especially the robot name:
83
+ # Set up the environment for Theia and Astrobee
77
84
78
- export ASTROBEE_SOURCE_PATH=$HOME/projects/astrobee/src
79
- source $ASTROBEE_SOURCE_PATH/../devel/setup.bash
85
+ Add the Theia tools to your path as:
86
+
87
+ export PATH=/path/to/TheiaSfM/build/bin:$PATH
88
+
89
+ Set up the environment for Astrobee, including the robot name. These
90
+ should be adjusted as needed:
91
+
92
+ export ASTROBEE_BUILD_PATH=$HOME/astrobee
93
+ export ASTROBEE_SOURCE_PATH=$ASTROBEE_BUILD_PATH/src
94
+ source $ASTROBEE_BUILD_PATH/devel/setup.bash
80
95
export ASTROBEE_RESOURCE_DIR=$ASTROBEE_SOURCE_PATH/astrobee/resources
81
96
export ASTROBEE_CONFIG_DIR=$ASTROBEE_SOURCE_PATH/astrobee/config
82
97
export ASTROBEE_WORLD=iss
83
98
export ASTROBEE_ROBOT=bumble
84
99
100
+ Add some Astrobee tools to the path as well:
101
+
102
+ export PATH=$ASTROBEE_BUILD_PATH/devel/lib/sparse_mapping:$PATH
103
+
104
+ Please note that if the robot name, as specified in
105
+ `` ASTROBEE_ROBOT `` , is incorrect, you will get poor results.
106
+
107
+ # Prepare the data
108
+
109
+ The data preparation is the same as used with the usual Astrobee
110
+ map-building software documented in \ref map_building. To summarize,
111
+ the steps are as follows.
112
+
113
+ Extract the data from the bag:
114
+
115
+ $ASTROBEE_BUILD_PATH/devel/lib/localization_node/extract_image_bag \
116
+ bagfile.bag -use_timestamp_as_image_name \
117
+ -image_topic /hw/cam_nav -output_directory image_dir
118
+
119
+ If the images were recorded with the image sampler, the nav_cam image
120
+ topic needs to be changed to:
121
+
122
+ /mgt/img_sampler/nav_cam/image_record
123
+
124
+ The `` -use_timestamp_as_image_name `` option is not strictly necessary,
125
+ but it is helpful if a lot of datasets needs to be processed
126
+ jointly. With it, the image filename is the timestamp (in
127
+ double-precision seconds since epoch), which provides for a rather
128
+ unique name, as compared to using the image index in the bag without
129
+ that option.
130
+
131
+ Select a subset of the images:
132
+
133
+ select_images -density_factor 1.4 image_dir/*.jpg
134
+
135
+ This will delete a lot of similar images from that directory. This is
136
+ not a foolproof process, and sometimes too many images are deleted but
137
+ most of the time too many are left. It is suggested to open the
138
+ remaining images with `` eog `` as:
139
+
140
+ eog image_dir/*.jpg
141
+
142
+ and use the `` Delete `` key to remove redundant ones. The
143
+ `` nvm_visualize `` tool (see \ref sparsemapping) can be used exactly as
144
+ `` eog `` , and it has the advantage that it echoes the current image
145
+ name in the terminal, which can be useful in some occasions.
146
+
147
+ A good rule of thumb is for each image to have a 4/5 overlap with the
148
+ next one. Too much or too little overlap will cause Theia to fail.
149
+
150
+ It is suggested to avoid images with pure camera rotation, or at least
151
+ to have in the mix additional images of the same environemnt without
152
+ such rotations.
153
+
154
+ Put the selected images in a list:
155
+
156
+ ls image_dir/* jpg > image_list.txt
157
+
158
+ # Run the Astrobee wrapper around the Theia tools
159
+
85
160
python $ASTROBEE_SOURCE_PATH/localization/sparse_mapping/tools/build_theia_map.py \
86
161
--output_map theia.map --work_dir theia_work --image_list image_list.txt
87
162
88
163
This will take care of preparing everything Theia needs, will run it,
89
- and will export the resulting map to Astrobee's expected format. This
90
- map will need to be registered and visualized as described in other
91
- documentation. The work directory can be deleted later.
164
+ and will export the resulting map to Astrobee's expected format.
165
+
166
+ It is suggested to first run this tool on a small subset of the data,
167
+ perhaps made up of 10 images. A 700-image dataset may take perhaps 6
168
+ hours on a machine with a couple of dozen cores and use up perhaps 20
169
+ GB of RAM.
170
+
171
+ The obtained map can be examined with `` nvm_visualize `` , as described
172
+ in \ref sparsemapping.
173
+
174
+ The work directory can be deleted later.
175
+
176
+ # Command line options
92
177
93
178
This tool has the following command-line options:
94
179
@@ -106,6 +191,15 @@ This tool has the following command-line options:
106
191
imported from Theia. This is for testing purposes.
107
192
--help: Show this help message and exit.
108
193
194
+ # Next steps
195
+
196
+ This map will need to be registered and visualized as described in
197
+ \ref map_building.
198
+
199
+ That page also has information for how the map can be rebuilt to use
200
+ BRISK features, and how it can be validated for localization by
201
+ playing a bag against it.
202
+
109
203
# Auxiliary import_map tool
110
204
111
205
This tool is used to import a map from the NVM format, which Theia
0 commit comments