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

Support for generating multiple systems #5

Merged
merged 2 commits into from
Aug 6, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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