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 depth image proc on ROS2 #362

Merged
merged 7 commits into from Nov 21, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
91 changes: 67 additions & 24 deletions depth_image_proc/CMakeLists.txt
@@ -1,44 +1,87 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.5)
project(depth_image_proc)

find_package(catkin REQUIRED cmake_modules cv_bridge eigen_conversions image_geometry image_transport message_filters nodelet sensor_msgs stereo_msgs tf2 tf2_ros)
# Default to C++14
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()

catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME})
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(tf2_eigen REQUIRED)
find_package(image_geometry REQUIRED)
find_package(image_transport REQUIRED)
find_package(message_filters REQUIRED)
find_package(class_loader REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(stereo_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)

find_package(Boost REQUIRED)
find_package(Eigen3 QUIET)
if(NOT EIGEN3_FOUND)
find_package(Eigen REQUIRED)
set(EIGEN3_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
endif()
find_package(OpenCV REQUIRED)
include_directories(include ${BOOST_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS})

add_library(${PROJECT_NAME} src/nodelets/convert_metric.cpp
src/nodelets/crop_foremost.cpp
src/nodelets/disparity.cpp
src/nodelets/point_cloud_xyz.cpp
src/nodelets/point_cloud_xyzrgb.cpp
src/nodelets/point_cloud_xyzi.cpp
src/nodelets/point_cloud_xyz_radial.cpp
src/nodelets/point_cloud_xyzi_radial.cpp
src/nodelets/register.cpp
include_directories(include ${BOOST_INCLUDE_DIRS} ${rclcpp_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS})

add_library(${PROJECT_NAME} SHARED
src/nodelets/convert_metric.cpp
src/nodelets/crop_foremost.cpp
src/nodelets/disparity.cpp
src/nodelets/point_cloud_xyz.cpp
src/nodelets/point_cloud_xyzrgb.cpp
src/nodelets/point_cloud_xyzi.cpp
src/nodelets/point_cloud_xyz_radial.cpp
src/nodelets/point_cloud_xyzi_radial.cpp
src/nodelets/register.cpp
)
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
ament_target_dependencies(${PROJECT_NAME}
"image_transport"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The quotes aren't necessary here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If remove "image_transport" from ament_target_dependencies, the build will fail with "fatal error: image_transport/image_transport.h: No such file or directory", so I just keep it.

ament_target_dependencies(${PROJECT_NAME}
#  "image_transport"

"image_geometry"
"cv_bridge"
"class_loader"
"message_filters"
"rclcpp"
"tf2_ros"
"tf2"
"tf2_eigen"
"stereo_msgs"
"sensor_msgs"
)

#rclcpp_register_node_plugins(${PROJECT_NAME} "${PROJECT_NAME}::ConvertMetricNode")
#rclcpp_register_node_plugins(${PROJECT_NAME} "${PROJECT_NAME}::CropForemostNode")
#rclcpp_register_node_plugins(${PROJECT_NAME} "${PROJECT_NAME}::DisparityNode")
#rclcpp_register_node_plugins(${PROJECT_NAME} "${PROJECT_NAME}::PointCloudXyzNode")
#rclcpp_register_node_plugins(${PROJECT_NAME} "${PROJECT_NAME}::PointCloudXyzRadialNode")
#rclcpp_register_node_plugins(${PROJECT_NAME} "${PROJECT_NAME}::PointCloudXyziNode")
#rclcpp_register_node_plugins(${PROJECT_NAME} "${PROJECT_NAME}::PointCloudXyziRadialNode")
#rclcpp_register_node_plugins(${PROJECT_NAME} "${PROJECT_NAME}::PointCloudXyzrgbNode")
#rclcpp_register_node_plugins(${PROJECT_NAME} "${PROJECT_NAME}::RegisterNode")

target_link_libraries(${PROJECT_NAME} ${ament_LIBRARIES} ${OpenCV_LIBRARIES})

install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
DESTINATION include/${PROJECT_NAME}
FILES_MATCHING PATTERN "*.h")

install(TARGETS ${PROJECT_NAME}
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
DESTINATION lib
)
install(FILES nodelet_plugins.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
install(DIRECTORY examples/launch
DESTINATION share/${PROJECT_NAME}/
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
Empty file removed depth_image_proc/COLCON_IGNORE
Empty file.
66 changes: 66 additions & 0 deletions depth_image_proc/examples/launch/convert_metric.launch.py
@@ -0,0 +1,66 @@
# Copyright (c) 2008, Willow Garage, Inc.
# All rights reserved.
#
# Software License Agreement (BSD License 2.0)
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the Willow Garage nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription

import launch_ros.actions


def generate_launch_description():
default_rviz = os.path.join(get_package_share_directory('depth_image_proc'),
'launch', 'rviz/convert_metric.rviz')
return LaunchDescription([
# install realsense from https://github.com/intel/ros2_intel_realsense
launch_ros.actions.Node(
package='realsense_ros2_camera', node_executable='realsense_ros2_camera',
output='screen'),

# composition api_composition, remap the topic
launch_ros.actions.Node(
package='composition', node_executable='api_composition', output='screen',
remappings=[('image_raw', '/camera/depth/image_rect_raw'),
('camera_info', '/camera/depth/camera_info'),
('image', '/camera/depth/converted_image')]),

# depth_image_proc::ConvertMetricNode
launch_ros.actions.Node(
package='composition', node_executable='api_composition_cli', output='screen',
arguments=['depth_image_proc', 'depth_image_proc::ConvertMetricNode']),

# rviz
launch_ros.actions.Node(
package='rviz2', node_executable='rviz2', output='screen',
arguments=['--display-config', default_rviz]),
])
66 changes: 66 additions & 0 deletions depth_image_proc/examples/launch/crop_foremost.launch.py
@@ -0,0 +1,66 @@
# Copyright (c) 2008, Willow Garage, Inc.
# All rights reserved.
#
# Software License Agreement (BSD License 2.0)
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the Willow Garage nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription

import launch_ros.actions


def generate_launch_description():
default_rviz = os.path.join(get_package_share_directory('depth_image_proc'),
'launch', 'rviz/crop_formost.rviz')
return LaunchDescription([
# install realsense from https://github.com/intel/ros2_intel_realsense
launch_ros.actions.Node(
package='realsense_ros2_camera', node_executable='realsense_ros2_camera',
output='screen'),

# composition api_composition, remap the topic
launch_ros.actions.Node(
package='composition', node_executable='api_composition', output='screen',
remappings=[('image_raw', '/camera/depth/image_rect_raw'),
('camera_info', '/camera/depth/camera_info'),
('image', '/camera/depth/crop_image')]),

# depth_image_proc::CropForemostNode
launch_ros.actions.Node(
package='composition', node_executable='api_composition_cli', output='screen',
arguments=['depth_image_proc', 'depth_image_proc::CropForemostNode']),

# rviz
launch_ros.actions.Node(
package='rviz2', node_executable='rviz2', output='screen',
arguments=['--display-config', default_rviz]),
])
69 changes: 69 additions & 0 deletions depth_image_proc/examples/launch/disparity.launch.py
@@ -0,0 +1,69 @@
# Copyright (c) 2008, Willow Garage, Inc.
# All rights reserved.
#
# Software License Agreement (BSD License 2.0)
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the Willow Garage nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription

import launch_ros.actions


def generate_launch_description():
default_rviz = os.path.join(get_package_share_directory('depth_image_proc'),
'launch', 'rviz/disparity.rviz')
return LaunchDescription([
# install realsense from https://github.com/intel/ros2_intel_realsense
launch_ros.actions.Node(
package='realsense_ros2_camera', node_executable='realsense_ros2_camera',
output='screen'),

# composition api_composition, remap the topic
# we use realsense camera for test, realsense not support left and right topic
# so we remap to depth image only for interface test.
launch_ros.actions.Node(
package='composition', node_executable='api_composition', output='screen',
remappings=[('left/image_rect', '/camera/depth/image_rect_raw'),
('right/camera_info', '/camera/depth/camera_info'),
('left/disparity', '/camera/left/disparity')]),

# depth_image_proc::DisparityNode
launch_ros.actions.Node(
package='composition', node_executable='api_composition_cli', output='screen',
arguments=['depth_image_proc', 'depth_image_proc::DisparityNode']),

# TODO: rviz could not display disparity(stereo_msgs)
# run stereo_view for display after image_view be ported
launch_ros.actions.Node(
package='rviz2', node_executable='rviz2', output='screen',
arguments=['--display-config', default_rviz]),
])
66 changes: 66 additions & 0 deletions depth_image_proc/examples/launch/point_cloud_xyz.launch.py
@@ -0,0 +1,66 @@
# Copyright (c) 2008, Willow Garage, Inc.
# All rights reserved.
#
# Software License Agreement (BSD License 2.0)
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the Willow Garage nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription

import launch_ros.actions


def generate_launch_description():
default_rviz = os.path.join(get_package_share_directory('depth_image_proc'),
'launch', 'rviz/point_cloud_xyz.rviz')
return LaunchDescription([
# install realsense from https://github.com/intel/ros2_intel_realsense
launch_ros.actions.Node(
package='realsense_ros2_camera', node_executable='realsense_ros2_camera',
output='screen'),

# composition api_composition, remap the topic
launch_ros.actions.Node(
package='composition', node_executable='api_composition', output='screen',
remappings=[('image_rect', '/camera/depth/image_rect_raw'),
('camera_info', '/camera/depth/camera_info'),
('points', '/camera/depth/points')]),

# depth_image_proc::PointCloudXyzNode
launch_ros.actions.Node(
package='composition', node_executable='api_composition_cli', output='screen',
arguments=['depth_image_proc', 'depth_image_proc::PointCloudXyzNode']),

# rviz
launch_ros.actions.Node(
package='rviz2', node_executable='rviz2', output='screen',
arguments=['--display-config', default_rviz]),
])