Skip to content

Commit

Permalink
Port to ros2
Browse files Browse the repository at this point in the history
  • Loading branch information
sacovo committed Aug 7, 2024
1 parent c0396a2 commit 6d825b6
Show file tree
Hide file tree
Showing 31 changed files with 2,462 additions and 276 deletions.
27 changes: 27 additions & 0 deletions Dockerfile_humble_22_04
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ros:humble-perception-jammy

RUN rm -f /etc/apt/apt.conf.d/docker-clean
RUN --mount=type=cache,target=/var/cache/apt apt-get update --fix-missing && apt-get upgrade -y

RUN --mount=type=cache,target=/var/cache/apt\
DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends --yes \
python3-colcon-common-extensions \
python3-rosdep

WORKDIR /work

RUN useradd -ms /bin/bash ros &&\
chown ros:ros /work &&\
usermod -aG sudo ros &&\
echo "ros ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers &&\
echo "ros:ros" | chpasswd

USER ros

COPY . /work/src/MINS

RUN bash /work/src/MINS/build_ros2.sh

RUN echo "source '/work/install/setup.bash'" >> ~/.bashrc

10 changes: 10 additions & 0 deletions build_ros2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

source /opt/ros/humble/setup.bash
colcon build --paths thirdparty/*
source install/setup.bash
colcon build --paths thirdparty/open_vins/*
source install/setup.bash
colcon build --paths mins mins_data
source install/setup.bash
colcon build --paths mins_eval
128 changes: 12 additions & 116 deletions mins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,119 +33,15 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fsee -fomit-frame-pointer -fno-sign
# Enable debug flags (use if you want to debug in gdb)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -Wuninitialized -Wmaybe-uninitialized -fno-omit-frame-pointer")

# Find ROS build system
find_package(catkin REQUIRED COMPONENTS roscpp rosbag tf std_msgs geometry_msgs sensor_msgs nav_msgs image_geometry visualization_msgs image_transport cv_bridge ov_core pcl_ros)

add_definitions(-DROS_AVAILABLE=1)

# Add catkin packages
catkin_package(
CATKIN_DEPENDS roscpp rosbag tf std_msgs geometry_msgs sensor_msgs nav_msgs image_geometry visualization_msgs image_transport cv_bridge ov_core pcl_ros
INCLUDE_DIRS src/
LIBRARIES mins_lib
)

# Include our header files
include_directories(
src
${EIGEN3_INCLUDE_DIR}
${PCL_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${libpointmatcher_INCLUDE_DIRS}
)

# Set link libraries used by all binaries
list(APPEND thirdparty_libraries
${Boost_LIBRARIES}
${OpenCV_LIBRARIES}
${catkin_LIBRARIES}
${libpointmatcher_LIBRARIES}
)

##################################################
# Make the shared library
##################################################

list(APPEND LIBRARY_SOURCES
src/options/Options.cpp
src/options/OptionsCamera.cpp
src/options/OptionsEstimator.cpp
src/options/OptionsGPS.cpp
src/options/OptionsIMU.cpp
src/options/OptionsInit.cpp
src/options/OptionsLidar.cpp
src/options/OptionsSimulation.cpp
src/options/OptionsSystem.cpp
src/options/OptionsVicon.cpp
src/options/OptionsWheel.cpp
src/core/ROSPublisher.cpp
src/core/ROSSubscriber.cpp
src/core/ROSHelper.cpp
src/sim/Simulator.cpp
src/sim/ConstBsplineSE3.cpp
src/sim/SimVisualizer.cpp
src/utils/Print_Logger.cpp
src/utils/Jabdongsani.cpp
src/state/State.cpp
src/state/StateHelper.cpp
src/state/Propagator.cpp
src/core/SystemManager.cpp
src/update/cam/CamTypes.cpp
src/update/cam/CamHelper.cpp
src/update/cam/UpdaterCamera.cpp
src/update/vicon/UpdaterVicon.cpp
src/update/gps/UpdaterGPS.cpp
src/update/wheel/UpdaterWheel.cpp
src/update/lidar/ikd_Tree.cpp
src/update/lidar/UpdaterLidar.cpp
src/update/lidar/LidarHelper.cpp
src/update/lidar/LidarTypes.cpp
src/update/UpdaterStatistics.cpp
src/init/Initializer.cpp
src/init/imu/I_Initializer.cpp
src/init/imu_wheel/IW_Initializer.cpp
)


file(GLOB_RECURSE LIBRARY_HEADERS "src/*.h")
add_library(mins_lib SHARED ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
target_link_libraries(mins_lib ${thirdparty_libraries})
target_include_directories(mins_lib PUBLIC src/)
install(TARGETS mins_lib
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY src/
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)

##################################################
# Make binary files!
##################################################

add_executable(simulation src/run_simulation.cpp)
target_link_libraries(simulation mins_lib)
install(TARGETS simulation
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

add_executable(bag src/run_bag.cpp)
target_link_libraries(bag mins_lib)
install(TARGETS bag
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

add_executable(subscribe src/run_subscribe.cpp)
target_link_libraries(subscribe mins_lib)
install(TARGETS subscribe
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
find_package(catkin QUIET COMPONENTS roscpp)
find_package(ament_cmake QUIET)
if (catkin_FOUND)
message(STATUS "ROS *1* version found, building ROS1.cmake")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS1.cmake)
elseif (ament_cmake_FOUND)
message(STATUS "ROS *2* version found, building ROS2.cmake")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS2.cmake)
else ()
message(STATUS "No ROS versions found, building ROS1.cmake")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS1.cmake)
endif ()
117 changes: 117 additions & 0 deletions mins/cmake/ROS1.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
cmake_minimum_required(VERSION 3.5.1)

find_package(catkin REQUIRED COMPONENTS roscpp rosbag tf std_msgs geometry_msgs sensor_msgs nav_msgs image_geometry visualization_msgs image_transport cv_bridge ov_core pcl_ros)

add_definitions(-DROS_AVAILABLE=1)

# Add catkin packages
catkin_package(
CATKIN_DEPENDS roscpp rosbag tf std_msgs geometry_msgs sensor_msgs nav_msgs image_geometry visualization_msgs image_transport cv_bridge ov_core pcl_ros
INCLUDE_DIRS src/
LIBRARIES mins_lib
)

# Include our header files
include_directories(
src
${EIGEN3_INCLUDE_DIR}
${PCL_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${libpointmatcher_INCLUDE_DIRS}
)

# Set link libraries used by all binaries
list(APPEND thirdparty_libraries
${Boost_LIBRARIES}
${OpenCV_LIBRARIES}
${catkin_LIBRARIES}
${libpointmatcher_LIBRARIES}
)

##################################################
# Make the shared library
##################################################

list(APPEND LIBRARY_SOURCES
src/options/Options.cpp
src/options/OptionsCamera.cpp
src/options/OptionsEstimator.cpp
src/options/OptionsGPS.cpp
src/options/OptionsIMU.cpp
src/options/OptionsInit.cpp
src/options/OptionsLidar.cpp
src/options/OptionsSimulation.cpp
src/options/OptionsSystem.cpp
src/options/OptionsVicon.cpp
src/options/OptionsWheel.cpp
src/core/ROSPublisher.cpp
src/core/ROSSubscriber.cpp
src/core/ROSHelper.cpp
src/sim/Simulator.cpp
src/sim/ConstBsplineSE3.cpp
src/sim/SimVisualizer.cpp
src/utils/Print_Logger.cpp
src/utils/Jabdongsani.cpp
src/state/State.cpp
src/state/StateHelper.cpp
src/state/Propagator.cpp
src/core/SystemManager.cpp
src/update/cam/CamTypes.cpp
src/update/cam/CamHelper.cpp
src/update/cam/UpdaterCamera.cpp
src/update/vicon/UpdaterVicon.cpp
src/update/gps/UpdaterGPS.cpp
src/update/wheel/UpdaterWheel.cpp
src/update/lidar/ikd_Tree.cpp
src/update/lidar/UpdaterLidar.cpp
src/update/lidar/LidarHelper.cpp
src/update/lidar/LidarTypes.cpp
src/update/UpdaterStatistics.cpp
src/init/Initializer.cpp
src/init/imu/I_Initializer.cpp
src/init/imu_wheel/IW_Initializer.cpp
)


file(GLOB_RECURSE LIBRARY_HEADERS "src/*.h")
add_library(mins_lib SHARED ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
target_link_libraries(mins_lib ${thirdparty_libraries})
target_include_directories(mins_lib PUBLIC src/)
install(TARGETS mins_lib
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY src/
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)

##################################################
# Make binary files!
##################################################

add_executable(simulation src/run_simulation.cpp)
target_link_libraries(simulation mins_lib)
install(TARGETS simulation
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

add_executable(bag src/run_bag.cpp)
target_link_libraries(bag mins_lib)
install(TARGETS bag
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

add_executable(subscribe src/run_subscribe.cpp)
target_link_libraries(subscribe mins_lib)
install(TARGETS subscribe
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
Loading

0 comments on commit 6d825b6

Please sign in to comment.