Skip to content

Commit

Permalink
Move simulator into a library
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerKuemmerle committed Apr 21, 2024
1 parent a20c62b commit c0d53ca
Show file tree
Hide file tree
Showing 48 changed files with 108 additions and 92 deletions.
5 changes: 4 additions & 1 deletion g2o/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ endif(G2O_BUILD_APPS)
# Pre-canned types
add_subdirectory(types)

# Solvers
add_subdirectory(solvers)

if (G2O_BUILD_SLAM2D_TYPES AND G2O_BUILD_SLAM3D_TYPES)
add_subdirectory(simulator)
endif()

# Examples
if(G2O_BUILD_EXAMPLES)
add_subdirectory(examples)
Expand Down
2 changes: 1 addition & 1 deletion g2o/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_subdirectory(g2o_cli)

if (G2O_BUILD_SLAM2D_TYPES AND G2O_BUILD_SLAM3D_TYPES)
if (TARGET simulator_lib)
add_subdirectory(g2o_simulator)
endif()

Expand Down
49 changes: 5 additions & 44 deletions g2o/apps/g2o_simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,58 +1,19 @@
add_library(g2o_simulator_library ${G2O_LIB_TYPE}
simulator.cpp simulator.h
pointsensorparameters.cpp pointsensorparameters.h
simulator2d_base.h
sensor_odometry2d.cpp sensor_odometry2d.h
sensor_pose2d.cpp sensor_pose2d.h
sensor_pointxy.cpp sensor_pointxy.h
sensor_pointxy_bearing.cpp sensor_pointxy_bearing.h
sensor_pointxy_offset.cpp sensor_pointxy_offset.h
simutils.cpp simutils.h
sensor_segment2d.cpp sensor_segment2d.h
sensor_segment2d_line.cpp sensor_segment2d_line.h
sensor_segment2d_pointline.cpp sensor_segment2d_pointline.h

simulator3d_base.h
sensor_odometry3d.cpp sensor_odometry3d.h
sensor_pose3d.cpp sensor_pose3d.h
sensor_pose3d_offset.cpp sensor_pose3d_offset.h
sensor_pointxyz.cpp sensor_pointxyz.h
sensor_pointxyz_disparity.cpp sensor_pointxyz_disparity.h
sensor_pointxyz_depth.cpp sensor_pointxyz_depth.h
sensor_se3_prior.cpp sensor_se3_prior.h

g2o_simulator_api.h
)

