moveit2
The MoveIt Motion Planning Framework for ROS 2.
test_basic_integration.test.py
Go to the documentation of this file.
1 import launch_testing
2 import os
3 import sys
4 import unittest
5 
6 from launch import LaunchDescription
7 from launch.actions import DeclareLaunchArgument, ExecuteProcess, TimerAction
8 from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
9 from launch_ros.actions import Node
10 
11 sys.path.append(os.path.dirname(__file__))
12 from hybrid_planning_common import (
13  generate_common_hybrid_launch_description,
14  get_robot_description,
15  get_robot_description_semantic,
16  load_file,
17  load_yaml,
18 )
19 
20 
22  # generate_common_hybrid_launch_description() returns a list of nodes to launch
24  robot_description = get_robot_description()
25  robot_description_semantic = get_robot_description_semantic()
26 
27  common_hybrid_planning_param = load_yaml(
28  "moveit_hybrid_planning", "config/common_hybrid_planning_params.yaml"
29  )
30 
31  hybrid_planning_gtest = Node(
32  executable=PathJoinSubstitution(
33  [LaunchConfiguration("test_binary_dir"), "test_basic_integration"]
34  ),
35  parameters=[
36  robot_description,
37  robot_description_semantic,
38  common_hybrid_planning_param,
39  ],
40  output="screen",
41  )
42 
43  return LaunchDescription(
44  [
45  DeclareLaunchArgument(
46  name="test_binary_dir",
47  description="Binary directory of package "
48  "containing test executables",
49  ),
50  TimerAction(period=2.0, actions=[hybrid_planning_gtest]),
51  launch_testing.actions.ReadyToTest(),
52  ]
53  + common_launch
54  ), {
55  "hybrid_planning_gtest": hybrid_planning_gtest,
56  }
57 
58 
59 class TestGTestWaitForCompletion(unittest.TestCase):
60  # Waits for test to complete, then waits a bit to make sure result files are generated
61  def test_gtest_run_complete(self, hybrid_planning_gtest):
62  self.proc_info.assertWaitForShutdown(hybrid_planning_gtest, timeout=4000.0)
63 
64 
65 @launch_testing.post_shutdown_test()
66 class TestGTestProcessPostShutdown(unittest.TestCase):
67  # Checks if the test has been completed with acceptable exit codes (successful codes)
68  def test_gtest_pass(self, proc_info, hybrid_planning_gtest):
69  launch_testing.asserts.assertExitCodes(proc_info, process=hybrid_planning_gtest)
def test_gtest_pass(self, proc_info, hybrid_planning_gtest)
def load_yaml(package_name, file_path)