Skip to content

Commit

Permalink
Merge pull request #4 from CoreSenseEU/fix_launchers
Browse files Browse the repository at this point in the history
Add Launcher support
  • Loading branch information
fmrico authored Aug 6, 2024
2 parents b65b0fb + 8206441 commit b29fd52
Show file tree
Hide file tree
Showing 16 changed files with 303 additions and 55 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ on:
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
container:
image: osrf/ros:humble-desktop
strategy:
matrix:
os: [ubuntu-22.04]
os: [ubuntu-24.04]
fail-fast: false
steps:
- uses: ros-tooling/setup-ros@v0.6
- uses: ros-tooling/setup-ros@0.7.7
with:
required-ros-distributions: humble
- uses: ros-tooling/action-ros-ci@v0.3
required-ros-distributions: rolling
- uses: ros-tooling/action-ros-ci@0.3.13
with:
package-name: rossdl_cmake rossdl_simple_test system_a system_b application_1 application_2 application_3
target-ros2-distro: humble

target-ros2-distro: rolling
colcon-defaults: |
{
"test": {
"parallel-workers" : 1
}
}
22 changes: 12 additions & 10 deletions rossdl_cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ install(
DESTINATION share/${PROJECT_NAME}
)

install(
FILES
tests/description.ros2
tests/description.rossystem
tests/Nodes.hpp.test
tests/Nodes.cpp.test
tests/system_1.launch.py.test
DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
find_package(ament_cmake_pytest REQUIRED)
ament_add_pytest_test(test_rossdl tests/test_rossdl.py)

install(
FILES
tests/description.ros2
tests/description.rossystem
tests/Nodes.hpp.test
tests/Nodes.cpp.test
tests/system_1.launch.py.test
tests/system_2.launch.py.test
DESTINATION share/${PROJECT_NAME}
)

endif()

ament_package(
Expand Down
6 changes: 3 additions & 3 deletions rossdl_cmake/resources/launcher.py.em
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ remappings = get_system_remappings(system_info, arfifacts)
parameters = get_system_parameters(system_info, arfifacts)
}@

from launch_ros.actions import LoadComposableNodes
from launch_ros.actions import ComposableNodeContainer, LoadComposableNodes
from launch_ros.descriptions import ComposableNode
from launch import LaunchDescription
from launch_ros.actions import Node
Expand Down Expand Up @@ -69,9 +69,9 @@ node_name = node[0]
plugin = '@(node[1])',
name = '@(node_name)',
remappings = [
@[ for remap in remappings[node_name]]@
@[ if node_name in remappings.keys()]@[ for remap in remappings[node_name]]@
@(remap),
@[ end for] ],
@[ end for]@[ end if] ],
parameters=[{
@[ if node_name in list(parameters)]@
@[ for parameter in parameters[node_name]]@
Expand Down
2 changes: 2 additions & 0 deletions rossdl_cmake/rossdl_cmake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,13 @@ def generate_launch(package, file_in, launch_in, file_out, system, systems_data,
file_output = StringIO()
content = ''
try:
em.Interpreter._wasProxyInstalled = False
_interpreter = em.Interpreter(
output=file_output,
options={
em.BUFFERED_OPT: True,
em.RAW_OPT: True,
em.OVERRIDE_OPT: False,
})

with open(launch_in, 'r') as h:
Expand Down
4 changes: 2 additions & 2 deletions rossdl_cmake/tests/system_1.launch.py.test
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def generate_launch_description():
],
parameters=[{
'description_label': 'image raw',
'use_sim_time': False,
'use_sim_time': True,
}],
),
ComposableNode(
Expand All @@ -59,7 +59,7 @@ def generate_launch_description():
('/consumer/image_out', '/other_node/image_in'),
],
parameters=[{
'use_sim_time': False,
'use_sim_time': True,
}],
),
])
Expand Down
72 changes: 72 additions & 0 deletions rossdl_cmake/tests/system_2.launch.py.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# generated from rossdl_cmake/resource/launcher.py.em
# DO NOT EDIT THIS FILE
# generated code does not contain a copyright notice


from launch_ros.actions import ComposableNodeContainer, LoadComposableNodes
from launch_ros.descriptions import ComposableNode
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.conditions import IfCondition
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument

def generate_launch_description():

create_container = LaunchConfiguration('create_container')
container_name = LaunchConfiguration('container_name')

declare_create_container_cmd = DeclareLaunchArgument(
'create_container',
default_value='True',
description='Whether run a container')

declare_container_name_cmd = DeclareLaunchArgument(
'container_name',
default_value='rossdl_test_container',
description='Name of the container')

container_cmd = Node(
condition=IfCondition(create_container),
name=container_name,
package='rclcpp_components',
executable='component_container',
output='both',
)

load_composable_nodes = LoadComposableNodes(
target_container=container_name,
composable_node_descriptions=[
ComposableNode(
package = 'rossdl_test',
plugin = 'rossdl_test::ImageFilter',
name = 'image_filter',
remappings = [
('/image_filter/image_out', '/consumer/image_in'),
('/image_filter/description_out', '/consumer/description_in'),
],
parameters=[{
'description_label': 'image compressed',
'use_sim_time': False,
}],
),
ComposableNode(
package = 'rossdl_test',
plugin = 'rossdl_test::Consumer',
name = 'consumer',
remappings = [
],
parameters=[{
'use_sim_time': False,
}],
),
])

ld = LaunchDescription()

ld.add_action(declare_create_container_cmd)
ld.add_action(declare_container_name_cmd)
ld.add_action(container_cmd)
ld.add_action(load_composable_nodes)

return ld
Loading

0 comments on commit b29fd52

Please sign in to comment.