dusty-nv / ros_deep_learning

Deep learning inference nodes for ROS / ROS2 with support for NVIDIA Jetson and TensorRT
887 stars 258 forks source link

how to use ros_deep_learning package in ros2 (dashing) #39

Open Kimsuhyung opened 4 years ago

Kimsuhyung commented 4 years ago

It says that it can be used in ROS Kinetic or Melodic, But is it not supported in ROS2 Dashing version ?

And I wonder that there is a way to use the jetson-inferenc project in ROS2 Dashing.

If anyone who has tried this in ros2 Dashing version or knows how to do it, Please help !

dusty-nv commented 4 years ago

Hi @Kimsuhyung, I haven't tried it with ROS2 - is ROS2 backwards compatible with ROS1?

Kimsuhyung commented 4 years ago

As far as I know, ros1 and ros2 are compatible.

I modified the ros_deep_learning cmakelist for ros2, but a build error occurs.

The cmakelist I wrote is below

cmake_minimum_required(VERSION 3.5) project(ros_deep_learning)

if(NOT CMAKE_C_STANDARD) set(CMAKE_C_STANDARD 99) endif()

if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif()

############## Package Dependencies ##############

find_package(ament_cmake REQUIRED) find_package(roscpp REQUIRED) find_package(sensor_msgs REQUIRED) find_package(std_msgs REQUIRED)

find_package(jetson-utils REQUIRED) find_package(jetson-inference REQUIRED)

find_package(CUDA REQUIRED)

############## Package Dependencies ##############

add_executable(ros_deep_learning src/ros_deep_learning.cpp src/image_converter.cpp)

target_link_libraries(ros_deep_learning ${jetson-utils_LIBRARIES} ${jetson-inference_LIBRARIES} ${CUDA_LIBRARIES} )

target_include_directories(ros_deep_learning PUBLIC ${CUDA_INCLUDE_DIRS} ${jetson-utils_INCLUDE_DIRS} ${jetson-inference_INCLUDE_DIRS}
)

ament_target_dependencies(ros_deep_learning
rclcpp std_msgs sensor_msgs jetson-utils jetson-inference CUDA )

ament_export_dependencies(ros_deep_learning) ament_export_interfaces(export_ros_deep_learning HAS_LIBRARY_TARGET)

install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION include/${PROJECT_NAME}/ )

install(TARGETS ros_deep_learning EXPORT export_ros_deep_learning ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin )

ament_package()

During the build, I think that jetson-inference function could not be used because jetson-inference package was not found

So, I am wondering if loading and using jetson-inference package from ros2 itself is ok.