Skip to content

Commit

Permalink
More robust detection of ROS 1 vs ROS 2 (PRBonn#107)
Browse files Browse the repository at this point in the history
* add .vscode to ignore files

* FIX: Allow using colcon to build for ROS 1

* Add ros_environment dependency to expose ROS_VERSION env var in build farms

---------

Co-authored-by: Ignacio Vizzo <[email protected]>
  • Loading branch information
jlblancoc and nachovizzo authored Mar 29, 2023
1 parent 99ac940 commit ea91033
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,6 @@ cython_debug/

# End of https://www.toptal.com/developers/gitignore/api/python
nn

# VSCode
.vscode
4 changes: 2 additions & 2 deletions ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ else()
FetchContent_MakeAvailable(ext_kiss_icp_core)
endif()

if(CATKIN_DEVEL_PREFIX OR catkin_FOUND OR CATKIN_BUILD_BINARY_PACKAGE)
if("$ENV{ROS_VERSION}" STREQUAL "1")
message(STATUS "KISS-ICP-ROS1 wrapper will be compiled")
find_package(
catkin REQUIRED
Expand All @@ -60,7 +60,7 @@ if(CATKIN_DEVEL_PREFIX OR catkin_FOUND OR CATKIN_BUILD_BINARY_PACKAGE)
target_link_libraries(odometry_node kiss_icp::pipeline ${catkin_LIBRARIES})
install(TARGETS odometry_node RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
elseif(DEFINED ENV{AMENT_PREFIX_PATH})
elseif("$ENV{ROS_VERSION}" STREQUAL "2")
message(STATUS "KISS-ICP-ROS2 wrapper will be compiled")

find_package(ament_cmake REQUIRED)
Expand Down
3 changes: 3 additions & 0 deletions ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<maintainer email="[email protected]">ivizzo</maintainer>
<license>MIT</license>

<!-- Common ROS 1 / ROS 2 dependencies -->
<build_depend>ros_environment</build_depend>

<!-- ROS1 dependencies -->
<buildtool_depend condition="$ROS_VERSION == 1">catkin</buildtool_depend>
<depend condition="$ROS_VERSION == 1">roscpp</depend>
Expand Down

0 comments on commit ea91033

Please sign in to comment.