AS: adding first phase of orientation
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: launch-testing-examples
|
||||
Version: 0.15.3
|
||||
Summary: Examples of simple launch tests
|
||||
Home-page: UNKNOWN
|
||||
Maintainer: Aditya Pande, Shane Loretz
|
||||
Maintainer-email: aditya.pande@openrobotics.org, shane@openrobotics.org
|
||||
License: Apache License 2.0
|
||||
Platform: UNKNOWN
|
||||
|
||||
UNKNOWN
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
README.md
|
||||
package.xml
|
||||
setup.cfg
|
||||
setup.py
|
||||
../../../../build/launch_testing_examples/launch_testing_examples.egg-info/PKG-INFO
|
||||
../../../../build/launch_testing_examples/launch_testing_examples.egg-info/SOURCES.txt
|
||||
../../../../build/launch_testing_examples/launch_testing_examples.egg-info/dependency_links.txt
|
||||
../../../../build/launch_testing_examples/launch_testing_examples.egg-info/entry_points.txt
|
||||
../../../../build/launch_testing_examples/launch_testing_examples.egg-info/requires.txt
|
||||
../../../../build/launch_testing_examples/launch_testing_examples.egg-info/top_level.txt
|
||||
../../../../build/launch_testing_examples/launch_testing_examples.egg-info/zip-safe
|
||||
launch_testing_examples/__init__.py
|
||||
launch_testing_examples/check_msgs_launch_test.py
|
||||
launch_testing_examples/check_multiple_nodes_launch_test.py
|
||||
launch_testing_examples/check_node_launch_test.py
|
||||
launch_testing_examples/hello_world_launch_test.py
|
||||
launch_testing_examples/record_rosbag_launch_test.py
|
||||
launch_testing_examples/set_param_launch_test.py
|
||||
resource/launch_testing_examples
|
||||
test/test_copyright.py
|
||||
test/test_flake8.py
|
||||
test/test_pep257.py
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[console_scripts]
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
setuptools
|
||||
@@ -0,0 +1 @@
|
||||
launch_testing_examples
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,44 @@
|
||||
# Copyright 2021 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 launch
|
||||
import launch.actions
|
||||
import launch_ros.actions
|
||||
import launch_testing.actions
|
||||
import launch_testing.markers
|
||||
from launch_testing_ros import WaitForTopics
|
||||
import pytest
|
||||
from std_msgs.msg import String
|
||||
|
||||
|
||||
@pytest.mark.launch_test
|
||||
@launch_testing.markers.keep_alive
|
||||
def generate_test_description():
|
||||
return launch.LaunchDescription([
|
||||
launch_ros.actions.Node(
|
||||
executable='talker',
|
||||
package='demo_nodes_cpp',
|
||||
name='demo_node_1'
|
||||
),
|
||||
launch_testing.actions.ReadyToTest()
|
||||
])
|
||||
|
||||
|
||||
class TestFixture(unittest.TestCase):
|
||||
|
||||
def test_check_if_msgs_published(self):
|
||||
with WaitForTopics([('chatter', String)], timeout=15.0):
|
||||
print('Topic received messages !')
|
||||
@@ -0,0 +1,152 @@
|
||||
# Copyright 2021 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 random
|
||||
import string
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import launch
|
||||
import launch.actions
|
||||
import launch_ros.actions
|
||||
import launch_testing.actions
|
||||
import launch_testing.markers
|
||||
import pytest
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
|
||||
|
||||
@pytest.mark.launch_test
|
||||
@launch_testing.markers.keep_alive
|
||||
def generate_test_description():
|
||||
launch_actions = []
|
||||
node_names = []
|
||||
|
||||
for i in range(3):
|
||||
launch_actions.append(
|
||||
launch_ros.actions.Node(
|
||||
executable='talker',
|
||||
package='demo_nodes_cpp',
|
||||
name='demo_node_' + str(i)
|
||||
)
|
||||
)
|
||||
node_names.append('demo_node_' + str(i))
|
||||
|
||||
launch_actions.append(launch_testing.actions.ReadyToTest())
|
||||
return launch.LaunchDescription(launch_actions), {'node_list': node_names}
|
||||
|
||||
|
||||
class CheckMultipleNodesLaunched(unittest.TestCase):
|
||||
|
||||
def test_nodes_successful(self, node_list):
|
||||
"""Check if all the nodes were launched correctly."""
|
||||
# Method 1
|
||||
wait_for_nodes_1 = WaitForNodes(node_list, timeout=5.0)
|
||||
assert wait_for_nodes_1.wait()
|
||||
assert wait_for_nodes_1.get_nodes_not_found() == set()
|
||||
wait_for_nodes_1.shutdown()
|
||||
|
||||
# Method 2
|
||||
with WaitForNodes(node_list, timeout=5.0) as wait_for_nodes_2:
|
||||
print('All nodes were found !')
|
||||
assert wait_for_nodes_2.get_nodes_not_found() == set()
|
||||
|
||||
def test_node_does_not_exist(self, node_list):
|
||||
"""Insert a invalid node name that should not exist."""
|
||||
invalid_node_list = node_list + ['invalid_node']
|
||||
|
||||
# Method 1
|
||||
wait_for_nodes_1 = WaitForNodes(invalid_node_list, timeout=1.0)
|
||||
assert not wait_for_nodes_1.wait()
|
||||
assert wait_for_nodes_1.get_nodes_not_found() == {'invalid_node'}
|
||||
wait_for_nodes_1.shutdown()
|
||||
|
||||
# Method 2
|
||||
with pytest.raises(RuntimeError):
|
||||
with WaitForNodes(invalid_node_list, timeout=1.0):
|
||||
pass
|
||||
|
||||
|
||||
# TODO (adityapande-1995): Move WaitForNodes implementation to launch_testing_ros
|
||||
# after https://github.com/ros2/rclpy/issues/831 is resolved
|
||||
class WaitForNodes:
|
||||
"""
|
||||
Wait to discover supplied nodes.
|
||||
|
||||
Example usage:
|
||||
--------------
|
||||
# Method 1, calling wait() and shutdown() manually
|
||||
def method_1():
|
||||
node_list = ['foo', 'bar']
|
||||
wait_for_nodes = WaitForNodes(node_list, timeout=5.0)
|
||||
assert wait_for_nodes.wait()
|
||||
print('Nodes found!')
|
||||
assert wait_for_nodes.get_nodes_not_found() == set()
|
||||
wait_for_nodes.shutdown()
|
||||
|
||||
# Method 2, using the 'with' keyword
|
||||
def method_2():
|
||||
with WaitForNodes(['foo', 'bar'], timeout=5.0) as wait_for_nodes:
|
||||
assert wait_for_nodes.get_nodes_not_found() == set()
|
||||
print('Nodes found!')
|
||||
"""
|
||||
|
||||
def __init__(self, node_names, timeout=5.0):
|
||||
self.node_names = node_names
|
||||
self.timeout = timeout
|
||||
self.__ros_context = rclpy.Context()
|
||||
rclpy.init(context=self.__ros_context)
|
||||
self._prepare_node()
|
||||
|
||||
self.__expected_nodes_set = set(node_names)
|
||||
self.__nodes_found = None
|
||||
|
||||
def _prepare_node(self):
|
||||
self.__node_name = '_test_node_' +\
|
||||
''.join(random.choices(string.ascii_uppercase + string.digits, k=10))
|
||||
self.__ros_node = Node(node_name=self.__node_name, context=self.__ros_context)
|
||||
|
||||
def wait(self):
|
||||
start = time.time()
|
||||
flag = False
|
||||
print('Waiting for nodes')
|
||||
while time.time() - start < self.timeout and not flag:
|
||||
flag = all(name in self.__ros_node.get_node_names() for name in self.node_names)
|
||||
time.sleep(0.3)
|
||||
|
||||
self.__nodes_found = set(self.__ros_node.get_node_names())
|
||||
self.__nodes_found.remove(self.__node_name)
|
||||
return flag
|
||||
|
||||
def shutdown(self):
|
||||
self.__ros_node.destroy_node()
|
||||
rclpy.shutdown(context=self.__ros_context)
|
||||
|
||||
def __enter__(self):
|
||||
if not self.wait():
|
||||
raise RuntimeError('Did not find all nodes !')
|
||||
|
||||
return self
|
||||
|
||||
def __exit__(self, exep_type, exep_value, trace):
|
||||
if exep_type is not None:
|
||||
raise Exception('Exception occured, value: ', exep_value)
|
||||
self.shutdown()
|
||||
|
||||
def get_nodes_found(self):
|
||||
return self.__nodes_found
|
||||
|
||||
def get_nodes_not_found(self):
|
||||
return self.__expected_nodes_set - self.__nodes_found
|
||||
@@ -0,0 +1,61 @@
|
||||
# Copyright 2021 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 time
|
||||
import unittest
|
||||
|
||||
import launch
|
||||
import launch.actions
|
||||
import launch_ros.actions
|
||||
import launch_testing.actions
|
||||
import launch_testing.markers
|
||||
import pytest
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
|
||||
|
||||
@pytest.mark.launch_test
|
||||
@launch_testing.markers.keep_alive
|
||||
def generate_test_description():
|
||||
return launch.LaunchDescription([
|
||||
launch.actions.TimerAction(
|
||||
period=5.0,
|
||||
actions=[
|
||||
launch_ros.actions.Node(
|
||||
executable='talker',
|
||||
package='demo_nodes_cpp',
|
||||
name='demo_node_1'
|
||||
),
|
||||
]),
|
||||
launch_testing.actions.ReadyToTest()
|
||||
])
|
||||
|
||||
|
||||
class TestFixture(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
rclpy.init()
|
||||
self.node = Node('test_node')
|
||||
|
||||
def tearDown(self):
|
||||
self.node.destroy_node()
|
||||
rclpy.shutdown()
|
||||
|
||||
def test_node_start(self, proc_output):
|
||||
start = time.time()
|
||||
found = False
|
||||
while time.time() - start < 20.0 and not found:
|
||||
found = 'demo_node_1' in self.node.get_node_names()
|
||||
time.sleep(0.1)
|
||||
assert found, 'Node not found !'
|
||||
@@ -0,0 +1,58 @@
|
||||
# Copyright 2021 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 launch
|
||||
import launch.actions
|
||||
import launch_testing.actions
|
||||
import launch_testing.markers
|
||||
import pytest
|
||||
|
||||
|
||||
# This function specifies the processes to be run for our test
|
||||
@pytest.mark.launch_test
|
||||
@launch_testing.markers.keep_alive
|
||||
def generate_test_description():
|
||||
"""Launch a simple process to print 'hello_world'."""
|
||||
return launch.LaunchDescription([
|
||||
# Launch a process to test
|
||||
launch.actions.ExecuteProcess(
|
||||
cmd=['echo', 'hello_world'],
|
||||
shell=True
|
||||
),
|
||||
# Tell launch to start the test
|
||||
launch_testing.actions.ReadyToTest()
|
||||
])
|
||||
|
||||
|
||||
# This is our test fixture. Each method is a test case.
|
||||
# These run alongside the processes specified in generate_test_description()
|
||||
class TestHelloWorldProcess(unittest.TestCase):
|
||||
|
||||
def test_read_stdout(self, proc_output):
|
||||
"""Check if 'hello_world' was found in the stdout."""
|
||||
# 'proc_output' is an object added automatically by the launch_testing framework.
|
||||
# It captures the outputs of the processes launched in generate_test_description()
|
||||
# Refer to the documentation for further details.
|
||||
proc_output.assertWaitFor('hello_world', timeout=10, stream='stdout')
|
||||
|
||||
|
||||
# These tests are run after the processes in generate_test_description() have shutdown.
|
||||
@launch_testing.post_shutdown_test()
|
||||
class TestHelloWorldShutdown(unittest.TestCase):
|
||||
|
||||
def test_exit_codes(self, proc_info):
|
||||
"""Check if the processes exited normally."""
|
||||
launch_testing.asserts.assertExitCodes(proc_info)
|
||||
@@ -0,0 +1,84 @@
|
||||
# Copyright 2021 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 os
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import launch
|
||||
import launch.actions
|
||||
import launch_ros.actions
|
||||
import launch_testing.actions
|
||||
import launch_testing.markers
|
||||
import pytest
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
@pytest.mark.launch_test
|
||||
@launch_testing.markers.keep_alive
|
||||
def generate_test_description():
|
||||
rosbag_dir = os.path.join(tempfile.mkdtemp(), 'test_bag')
|
||||
|
||||
node_list = [
|
||||
launch_ros.actions.Node(
|
||||
executable='talker',
|
||||
package='demo_nodes_cpp',
|
||||
name='demo_node'
|
||||
),
|
||||
launch.actions.ExecuteProcess(
|
||||
cmd=['ros2', 'bag', 'record', '-a', '-o', rosbag_dir],
|
||||
output='screen'
|
||||
),
|
||||
launch_testing.actions.ReadyToTest()
|
||||
]
|
||||
|
||||
return launch.LaunchDescription(node_list), {'rosbag_dir': rosbag_dir}
|
||||
|
||||
|
||||
class DelayShutdown(unittest.TestCase):
|
||||
|
||||
def test_delay(self):
|
||||
"""Delay the shutdown of processes so that rosbag can record some messages."""
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
# TODO : Test fails on windows, to be fixed
|
||||
# https://github.com/ros2/rosbag2/issues/926
|
||||
if os.name != 'nt':
|
||||
@launch_testing.post_shutdown_test()
|
||||
class TestFixtureAfterShutdown(unittest.TestCase):
|
||||
|
||||
rosbag_dir = None
|
||||
|
||||
def test_rosbag_record(self, rosbag_dir):
|
||||
"""Check if the rosbag2 recording was successful."""
|
||||
with open(os.path.join(rosbag_dir, 'metadata.yaml'), 'r') as file:
|
||||
metadata = yaml.safe_load(file)
|
||||
assert metadata['rosbag2_bagfile_information']['message_count'] > 0
|
||||
print('The following topics received messages:')
|
||||
for item in metadata['rosbag2_bagfile_information']['topics_with_message_count']:
|
||||
print(item['topic_metadata']['name'], 'recieved ', item['message_count'],
|
||||
' messages')
|
||||
|
||||
TestFixtureAfterShutdown.rosbag_dir = rosbag_dir
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""Delete the rosbag directory."""
|
||||
print('Deleting ', cls.rosbag_dir)
|
||||
shutil.rmtree(cls.rosbag_dir.replace('test_bag', ''))
|
||||
@@ -0,0 +1,68 @@
|
||||
# Copyright 2021 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 os
|
||||
import unittest
|
||||
|
||||
import launch
|
||||
import launch.actions
|
||||
import launch_ros.actions
|
||||
import launch_testing.actions
|
||||
import launch_testing.markers
|
||||
import pytest
|
||||
from rcl_interfaces.srv import SetParameters
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
|
||||
|
||||
@pytest.mark.launch_test
|
||||
@launch_testing.markers.keep_alive
|
||||
def generate_test_description():
|
||||
return launch.LaunchDescription([
|
||||
launch_ros.actions.Node(
|
||||
executable='parameter_blackboard',
|
||||
package='demo_nodes_cpp',
|
||||
name='demo_node_1'
|
||||
),
|
||||
launch_testing.actions.ReadyToTest()
|
||||
])
|
||||
|
||||
|
||||
# TODO: Fix windows failures for this test
|
||||
if os.name != 'nt':
|
||||
class TestFixture(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
rclpy.init()
|
||||
self.node = Node('test_node')
|
||||
|
||||
def tearDown(self):
|
||||
self.node.destroy_node()
|
||||
rclpy.shutdown()
|
||||
|
||||
def test_set_parameter(self, proc_output):
|
||||
parameters = [rclpy.Parameter('demo_parameter_1', value=True).to_parameter_msg()]
|
||||
|
||||
client = self.node.create_client(SetParameters, 'demo_node_1/set_parameters')
|
||||
ready = client.wait_for_service(timeout_sec=15.0)
|
||||
if not ready:
|
||||
raise RuntimeError('Wait for service timed out')
|
||||
|
||||
request = SetParameters.Request()
|
||||
request.parameters = parameters
|
||||
future = client.call_async(request)
|
||||
rclpy.spin_until_future_complete(self.node, future, timeout_sec=15.0)
|
||||
|
||||
response = future.result()
|
||||
assert response.results[0].successful, 'Could not set parameter!'
|
||||
@@ -0,0 +1 @@
|
||||
demo_nodes_cpp:launch:launch_ros:launch_testing:launch_testing_ros:python3-pytest:rcl_interfaces:rclpy:ros2bag:std_msgs
|
||||
@@ -0,0 +1 @@
|
||||
prepend-non-duplicate;AMENT_PREFIX_PATH;
|
||||
@@ -0,0 +1,3 @@
|
||||
# generated from colcon_powershell/shell/template/hook_prepend_value.ps1.em
|
||||
|
||||
colcon_prepend_unique_value AMENT_PREFIX_PATH "$env:COLCON_CURRENT_PREFIX"
|
||||
@@ -0,0 +1,3 @@
|
||||
# generated from colcon_core/shell/template/hook_prepend_value.sh.em
|
||||
|
||||
_colcon_prepend_unique_value AMENT_PREFIX_PATH "$COLCON_CURRENT_PREFIX"
|
||||
@@ -0,0 +1 @@
|
||||
prepend-non-duplicate;PYTHONPATH;lib/python3.10/site-packages
|
||||
@@ -0,0 +1,3 @@
|
||||
# generated from colcon_powershell/shell/template/hook_prepend_value.ps1.em
|
||||
|
||||
colcon_prepend_unique_value PYTHONPATH "$env:COLCON_CURRENT_PREFIX\lib/python3.10/site-packages"
|
||||
@@ -0,0 +1,3 @@
|
||||
# generated from colcon_core/shell/template/hook_prepend_value.sh.em
|
||||
|
||||
_colcon_prepend_unique_value PYTHONPATH "$COLCON_CURRENT_PREFIX/lib/python3.10/site-packages"
|
||||
@@ -0,0 +1,31 @@
|
||||
# generated from colcon_bash/shell/template/package.bash.em
|
||||
|
||||
# This script extends the environment for this package.
|
||||
|
||||
# a bash script is able to determine its own path if necessary
|
||||
if [ -z "$COLCON_CURRENT_PREFIX" ]; then
|
||||
# the prefix is two levels up from the package specific share directory
|
||||
_colcon_package_bash_COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${BASH_SOURCE[0]}"`/../.." > /dev/null && pwd)"
|
||||
else
|
||||
_colcon_package_bash_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX"
|
||||
fi
|
||||
|
||||
# function to source another script with conditional trace output
|
||||
# first argument: the path of the script
|
||||
# additional arguments: arguments to the script
|
||||
_colcon_package_bash_source_script() {
|
||||
if [ -f "$1" ]; then
|
||||
if [ -n "$COLCON_TRACE" ]; then
|
||||
echo "# . \"$1\""
|
||||
fi
|
||||
. "$@"
|
||||
else
|
||||
echo "not found: \"$1\"" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
# source sh script of this package
|
||||
_colcon_package_bash_source_script "$_colcon_package_bash_COLCON_CURRENT_PREFIX/share/launch_testing_examples/package.sh"
|
||||
|
||||
unset _colcon_package_bash_source_script
|
||||
unset _colcon_package_bash_COLCON_CURRENT_PREFIX
|
||||
@@ -0,0 +1,6 @@
|
||||
source;share/launch_testing_examples/hook/pythonpath.ps1
|
||||
source;share/launch_testing_examples/hook/pythonpath.dsv
|
||||
source;share/launch_testing_examples/hook/pythonpath.sh
|
||||
source;share/launch_testing_examples/hook/ament_prefix_path.ps1
|
||||
source;share/launch_testing_examples/hook/ament_prefix_path.dsv
|
||||
source;share/launch_testing_examples/hook/ament_prefix_path.sh
|
||||
@@ -0,0 +1,116 @@
|
||||
# generated from colcon_powershell/shell/template/package.ps1.em
|
||||
|
||||
# function to append a value to a variable
|
||||
# which uses colons as separators
|
||||
# duplicates as well as leading separators are avoided
|
||||
# first argument: the name of the result variable
|
||||
# second argument: the value to be prepended
|
||||
function colcon_append_unique_value {
|
||||
param (
|
||||
$_listname,
|
||||
$_value
|
||||
)
|
||||
|
||||
# get values from variable
|
||||
if (Test-Path Env:$_listname) {
|
||||
$_values=(Get-Item env:$_listname).Value
|
||||
} else {
|
||||
$_values=""
|
||||
}
|
||||
$_duplicate=""
|
||||
# start with no values
|
||||
$_all_values=""
|
||||
# iterate over existing values in the variable
|
||||
if ($_values) {
|
||||
$_values.Split(";") | ForEach {
|
||||
# not an empty string
|
||||
if ($_) {
|
||||
# not a duplicate of _value
|
||||
if ($_ -eq $_value) {
|
||||
$_duplicate="1"
|
||||
}
|
||||
if ($_all_values) {
|
||||
$_all_values="${_all_values};$_"
|
||||
} else {
|
||||
$_all_values="$_"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# append only non-duplicates
|
||||
if (!$_duplicate) {
|
||||
# avoid leading separator
|
||||
if ($_all_values) {
|
||||
$_all_values="${_all_values};${_value}"
|
||||
} else {
|
||||
$_all_values="${_value}"
|
||||
}
|
||||
}
|
||||
|
||||
# export the updated variable
|
||||
Set-Item env:\$_listname -Value "$_all_values"
|
||||
}
|
||||
|
||||
# function to prepend a value to a variable
|
||||
# which uses colons as separators
|
||||
# duplicates as well as trailing separators are avoided
|
||||
# first argument: the name of the result variable
|
||||
# second argument: the value to be prepended
|
||||
function colcon_prepend_unique_value {
|
||||
param (
|
||||
$_listname,
|
||||
$_value
|
||||
)
|
||||
|
||||
# get values from variable
|
||||
if (Test-Path Env:$_listname) {
|
||||
$_values=(Get-Item env:$_listname).Value
|
||||
} else {
|
||||
$_values=""
|
||||
}
|
||||
# start with the new value
|
||||
$_all_values="$_value"
|
||||
# iterate over existing values in the variable
|
||||
if ($_values) {
|
||||
$_values.Split(";") | ForEach {
|
||||
# not an empty string
|
||||
if ($_) {
|
||||
# not a duplicate of _value
|
||||
if ($_ -ne $_value) {
|
||||
# keep non-duplicate values
|
||||
$_all_values="${_all_values};$_"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# export the updated variable
|
||||
Set-Item env:\$_listname -Value "$_all_values"
|
||||
}
|
||||
|
||||
# function to source another script with conditional trace output
|
||||
# first argument: the path of the script
|
||||
# additional arguments: arguments to the script
|
||||
function colcon_package_source_powershell_script {
|
||||
param (
|
||||
$_colcon_package_source_powershell_script
|
||||
)
|
||||
# source script with conditional trace output
|
||||
if (Test-Path $_colcon_package_source_powershell_script) {
|
||||
if ($env:COLCON_TRACE) {
|
||||
echo ". '$_colcon_package_source_powershell_script'"
|
||||
}
|
||||
. "$_colcon_package_source_powershell_script"
|
||||
} else {
|
||||
Write-Error "not found: '$_colcon_package_source_powershell_script'"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# a powershell script is able to determine its own path
|
||||
# the prefix is two levels up from the package specific share directory
|
||||
$env:COLCON_CURRENT_PREFIX=(Get-Item $PSCommandPath).Directory.Parent.Parent.FullName
|
||||
|
||||
colcon_package_source_powershell_script "$env:COLCON_CURRENT_PREFIX\share/launch_testing_examples/hook/pythonpath.ps1"
|
||||
colcon_package_source_powershell_script "$env:COLCON_CURRENT_PREFIX\share/launch_testing_examples/hook/ament_prefix_path.ps1"
|
||||
|
||||
Remove-Item Env:\COLCON_CURRENT_PREFIX
|
||||
@@ -0,0 +1,87 @@
|
||||
# generated from colcon_core/shell/template/package.sh.em
|
||||
|
||||
# This script extends the environment for this package.
|
||||
|
||||
# function to prepend a value to a variable
|
||||
# which uses colons as separators
|
||||
# duplicates as well as trailing separators are avoided
|
||||
# first argument: the name of the result variable
|
||||
# second argument: the value to be prepended
|
||||
_colcon_prepend_unique_value() {
|
||||
# arguments
|
||||
_listname="$1"
|
||||
_value="$2"
|
||||
|
||||
# get values from variable
|
||||
eval _values=\"\$$_listname\"
|
||||
# backup the field separator
|
||||
_colcon_prepend_unique_value_IFS=$IFS
|
||||
IFS=":"
|
||||
# start with the new value
|
||||
_all_values="$_value"
|
||||
# workaround SH_WORD_SPLIT not being set in zsh
|
||||
if [ "$(command -v colcon_zsh_convert_to_array)" ]; then
|
||||
colcon_zsh_convert_to_array _values
|
||||
fi
|
||||
# iterate over existing values in the variable
|
||||
for _item in $_values; do
|
||||
# ignore empty strings
|
||||
if [ -z "$_item" ]; then
|
||||
continue
|
||||
fi
|
||||
# ignore duplicates of _value
|
||||
if [ "$_item" = "$_value" ]; then
|
||||
continue
|
||||
fi
|
||||
# keep non-duplicate values
|
||||
_all_values="$_all_values:$_item"
|
||||
done
|
||||
unset _item
|
||||
# restore the field separator
|
||||
IFS=$_colcon_prepend_unique_value_IFS
|
||||
unset _colcon_prepend_unique_value_IFS
|
||||
# export the updated variable
|
||||
eval export $_listname=\"$_all_values\"
|
||||
unset _all_values
|
||||
unset _values
|
||||
|
||||
unset _value
|
||||
unset _listname
|
||||
}
|
||||
|
||||
# since a plain shell script can't determine its own path when being sourced
|
||||
# either use the provided COLCON_CURRENT_PREFIX
|
||||
# or fall back to the build time prefix (if it exists)
|
||||
_colcon_package_sh_COLCON_CURRENT_PREFIX="/root/ros2_ws/install/launch_testing_examples"
|
||||
if [ -z "$COLCON_CURRENT_PREFIX" ]; then
|
||||
if [ ! -d "$_colcon_package_sh_COLCON_CURRENT_PREFIX" ]; then
|
||||
echo "The build time path \"$_colcon_package_sh_COLCON_CURRENT_PREFIX\" doesn't exist. Either source a script for a different shell or set the environment variable \"COLCON_CURRENT_PREFIX\" explicitly." 1>&2
|
||||
unset _colcon_package_sh_COLCON_CURRENT_PREFIX
|
||||
return 1
|
||||
fi
|
||||
COLCON_CURRENT_PREFIX="$_colcon_package_sh_COLCON_CURRENT_PREFIX"
|
||||
fi
|
||||
unset _colcon_package_sh_COLCON_CURRENT_PREFIX
|
||||
|
||||
# function to source another script with conditional trace output
|
||||
# first argument: the path of the script
|
||||
# additional arguments: arguments to the script
|
||||
_colcon_package_sh_source_script() {
|
||||
if [ -f "$1" ]; then
|
||||
if [ -n "$COLCON_TRACE" ]; then
|
||||
echo "# . \"$1\""
|
||||
fi
|
||||
. "$@"
|
||||
else
|
||||
echo "not found: \"$1\"" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
# source sh hooks
|
||||
_colcon_package_sh_source_script "$COLCON_CURRENT_PREFIX/share/launch_testing_examples/hook/pythonpath.sh"
|
||||
_colcon_package_sh_source_script "$COLCON_CURRENT_PREFIX/share/launch_testing_examples/hook/ament_prefix_path.sh"
|
||||
|
||||
unset _colcon_package_sh_source_script
|
||||
unset COLCON_CURRENT_PREFIX
|
||||
|
||||
# do not unset _colcon_prepend_unique_value since it might be used by non-primary shell hooks
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>launch_testing_examples</name>
|
||||
<version>0.15.3</version>
|
||||
<description>Examples of simple launch tests</description>
|
||||
<maintainer email="sloretz@openrobotics.org">Shane Loretz</maintainer>
|
||||
<maintainer email="aditya.pande@openrobotics.org">Aditya Pande</maintainer>
|
||||
<license>Apache License 2.0</license>
|
||||
|
||||
<author email="aditya.pande@openrobotics.org">Aditya Pande</author>
|
||||
<author email="sloretz@openrobotics.org">Shane Loretz</author>
|
||||
|
||||
<exec_depend>demo_nodes_cpp</exec_depend>
|
||||
<exec_depend>launch</exec_depend>
|
||||
<exec_depend>launch_ros</exec_depend>
|
||||
<exec_depend>launch_testing</exec_depend>
|
||||
<exec_depend>launch_testing_ros</exec_depend>
|
||||
<exec_depend>python3-pytest</exec_depend>
|
||||
<exec_depend>rclpy</exec_depend>
|
||||
<exec_depend>rcl_interfaces</exec_depend>
|
||||
<exec_depend>ros2bag</exec_depend>
|
||||
<exec_depend>std_msgs</exec_depend>
|
||||
|
||||
<test_depend>ament_copyright</test_depend>
|
||||
<test_depend>ament_flake8</test_depend>
|
||||
<test_depend>ament_pep257</test_depend>
|
||||
|
||||
<export>
|
||||
<build_type>ament_python</build_type>
|
||||
</export>
|
||||
</package>
|
||||
@@ -0,0 +1,42 @@
|
||||
# generated from colcon_zsh/shell/template/package.zsh.em
|
||||
|
||||
# This script extends the environment for this package.
|
||||
|
||||
# a zsh script is able to determine its own path if necessary
|
||||
if [ -z "$COLCON_CURRENT_PREFIX" ]; then
|
||||
# the prefix is two levels up from the package specific share directory
|
||||
_colcon_package_zsh_COLCON_CURRENT_PREFIX="$(builtin cd -q "`dirname "${(%):-%N}"`/../.." > /dev/null && pwd)"
|
||||
else
|
||||
_colcon_package_zsh_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX"
|
||||
fi
|
||||
|
||||
# function to source another script with conditional trace output
|
||||
# first argument: the path of the script
|
||||
# additional arguments: arguments to the script
|
||||
_colcon_package_zsh_source_script() {
|
||||
if [ -f "$1" ]; then
|
||||
if [ -n "$COLCON_TRACE" ]; then
|
||||
echo "# . \"$1\""
|
||||
fi
|
||||
. "$@"
|
||||
else
|
||||
echo "not found: \"$1\"" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
# function to convert array-like strings into arrays
|
||||
# to workaround SH_WORD_SPLIT not being set
|
||||
colcon_zsh_convert_to_array() {
|
||||
local _listname=$1
|
||||
local _dollar="$"
|
||||
local _split="{="
|
||||
local _to_array="(\"$_dollar$_split$_listname}\")"
|
||||
eval $_listname=$_to_array
|
||||
}
|
||||
|
||||
# source sh script of this package
|
||||
_colcon_package_zsh_source_script "$_colcon_package_zsh_COLCON_CURRENT_PREFIX/share/launch_testing_examples/package.sh"
|
||||
unset convert_zsh_to_array
|
||||
|
||||
unset _colcon_package_zsh_source_script
|
||||
unset _colcon_package_zsh_COLCON_CURRENT_PREFIX
|
||||
Reference in New Issue
Block a user