Skip to content

Commit 381c84c

Browse files
authored
[RST-1745] Added a marginalizeVariables() function (locusrobotics#48)
1 parent a29a55a commit 381c84c

File tree

6 files changed

+1647
-10
lines changed

6 files changed

+1647
-10
lines changed

fuse_constraints/CMakeLists.txt

+39-10
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,32 @@ cmake_minimum_required(VERSION 2.8.3)
22
project(fuse_constraints)
33

44
set(build_depends
5-
geometry_msgs
65
fuse_core
76
fuse_variables
7+
geometry_msgs
88
roscpp
99
)
1010

1111
find_package(catkin REQUIRED COMPONENTS
1212
${build_depends}
1313
)
1414

15+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
1516
find_package(Ceres REQUIRED)
1617
find_package(Eigen3 REQUIRED)
18+
find_package(SuiteSparse REQUIRED COMPONENTS CCOLAMD)
1719

1820
catkin_package(
1921
INCLUDE_DIRS
2022
include
21-
${CERES_INCLUDE_DIRS}
22-
${EIGEN3_INCLUDE_DIRS}
2323
LIBRARIES
2424
${PROJECT_NAME}
25-
${CERES_LIBRARIES}
2625
CATKIN_DEPENDS
2726
${build_depends}
27+
DEPENDS
28+
CERES
29+
EIGEN3
30+
SUITESPARSE
2831
)
2932

3033
###########
@@ -41,6 +44,7 @@ add_library(${PROJECT_NAME}
4144
src/absolute_pose_3d_stamped_constraint.cpp
4245
src/marginal_constraint.cpp
4346
src/marginal_cost_function.cpp
47+
src/marginalize_variables.cpp
4448
src/normal_delta.cpp
4549
src/normal_delta_orientation_2d.cpp
4650
src/normal_prior_orientation_2d.cpp
@@ -59,10 +63,13 @@ target_include_directories(${PROJECT_NAME}
5963
${catkin_INCLUDE_DIRS}
6064
${CERES_INCLUDE_DIRS}
6165
${EIGEN3_INCLUDE_DIRS}
66+
${SUITESPARSE_INCLUDE_DIRS}
6267
)
6368
target_link_libraries(${PROJECT_NAME}
6469
${catkin_LIBRARIES}
6570
${CERES_LIBRARIES}
71+
${EIGEN3_LIBRARIES}
72+
${SUITESPARSE_LIBRARIES}
6673
)
6774

6875
#############
@@ -87,6 +94,7 @@ install(DIRECTORY include/${PROJECT_NAME}/
8794
if(CATKIN_ENABLE_TESTING)
8895
find_package(roslint REQUIRED)
8996
find_package(rostest REQUIRED)
97+
find_package(fuse_graphs REQUIRED)
9098

9199
# Lint tests
92100
set(ROSLINT_CPP_OPTS "--filter=-build/c++11,-runtime/references")
@@ -105,7 +113,6 @@ if(CATKIN_ENABLE_TESTING)
105113
include
106114
${catkin_INCLUDE_DIRS}
107115
${CERES_INCLUDE_DIRS}
108-
${EIGEN3_INCLUDE_DIRS}
109116
)
110117
target_link_libraries(test_absolute_constraint
111118
${PROJECT_NAME}
@@ -130,6 +137,8 @@ if(CATKIN_ENABLE_TESTING)
130137
target_link_libraries(test_absolute_orientation_3d_stamped_constraint
131138
${PROJECT_NAME}
132139
${catkin_LIBRARIES}
140+
${CERES_LIBRARIES}
141+
${EIGEN3_LIBRARIES}
133142
)
134143

135144
# Absolute Orientation 3D Stamped Euler Constraint Tests
@@ -149,6 +158,8 @@ if(CATKIN_ENABLE_TESTING)
149158
target_link_libraries(test_absolute_orientation_3d_stamped_euler_constraint
150159
${PROJECT_NAME}
151160
${catkin_LIBRARIES}
161+
${CERES_LIBRARIES}
162+
${EIGEN3_LIBRARIES}
152163
)
153164

154165
# Absolute Pose 2D Stamped Constraint Tests
@@ -163,11 +174,11 @@ if(CATKIN_ENABLE_TESTING)
163174
include
164175
${catkin_INCLUDE_DIRS}
165176
${CERES_INCLUDE_DIRS}
166-
${EIGEN3_INCLUDE_DIRS}
167177
)
168178
target_link_libraries(test_absolute_pose_2d_stamped_constraint
169179
${PROJECT_NAME}
170180
${catkin_LIBRARIES}
181+
${CERES_LIBRARIES}
171182
)
172183

173184
# Absolute Pose 3D Stamped Constraint Tests
@@ -182,11 +193,11 @@ if(CATKIN_ENABLE_TESTING)
182193
include
183194
${catkin_INCLUDE_DIRS}
184195
${CERES_INCLUDE_DIRS}
185-
${EIGEN3_INCLUDE_DIRS}
186196
)
187197
target_link_libraries(test_absolute_pose_3d_stamped_constraint
188198
${PROJECT_NAME}
189199
${catkin_LIBRARIES}
200+
${CERES_LIBRARIES}
190201
)
191202

192203
# Marginal Constraint Tests
@@ -206,6 +217,25 @@ if(CATKIN_ENABLE_TESTING)
206217
${catkin_LIBRARIES}
207218
)
208219

