Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port stereo_image_proc to ROS 2 #486

Merged
merged 21 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 90 additions & 37 deletions stereo_image_proc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,57 +1,110 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.5)
project(stereo_image_proc)

find_package(catkin REQUIRED cv_bridge dynamic_reconfigure image_geometry image_proc image_transport message_filters nodelet sensor_msgs stereo_msgs)
find_package(Boost REQUIRED COMPONENTS thread)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(cv_bridge_VERSION VERSION_GREATER "1.12.0")
add_compile_options(-std=c++11)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# Dynamic reconfigure support
generate_dynamic_reconfigure_options(cfg/Disparity.cfg)
find_package(cv_bridge REQUIRED)
find_package(image_geometry REQUIRED)
find_package(image_proc REQUIRED)
find_package(image_transport REQUIRED)
find_package(message_filters REQUIRED)
find_package(OpenCV REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(stereo_msgs REQUIRED)

catkin_package(
CATKIN_DEPENDS image_geometry image_proc sensor_msgs stereo_msgs
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
include_directories(
include
${OpenCV_INCLUDE_DIRS}
)

include_directories(include)

find_package(OpenCV REQUIRED)
include_directories(${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})

# See note in image_proc/CMakeLists.txt
add_definitions(-DOPENCV_TRAITS_ENABLE_DEPRECATED)
# add_definitions(-DOPENCV_TRAITS_ENABLE_DEPRECATED)

# Nodelet library
add_library(${PROJECT_NAME} src/libstereo_image_proc/processor.cpp src/nodelets/disparity.cpp src/nodelets/point_cloud2.cpp)
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
add_library(${PROJECT_NAME} SHARED
src/${PROJECT_NAME}/stereo_processor.cpp
src/${PROJECT_NAME}/disparity_node.cpp
src/${PROJECT_NAME}/point_cloud_node.cpp
)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_gencfg)
install(TARGETS ${PROJECT_NAME}
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBRARIES}
)
install(FILES nodelet_plugins.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
ament_target_dependencies(${PROJECT_NAME}
cv_bridge
image_geometry
image_proc
image_transport
message_filters
rclcpp
rclcpp_components
sensor_msgs
stereo_msgs
)

# Standalone node
add_executable(stereoimageproc_exe src/nodes/stereo_image_proc.cpp)
target_link_libraries(stereoimageproc_exe stereo_image_proc)
SET_TARGET_PROPERTIES(stereoimageproc_exe PROPERTIES OUTPUT_NAME stereo_image_proc)
install(TARGETS stereoimageproc_exe
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "stereo_image_proc::DisparityNode"
EXECUTABLE disparity_node
)
rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "stereo_image_proc::PointCloudNode"
EXECUTABLE point_cloud_node
)

install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

# install the launch file
install(DIRECTORY launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/
DESTINATION share/${PROJECT_NAME}
)

# install the include directory
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
install(DIRECTORY include/
DESTINATION include
)

ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_cmake_pytest REQUIRED)
find_package(launch_testing_ament_cmake REQUIRED)
find_package(ament_lint_auto REQUIRED)
find_package(python_cmake_module REQUIRED)

ament_lint_auto_find_test_dependencies()

set(_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}")
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}")
endif()

# Test DisparityNode in launch test
add_launch_test("test/test_disparity_node.py"
PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
)
# TODO(jacobperron): As of Eloquent, they're just plain pytests
# ament_add_pytest_test("test_disparity_node" test/test_disparity_node.py
# PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
# )

# Test PointCloudNode in launch test
add_launch_test("test/test_point_cloud_node.py"
PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
)
# ament_add_pytest_test("test_point_cloud_node" test/test_point_cloud_node.py
# PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
# )

set(PYTHON_EXECUTABLE "${_PYTHON_EXECUTABLE}")
endif()

ament_package()
Empty file removed stereo_image_proc/COLCON_IGNORE
Empty file.
Loading