ROS Deep Learning Stereo Image Publisher

Hi,
I have 2 CSI cameras. I first installed the ros deep learning package and to create 2 different nodes for left and right cameras, I copied the video source node and changed the original one as left camera and the copied one as right camera. But the problem is, original one ( left ) works while copied one ( right ) does not work and gives the error ‘there is no file’.

This is the code:

# locate dependencies
find_package(jetson-utils REQUIRED)
find_package(jetson-inference REQUIRED)

find_package(CUDA REQUIRED)
include_directories("${CUDA_INCLUDE_DIRS}")
# detect ROS1 vs ROS2
find_package(catkin QUIET)

if( catkin_FOUND )
	message("detected ROS1 (catkin_make)")

	configure_file(${CMAKE_CURRENT_SOURCE_DIR}/package.ros1.xml ${CMAKE_CURRENT_SOURCE_DIR}/package.xml COPYONLY)

	find_package(catkin REQUIRED COMPONENTS
		image_transport
		roscpp
		sensor_msgs
		vision_msgs
		std_msgs
	)
	 
	catkin_package(
	    LIBRARIES ros_deep_learning_nodelets
	    CATKIN_DEPENDS nodelet roscpp image_transport sensor_msgs
	)

	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")	# enable c++11 (TensorRT requirement)
	include_directories(${catkin_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS})
	add_definitions(-DROS1)

else()
	find_package(ament_cmake QUIET)

	if( ament_cmake_FOUND )
		message("detected ROS2 (ament_cmake)")

		configure_file(${CMAKE_CURRENT_SOURCE_DIR}/package.ros2.xml ${CMAKE_CURRENT_SOURCE_DIR}/package.xml COPYONLY)

		find_package(rclcpp REQUIRED)
		find_package(std_msgs REQUIRED)
		find_package(sensor_msgs REQUIRED)
		find_package(vision_msgs REQUIRED)

		set(CMAKE_CXX_STANDARD 14)
		include_directories(${CUDA_INCLUDE_DIRS})
		add_definitions(-DROS2)

	else()
		message(FATAL_ERROR "could not find either ROS1 (catkin_make) or ROS2 (ament_cmake) packages")
	endif()
endif()

# sources shared across nodes
set(common_src src/image_converter.cpp src/ros_compat.cpp)

# inference nodes
add_executable(imagenet src/node_imagenet.cpp ${common_src})
target_link_libraries(imagenet ${catkin_LIBRARIES} jetson-inference)

add_executable(detectnet src/node_detectnet.cpp ${common_src})
target_link_libraries(detectnet ${catkin_LIBRARIES} jetson-inference)

add_executable(segnet src/node_segnet.cpp ${common_src})
target_link_libraries(segnet ${catkin_LIBRARIES} jetson-inference)

add_executable(video_source_left src/node_video_source_left.cpp ${common_src})
target_link_libraries(video_source_left ${catkin_LIBRARIES} jetson-inference)

add_executable(video_source_right src/node_video_source_right.cpp ${common_src})
target_link_libraries(video_source_right ${catkin_LIBRARIES} jetson-inference)

add_executable(video_output src/node_video_output.cpp ${common_src})
target_link_libraries(video_output ${catkin_LIBRARIES} jetson-inference)

if( catkin_FOUND )
	add_library(ros_deep_learning_nodelets src/nodelet_imagenet.cpp src/image_converter.cpp)
	target_link_libraries(ros_deep_learning_nodelets ${catkin_LIBRARIES} jetson-inference)

	if(catkin_EXPORTED_LIBRARIES)
		add_dependencies(ros_deep_learning_nodelets ${catkin_EXPORTED_LIBRARIES})
	endif()
else()
	ament_target_dependencies(imagenet rclcpp std_msgs sensor_msgs vision_msgs)
	install(TARGETS imagenet DESTINATION lib/${PROJECT_NAME})

	ament_target_dependencies(detectnet rclcpp std_msgs sensor_msgs vision_msgs)
	install(TARGETS detectnet DESTINATION lib/${PROJECT_NAME})

	ament_target_dependencies(segnet rclcpp std_msgs sensor_msgs vision_msgs)
	install(TARGETS segnet DESTINATION lib/${PROJECT_NAME})

	ament_target_dependencies(video_source_left rclcpp std_msgs sensor_msgs vision_msgs)
	install(TARGETS video_source_left DESTINATION lib/${PROJECT_NAME})

        ament_target_dependencies(video_source_right rclcpp std_msgs sensor_msgs vision_msgs)
	install(TARGETS video_source_right DESTINATION lib/${PROJECT_NAME})

	ament_target_dependencies(video_output rclcpp std_msgs sensor_msgs vision_msgs)
	install(TARGETS video_output DESTINATION lib/${PROJECT_NAME})

	install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}/)

	ament_package()
endif()


Thank you!

Hi @sahiinnmeral, what is the error you are getting - is it from cmake or from ros launch?

Also, the video_source node has a resource parameter so you can select what camera it uses, so you don’t need to duplicate the node itself. See here: https://github.com/dusty-nv/ros_deep_learning#video_source-node

Thank you, problem was just a typo.
Now I have a new problem, how can I change the camera mode?

You would need to change the ros param in the launch file or like here: https://github.com/dusty-nv/ros_deep_learning#video-viewer