set_target_properties(g2o_simulator_library PROPERTIES OUTPUT_NAME ${LIB_PREFIX}simulator)
set_target_properties(g2o_simulator_library PROPERTIES
VERSION ${G2O_LIB_VERSION}
SOVERSION ${G2O_LIB_SOVERSION})
if (APPLE)
set_target_properties(g2o_simulator_library PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()

target_link_libraries(g2o_simulator_library types_slam3d_addons types_slam3d types_slam2d_addons types_slam2d core)

add_executable(g2o_simulator2d_application
test_simulator2d.cpp
g2o_simulator2d.cpp
)
target_link_libraries(g2o_simulator2d_application g2o_simulator_library types_slam2d_addons types_slam2d core)
target_link_libraries(g2o_simulator2d_application simulator_lib types_slam2d_addons types_slam2d core)
set_target_properties(g2o_simulator2d_application PROPERTIES OUTPUT_NAME g2o_simulator2d)

add_executable(g2o_simulator3d_application
test_simulator3d.cpp
g2o_simulator3d.cpp
)
target_link_libraries(g2o_simulator3d_application g2o_simulator_library types_slam3d_addons types_slam3d types_slam2d_addons types_slam2d core)
target_link_libraries(g2o_simulator3d_application simulator_lib types_slam3d_addons types_slam3d types_slam2d_addons types_slam2d core)
set_target_properties(g2o_simulator3d_application PROPERTIES OUTPUT_NAME g2o_simulator3d)

install(TARGETS g2o_simulator_library g2o_simulator2d_application g2o_simulator3d_application
install(TARGETS g2o_simulator2d_application g2o_simulator3d_application
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
install(FILES ${headers} DESTINATION ${INCLUDES_INSTALL_DIR}/apps/g2o_simulator)
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
#include <memory>
#include <optional>

#include "g2o/apps/g2o_simulator/sensor_odometry2d.h"
#include "g2o/apps/g2o_simulator/sensor_pointxy.h"
#include "g2o/apps/g2o_simulator/sensor_pointxy_bearing.h"
#include "g2o/apps/g2o_simulator/sensor_pose2d.h"
#include "g2o/apps/g2o_simulator/sensor_segment2d.h"
#include "g2o/apps/g2o_simulator/sensor_segment2d_line.h"
#include "g2o/apps/g2o_simulator/sensor_segment2d_pointline.h"
#include "g2o/apps/g2o_simulator/simulator.h"
#include "g2o/apps/g2o_simulator/simulator2d_base.h"
#include "g2o/core/optimizable_graph.h"
#include "g2o/simulator/sensor_odometry2d.h"
#include "g2o/simulator/sensor_pointxy.h"
#include "g2o/simulator/sensor_pointxy_bearing.h"
#include "g2o/simulator/sensor_pose2d.h"
#include "g2o/simulator/sensor_segment2d.h"
#include "g2o/simulator/sensor_segment2d_line.h"
#include "g2o/simulator/sensor_segment2d_pointline.h"
#include "g2o/simulator/simulator.h"
#include "g2o/simulator/simulator2d_base.h"
#include "g2o/stuff/command_args.h"
#include "g2o/stuff/sampler.h"
#include "g2o/types/slam2d/se2.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
#include <memory>
#include <optional>

#include "g2o/apps/g2o_simulator/sensor_odometry3d.h"
#include "g2o/apps/g2o_simulator/sensor_pointxyz.h"
#include "g2o/apps/g2o_simulator/sensor_pointxyz_depth.h"
#include "g2o/apps/g2o_simulator/sensor_pointxyz_disparity.h"
#include "g2o/apps/g2o_simulator/sensor_pose3d.h"
#include "g2o/apps/g2o_simulator/simulator.h"
#include "g2o/apps/g2o_simulator/simulator3d_base.h"
#include "g2o/core/eigen_types.h"
#include "g2o/core/optimizable_graph.h"
#include "g2o/simulator/sensor_odometry3d.h"
#include "g2o/simulator/sensor_pointxyz.h"
#include "g2o/simulator/sensor_pointxyz_depth.h"
#include "g2o/simulator/sensor_pointxyz_disparity.h"
#include "g2o/simulator/sensor_pose3d.h"
#include "g2o/simulator/simulator.h"
#include "g2o/simulator/simulator3d_base.h"
#include "g2o/stuff/command_args.h"
#include "g2o/stuff/sampler.h"
#include "g2o/types/slam3d/parameter_camera.h"
Expand Down
51 changes: 51 additions & 0 deletions g2o/simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
add_library(simulator_lib ${G2O_LIB_TYPE}
simulator.cpp simulator.h
pointsensorparameters.cpp pointsensorparameters.h
simulator2d_base.h
sensor_odometry2d.cpp sensor_odometry2d.h
sensor_pose2d.cpp sensor_pose2d.h
sensor_pointxy.cpp sensor_pointxy.h
sensor_pointxy_bearing.cpp sensor_pointxy_bearing.h
sensor_pointxy_offset.cpp sensor_pointxy_offset.h
simutils.cpp simutils.h
sensor_segment2d.cpp sensor_segment2d.h
sensor_segment2d_line.cpp sensor_segment2d_line.h
sensor_segment2d_pointline.cpp sensor_segment2d_pointline.h

simulator3d_base.h
sensor_odometry3d.cpp sensor_odometry3d.h
sensor_pose3d.cpp sensor_pose3d.h
sensor_pose3d_offset.cpp sensor_pose3d_offset.h
sensor_pointxyz.cpp sensor_pointxyz.h
sensor_pointxyz_disparity.cpp sensor_pointxyz_disparity.h
sensor_pointxyz_depth.cpp sensor_pointxyz_depth.h
sensor_se3_prior.cpp sensor_se3_prior.h

g2o_simulator_api.h
)

target_include_directories(core PUBLIC
"$<BUILD_INTERFACE:${g2o_SOURCE_DIR};${PROJECT_BINARY_DIR}>"
$<INSTALL_INTERFACE:include/g2o/simulator>
)

set_target_properties(simulator_lib PROPERTIES OUTPUT_NAME ${LIB_PREFIX}simulator)
set_target_properties(simulator_lib PROPERTIES
VERSION ${G2O_LIB_VERSION}
SOVERSION ${G2O_LIB_SOVERSION})
if (APPLE)
set_target_properties(simulator_lib PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()

target_link_libraries(simulator_lib types_slam3d_addons types_slam3d types_slam2d_addons types_slam2d core)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
install(FILES ${headers} DESTINATION ${INCLUDES_INSTALL_DIR}/simulator)

install(TARGETS simulator_lib
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@
#ifndef G2O_SIMULATOR_API_H
#define G2O_SIMULATOR_API_H

#include "g2o/config.h"

#ifdef _MSC_VER
// We are using a Microsoft compiler:
#include "g2o/config.h"
#ifdef G2O_SHARED_LIBS
#ifdef g2o_simulator_library_EXPORTS
#ifdef simulator_lib_EXPORTS
#define G2O_SIMULATOR_API __declspec(dllexport)
#else
#define G2O_SIMULATOR_API __declspec(dllimport)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "sensor_odometry2d.h"

#include "g2o/apps/g2o_simulator/simulator2d_base.h"
#include "g2o/simulator/simulator2d_base.h"
#include "g2o/stuff/logger.h"

// Robot2D
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <cassert>
#include <utility>

#include "g2o/apps/g2o_simulator/simulator.h"
#include "g2o/simulator/simulator.h"

namespace g2o {

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <cassert>
#include <utility>

#include "g2o/apps/g2o_simulator/simulator.h"
#include "g2o/simulator/simulator.h"

namespace g2o {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

#ifndef G2O_SENSOR_POINTXYZ_H_
#define G2O_SENSOR_POINTXYZ_H_
#include "g2o/apps/g2o_simulator/simulator.h"

#include "g2o/simulator/simulator.h"
#include "g2o/types/slam3d/edge_se3_pointxyz.h"
#include "g2o_simulator_api.h"
#include "pointsensorparameters.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <cassert>

#include "g2o/apps/g2o_simulator/simulator.h"
#include "g2o/simulator/simulator.h"

namespace g2o {

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <cassert>

#include "g2o/apps/g2o_simulator/simulator.h"
#include "simulator.h"

namespace g2o {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

#ifndef G2O_SENSOR_POINTXYZ_DISPARITY_H_
#define G2O_SENSOR_POINTXYZ_DISPARITY_H_
#include "g2o/apps/g2o_simulator/simulator.h"

#include "g2o/simulator/simulator.h"
#include "g2o/types/slam3d/edge_se3_pointxyz_disparity.h"
#include "g2o/types/slam3d/parameter_camera.h"
#include "g2o_simulator_api.h"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <unordered_set>
#include <utility>

#include "g2o/apps/g2o_simulator/simulator.h"
#include "g2o/simulator/simulator.h"
#include "g2o/types/slam3d/isometry3d_mappings.h"

namespace g2o {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef G2O_SENSOR_POSE3D_OFFSET_H_
#define G2O_SENSOR_POSE3D_OFFSET_H_

#include "g2o/apps/g2o_simulator/simulator.h"
#include "g2o/simulator/simulator.h"
#include "g2o/types/slam3d/edge_se3_offset.h"
#include "g2o/types/slam3d/parameter_se3_offset.h"
#include "pointsensorparameters.h"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <cassert>
#include <utility>

#include "g2o/apps/g2o_simulator/simutils.h"
#include "g2o/simulator/simutils.h"

namespace g2o {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#ifndef G2O_SENSOR_SEGMENT2D_H_
#define G2O_SENSOR_SEGMENT2D_H_

#include "g2o/apps/g2o_simulator/pointsensorparameters.h"
#include "g2o/apps/g2o_simulator/simulator2d_base.h"
#include "g2o/simulator/pointsensorparameters.h"
#include "g2o/simulator/simulator2d_base.h"
#include "g2o/types/slam2d_addons/edge_se2_segment2d.h"

namespace g2o {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <cassert>
#include <utility>

#include "g2o/apps/g2o_simulator/simutils.h"
#include "g2o/simulator/simutils.h"

namespace g2o {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#ifndef G2O_SENSOR_SEGMENT2D_LINE_H_
#define G2O_SENSOR_SEGMENT2D_LINE_H_

#include "g2o/apps/g2o_simulator/pointsensorparameters.h"
#include "g2o/apps/g2o_simulator/simulator2d_base.h"
#include "g2o/simulator/pointsensorparameters.h"
#include "g2o/simulator/simulator2d_base.h"
#include "g2o/types/slam2d_addons/edge_se2_segment2d_line.h"

namespace g2o {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <cassert>
#include <utility>

#include "g2o/apps/g2o_simulator/simutils.h"
#include "g2o/simulator/simutils.h"

namespace g2o {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#ifndef G2O_SENSOR_SEGMENT2D_POINTLINE_H_
#define G2O_SENSOR_SEGMENT2D_POINTLINE_H_

#include "g2o/apps/g2o_simulator/pointsensorparameters.h"
#include "g2o/apps/g2o_simulator/simulator2d_base.h"
#include "g2o/simulator/pointsensorparameters.h"
#include "g2o/simulator/simulator2d_base.h"
#include "g2o/types/slam2d_addons/edge_se2_segment2d_pointLine.h"

namespace g2o {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions todo.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
[ ] wrap simulator into library
[ ] add python wrapper for simulator
[x] wrap simulator into library
[ ] add config types for simulation
[ ] add tests for simulator
[ ] add python wrapper for simulator
[x] Create parameter type for ParameterCamera to support load/save
[ ] Add typing for parameters to template?
[ ] Add fixed size types for pure python problems
[ ] Re-work python wrapping for parameters, templated base param
[ ] Test load/save for VertexCam (camera and baseline seem missing from traits)
[x] Refactor Data container. Can it be a container instead of linked list?
[ ] use cmakedefine01 for compile flags in config
[ ] add test for setData / getData on the graph
[ ] update py_base_vertex/edge to map now common methods
[ ] Use FakeDependency in Traits
[ ] wrap abstract graph to python and update save wrapper
[x] Create parameter type for ParameterCamera to support load/save
[x] Refactor Data container. Can it be a container instead of linked list?
[x] EdgeSE2TwoPointsXY, EdgeSE2PointXYCalib can be fixed size edges -> IO test
[x] IO test fixture including parameter
[x] Type Based Tests for Jacobian
Expand All @@ -19,10 +24,5 @@
[x] test save/load of dynamic edge
[x] binary format for save/load
[x] XML format for save/load
[ ] wrap abstract graph to python and update save wrapper
[x] ParameterContainer remove read/write
[x] remove read/write methods for vertex / edge

[ ] use cmakedefine01 for compile flags in config
[ ] add test for setData / getData on the graph
[ ] update py_base_vertex/edge to map now common methods

0 comments on commit c0d53ca

Please sign in to comment.