220+
# Marginalize Variables Tests
221+
catkin_add_gtest(test_marginalize_variables
222+
test/test_marginalize_variables.cpp
223+
)
224+
add_dependencies(test_marginalize_variables
225+
${catkin_EXPORTED_TARGETS}
226+
)
227+
target_include_directories(test_marginalize_variables
228+
PRIVATE
229+
include
230+
${CERES_INCLUDE_DIRS}
231+
${fuse_graphs_INCLUDE_DIRS}
232+
)
233+
target_link_libraries(test_marginalize_variables
234+
${PROJECT_NAME}
235+
${catkin_LIBRARIES}
236+
${fuse_graphs_LIBRARIES}
237+
)
238+
209239
# Relative Constraint Tests
210240
catkin_add_gtest(test_relative_constraint
211241
test/test_relative_constraint.cpp
@@ -218,7 +248,6 @@ if(CATKIN_ENABLE_TESTING)
218248
include
219249
${catkin_INCLUDE_DIRS}
220250
${CERES_INCLUDE_DIRS}
221-
${EIGEN3_INCLUDE_DIRS}
222251
)
223252
target_link_libraries(test_relative_constraint
224253
${PROJECT_NAME}
@@ -238,11 +267,11 @@ if(CATKIN_ENABLE_TESTING)
238267
include
239268
${catkin_INCLUDE_DIRS}
240269
${CERES_INCLUDE_DIRS}
241-
${EIGEN3_INCLUDE_DIRS}
242270
)
243271
target_link_libraries(test_relative_pose_2d_stamped_constraint
244272
${PROJECT_NAME}
245273
${catkin_LIBRARIES}
274+
${CERES_LIBRARIES}
246275
)
247276

248277
# Relative Pose 3D Stamped Constraint Tests
@@ -257,11 +286,11 @@ if(CATKIN_ENABLE_TESTING)
257286
include
258287
${catkin_INCLUDE_DIRS}
259288
${CERES_INCLUDE_DIRS}
260-
${EIGEN3_INCLUDE_DIRS}
261289
)
262290
target_link_libraries(test_relative_pose_3d_stamped_constraint
263291
${PROJECT_NAME}
264292
${catkin_LIBRARIES}
293+
${CERES_LIBRARIES}
265294
)
266295

267296
# UuidOrdering Tests

0 commit comments

Comments
 (0)