Skip to content

Commit eb34cbe

Browse files
authored
Add EnableRmwIsolation action for starting rmw_test_fixture (#459)
Signed-off-by: Scott K Logan <[email protected]>
1 parent 9907300 commit eb34cbe

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2025 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from .enable_rmw_isolation import EnableRmwIsolation
16+
17+
__all__ = [
18+
'EnableRmwIsolation',
19+
]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2025 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from typing import List
16+
from typing import Optional
17+
18+
from launch.action import Action
19+
from launch.event import Event
20+
from launch.event_handlers import OnShutdown
21+
from launch.launch_context import LaunchContext
22+
from launch.launch_description_entity import LaunchDescriptionEntity
23+
from launch.some_entities_type import SomeEntitiesType
24+
from rmw_test_fixture_implementation import rmw_test_isolation_start
25+
from rmw_test_fixture_implementation import rmw_test_isolation_stop
26+
27+
28+
class EnableRmwIsolation(Action):
29+
"""Action which enables isolation of ROS communication using rmw_test_fixture."""
30+
31+
def __init__(self, **kwargs) -> None:
32+
"""Create a EnableRmwIsolation action."""
33+
super().__init__(**kwargs)
34+
35+
def __on_shutdown(self, event: Event, context: LaunchContext) -> Optional[SomeEntitiesType]:
36+
rmw_test_isolation_stop()
37+
38+
def execute(self, context: LaunchContext) -> Optional[List[LaunchDescriptionEntity]]:
39+
rmw_test_isolation_start()
40+
context.register_event_handler(OnShutdown(
41+
on_shutdown=self.__on_shutdown))

launch_testing_ros/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<exec_depend>launch_testing</exec_depend>
2020
<exec_depend>launch_ros</exec_depend>
2121
<exec_depend>rclpy</exec_depend>
22+
<exec_depend>rmw_test_fixture_implementation</exec_depend>
2223

2324
<test_depend>ament_copyright</test_depend>
2425
<test_depend>ament_flake8</test_depend>

0 commit comments

Comments
 (0)