From 7fa991135ce1e89e2244ad357918be28e0f1f0a8 Mon Sep 17 00:00:00 2001 From: jbrhm Date: Tue, 22 Oct 2024 14:21:08 -0400 Subject: [PATCH] better launching --- CMakeLists.txt | 6 +++--- cmake/macros.cmake | 9 ++++++--- launch/perception.launch.py | 12 +++++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1a3a1c7..e32b8453 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,7 +258,7 @@ if(ZED_FOUND AND CUDA_FOUND) # rclcpp_components_register_nodes(zed "mrover::ZedWrapper") # set(node_plugins "${node_plugins}mrover::ZedWrapper;$\n") - mrover_add_component(zed ZedWrapper perception/zed_wrapper/*.c* perception/zed_wrapper/pch.hpp) + mrover_add_component(zed perception/zed_wrapper/*.c* perception/zed_wrapper/pch.hpp ZedWrapper) mrover_link_component(zed parameter_utils lie MANIF::manif ${CUDA_LIBRARIES} loop_profiler cuda_compiler_flags) mrover_ament_component(zed rclcpp rclcpp_components sensor_msgs ZED CUDA tf2 tf2_ros) @@ -270,7 +270,7 @@ if(ZED_FOUND AND CUDA_FOUND) target_link_libraries(tensorrt PRIVATE opencv_core opencv_dnn opencv_imgproc lie nvinfer nvonnxparser tbb cuda_compiler_flags) # Object Detector - mrover_add_component(object_detector StereoObjectDetector perception/object_detector/*.c* src/perception/object_detector/pch.hpp) + mrover_add_component(object_detector perception/object_detector/*.c* src/perception/object_detector/pch.hpp StereoObjectDetector ImageObjectDetector) target_compile_options(zed PRIVATE $<$:-std=c++20>) mrover_link_component(object_detector opencv_core opencv_dnn opencv_imgproc lie tbb tensorrt opencv_imgcodecs opencv_highgui loop_profiler parameter_utils cuda_compiler_flags) mrover_ament_component(object_detector rclcpp sensor_msgs rclcpp_components CUDA tf2 tf2_ros) @@ -302,7 +302,7 @@ if (Gst_FOUND AND GstApp_FOUND) target_compile_definitions(websocket_server PUBLIC BOOST_ASIO_NO_DEPRECATED) ament_target_dependencies(websocket_server rclcpp) - mrover_add_component(gst_websocket_streamer GstWebsocketStreamer esw/gst_websocket_streamer/*.c* esw/gst_websocket_streamer/pch.hpp) + mrover_add_component(gst_websocket_streamer esw/gst_websocket_streamer/*.c* esw/gst_websocket_streamer/pch.hpp GstWebsocketStreamer) mrover_link_component(gst_websocket_streamer PkgConfig::Gst PkgConfig::GstApp PkgConfig::LibUdev opencv_core opencv_imgcodecs websocket_server) mrover_ament_component(gst_websocket_streamer rclcpp rclcpp_components sensor_msgs) endif () diff --git a/cmake/macros.cmake b/cmake/macros.cmake index dc553a11..b82632be 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -45,7 +45,7 @@ macro(mrover_add_node name sources) endif () endmacro() -macro(mrover_add_component name class_name sources includes) +macro(mrover_add_component name sources includes) # Create Executable mrover_add_node(${name} ${sources}) rosidl_target_interfaces(${name} ${PROJECT_NAME} "rosidl_typesupport_cpp") @@ -54,9 +54,12 @@ macro(mrover_add_component name class_name sources includes) set(component_name ${name}_component) mrover_add_library(${component_name} ${sources} ${includes} SHARED) rosidl_target_interfaces(${component_name} ${PROJECT_NAME} "rosidl_typesupport_cpp") - rclcpp_components_register_nodes(${component_name} "mrover::${class_name}") + foreach(node ${ARGN}) + message("Registering ${node}") + rclcpp_components_register_nodes(${component_name} "mrover::${node}") + set(node_plugins "${node_plugins}mrover::${node};$\n") + endforeach() target_compile_definitions(${component_name} PRIVATE "COMPOSITION_BUILDING_DLL") - set(node_plugins "${node_plugins}mrover::${class_name};$\n") install(CODE "execute_process( \ COMMAND ${CMAKE_COMMAND} -E create_symlink \ ${CMAKE_CURRENT_LIST_DIR}/../../build/${PROJECT_NAME}/lib${component_name}.so \ diff --git a/launch/perception.launch.py b/launch/perception.launch.py index af7562a9..8d70d56b 100644 --- a/launch/perception.launch.py +++ b/launch/perception.launch.py @@ -21,14 +21,20 @@ def generate_launch_description(): composable_node_descriptions=[ ComposableNode( package="mrover", - plugin="mrover::object_detector_component", + plugin="mrover::StereoObjectDetector", name="object_detector_component", parameters=[Path(get_package_share_directory("mrover"), "config", "object_detector.yaml")], ), ComposableNode( package="mrover", - plugin="mrover::zed_wrapper_component", - name="zed_wrapper_component", + plugin="mrover::ImageObjectDetector", + name="object_detector_component", + parameters=[Path(get_package_share_directory("mrover"), "config", "object_detector.yaml")], + ), + ComposableNode( + package="mrover", + plugin="mrover::ZedWrapper", + name="zed_component", parameters=[Path(get_package_share_directory("mrover"), "config", "zed.yaml")], ), ],