-
Notifications
You must be signed in to change notification settings - Fork 786
[ros2] make transient local reliable #1033
Changes from 11 commits
4ba6121
00bf7ff
b9a2ba2
d45abff
2effc21
799db47
d4e022c
99ecf21
d98dfe1
61a6fa2
fee09f6
880cf8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Copyright 2020 Open Source Robotics Foundation, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import unittest | ||
|
|
||
| import ament_index_python | ||
|
|
||
| import launch | ||
| import launch.actions | ||
|
|
||
| from launch.actions import IncludeLaunchDescription | ||
| from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
| import launch_testing | ||
| import launch_testing.asserts | ||
| import launch_testing.markers | ||
| import launch_testing.tools | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.mark.launch_test | ||
| @launch_testing.markers.keep_alive | ||
| def generate_test_description(ready_fn): | ||
| return launch.LaunchDescription([ | ||
| launch.actions.DeclareLaunchArgument( | ||
| 'mock_robot_state_publisher', | ||
| description='Path to mock robot state publisher executable', | ||
| ), | ||
| launch.actions.ExecuteProcess( | ||
| cmd=[launch.substitutions.LaunchConfiguration('mock_robot_state_publisher')], | ||
| output='screen' | ||
| ), | ||
| IncludeLaunchDescription( | ||
| PythonLaunchDescriptionSource([ | ||
| ament_index_python.get_package_share_directory('gazebo_ros'), | ||
| '/launch', '/gzserver.launch.py' | ||
| ]) | ||
| ), | ||
| launch.actions.OpaqueFunction(function=lambda context: ready_fn()) | ||
| # launch_testing.actions.ReadyToTest() | ||
|
||
| ]) | ||
|
|
||
|
|
||
| class TestTerminatingProc(unittest.TestCase): | ||
|
|
||
| def test_spawn_entity(self, launch_service, proc_info, proc_output): | ||
| """Test terminating_proc without command line arguments.""" | ||
| print('Running spawn entity test on /mock_robot_description topic') | ||
| entity_spawner_action = launch.actions.ExecuteProcess( | ||
| cmd=['ros2', 'run', 'gazebo_ros', 'spawn_entity.py', '-entity', | ||
| 'mock_robot_state_entity', '-topic', '/mock_robot_description'], | ||
| output='screen' | ||
| ) | ||
| with launch_testing.tools.launch_process( | ||
| launch_service, entity_spawner_action, proc_info, proc_output) as command: | ||
| assert command.wait_for_shutdown(timeout=10) | ||
| assert command.exit_code == launch_testing.asserts.EXIT_OK | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Copyright 2020 Open Source Robotics Foundation, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include <chrono> | ||
| #include <iostream> | ||
|
|
||
| #include "rclcpp/rclcpp.hpp" | ||
|
|
||
| #include "std_msgs/msg/string.hpp" | ||
|
|
||
| using namespace std::chrono_literals; | ||
|
|
||
| int main(int argc, char * argv[]) | ||
| { | ||
| rclcpp::init(argc, argv); | ||
| auto node = rclcpp::Node::make_shared("mock_robot_state_publisher"); | ||
| auto publisher = node->create_publisher<std_msgs::msg::String>( | ||
| "/mock_robot_description", rclcpp::QoS(1).transient_local()); | ||
|
|
||
| std_msgs::msg::String message; | ||
| message.data = "<?xml version='1.0' ?>" | ||
| "<sdf version='1.5'>" | ||
| "<model name='ignored'>" | ||
| "<static>true</static>" | ||
| "<link name='link'>" | ||
| "<visual name='visual'>" | ||
| "<geometry>" | ||
| "<sphere><radius>1.0</radius></sphere>" | ||
| "</geometry>" | ||
| "</visual>" | ||
| "</link>" | ||
| "</model>" | ||
| "</sdf>"; | ||
|
|
||
| RCLCPP_INFO(node->get_logger(), "Publishing on /mock_robot_description"); | ||
| publisher->publish(message); | ||
| rclcpp::spin(node); | ||
| rclcpp::shutdown(); | ||
| return 0; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.