Skip to content

Commit

Permalink
Merge pull request #5 from CoreSenseEU/multiple_systems
Browse files Browse the repository at this point in the history
Support for generating multiple systems
  • Loading branch information
fmrico authored Aug 6, 2024
2 parents b29fd52 + 1107dbb commit 14a5f24
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 30 deletions.
66 changes: 37 additions & 29 deletions rossdl_cmake/cmake/rossdl_generate_system.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
# limitations under the License.


macro(rossdl_generate_system description_file system)
macro(rossdl_generate_system) # description_file systems)
set(ARGN_COPY ${ARGN})
set(description_file "${ARGV0}")
list(REMOVE_AT ARGN_COPY 0)

get_filename_component(_extension ${description_file} LAST_EXT)

if("${_extension}" STREQUAL "")
Expand Down Expand Up @@ -65,7 +69,6 @@ macro(rossdl_generate_system description_file system)
set(RESOURCE_LAUNCH ${ROSSDL_CMAKE_PATH}/share/rossdl_cmake/resources/launcher.py.em)

string(REGEX REPLACE ":([^:]*)$" "/\\1" _abs_file "${_code_tuple}")
set(_launch_out_file ${CMAKE_CURRENT_BINARY_DIR}/launch/${system}.launch.py)

file(READ ${_abs_file} ROSSDL_SYSTEM_DESCRIPTION)
ament_index_register_resource(rossdl_system_descriptions CONTENT ${ROSSDL_SYSTEM_DESCRIPTION})
Expand Down Expand Up @@ -106,32 +109,37 @@ macro(rossdl_generate_system description_file system)
message(STATUS "ROSSDL_SYSTEMS_NO_VOID: " ${ROSSDL_SYSTEMS_NO_VOID})
message(STATUS "ROSSDL_LOCAL_SYSTEMS_NO_VOID: " ${ROSSDL_LOCAL_SYSTEMS_NO_VOID})

add_custom_command(
OUTPUT ${_launch_out_file}
COMMAND ros2
ARGS run rossdl_cmake sdl_generator_launch
--package ${PROJECT_NAME}
--description-file ${_abs_file}
--artifacts ${ROSSDL_ARTIFACTS_NO_VOID}
--local-artifacts ${ROSSDL_LOCAL_ARTIFACTS_NO_VOID}
--systems ${ROSSDL_SYSTEMS_NO_VOID}
--local-systems ${ROSSDL_LOCAL_SYSTEMS_NO_VOID}
--launch-out-file ${_launch_out_file}
--system ${system}
DEPENDS ${_abs_file} ${RESOURCE_LAUNCH}
COMMENT "Generating launcher for ROS 2 System: ${system}"
VERBATIM
)

add_custom_target(file_toucher
COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${_abs_file})

add_custom_target(${PROJECT_NAME}_run ALL
DEPENDS ${_launch_out_file} file_toucher)

install(FILES
${_launch_out_file}
DESTINATION share/${PROJECT_NAME}/launch
)

foreach(system ${ARGN_COPY})
set(_launch_out_file ${CMAKE_CURRENT_BINARY_DIR}/launch/${system}.launch.py)

add_custom_command(
OUTPUT ${_launch_out_file}
COMMAND ros2
ARGS run rossdl_cmake sdl_generator_launch
--package ${PROJECT_NAME}
--description-file ${_abs_file}
--artifacts ${ROSSDL_ARTIFACTS_NO_VOID}
--local-artifacts ${ROSSDL_LOCAL_ARTIFACTS_NO_VOID}
--systems ${ROSSDL_SYSTEMS_NO_VOID}
--local-systems ${ROSSDL_LOCAL_SYSTEMS_NO_VOID}
--launch-out-file ${_launch_out_file}
--system ${system}
DEPENDS ${_abs_file} ${RESOURCE_LAUNCH}
COMMENT "Generating launcher for ROS 2 System: ${system}"
VERBATIM
)

add_custom_target(file_toucher_${system}
COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${_abs_file})

add_custom_target(${PROJECT_NAME}_${system}_run ALL
DEPENDS ${_launch_out_file} file_toucher_${system})

install(FILES
${_launch_out_file}
DESTINATION share/${PROJECT_NAME}/launch
)
endforeach()

endmacro()
2 changes: 1 addition & 1 deletion rossdl_tests/rossdl_simple_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ rossdl_generate_code(
${dependencies}
)


rossdl_generate_system(
"description.rossystem"
"system_1"
"system_2"
)

add_library(${PROJECT_NAME} SHARED
Expand Down

0 comments on commit 14a5f24

Please sign in to comment.