moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
test_basic_integration.test.py
Go to the documentation of this file.
1import launch_testing
2import os
3import sys
4import unittest
5
6from ament_index_python.packages import get_package_share_directory
7from launch import LaunchDescription
8from launch.actions import DeclareLaunchArgument, TimerAction
9from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
10from launch_ros.actions import Node
11from moveit_configs_utils import MoveItConfigsBuilder
12
13sys.path.append(os.path.dirname(__file__))
14from hybrid_planning_common import (
15 generate_common_hybrid_launch_description,
16 load_yaml,
17)
18
19
21 # generate_common_hybrid_launch_description() returns a list of nodes to launch
22 common_launch = generate_common_hybrid_launch_description()
23 moveit_config = (
24 MoveItConfigsBuilder("moveit_resources_panda")
25 .robot_description(file_path="config/panda.urdf.xacro")
26 .to_moveit_configs()
27 )
28
29 hybrid_planning_gtest = Node(
30 executable=PathJoinSubstitution(
31 [LaunchConfiguration("test_binary_dir"), "test_basic_integration"]
32 ),
33 parameters=[
34 moveit_config.to_dict(),
35 ],
36 output="screen",
37 )
38
39 # Static TF
40 static_tf = Node(
41 package="tf2_ros",
42 executable="static_transform_publisher",
43 name="static_transform_publisher",
44 output="log",
45 arguments=["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "world", "panda_link0"],
46 )
47
48 # Publish TF
49 robot_state_publisher = Node(
50 package="robot_state_publisher",
51 executable="robot_state_publisher",
52 name="robot_state_publisher",
53 output="both",
54 parameters=[moveit_config.robot_description],
55 )
56
57 # ros2_control using FakeSystem as hardware
58 ros2_controllers_path = os.path.join(
59 get_package_share_directory("moveit_hybrid_planning"),
60 "config",
61 "demo_controller.yaml",
62 )
63 ros2_control_node = Node(
64 package="controller_manager",
65 executable="ros2_control_node",
66 parameters=[moveit_config.robot_description, ros2_controllers_path],
67 output="screen",
68 )
69
70 joint_state_broadcaster_spawner = Node(
71 package="controller_manager",
72 executable="spawner",
73 arguments=[
74 "joint_state_broadcaster",
75 "--controller-manager",
76 "/controller_manager",
77 ],
78 )
79
80 panda_joint_group_position_controller_spawner = Node(
81 package="controller_manager",
82 executable="spawner",
83 arguments=[
84 "panda_joint_group_position_controller",
85 "-c",
86 "/controller_manager",
87 ],
88 )
89
90 return LaunchDescription(
91 [
92 DeclareLaunchArgument(
93 name="test_binary_dir",
94 description="Binary directory of package "
95 "containing test executables",
96 ),
97 TimerAction(period=2.0, actions=[hybrid_planning_gtest]),
98 launch_testing.actions.ReadyToTest(),
99 ]
100 + common_launch
101 + [
102 static_tf,
103 robot_state_publisher,
104 ros2_control_node,
105 joint_state_broadcaster_spawner,
106 panda_joint_group_position_controller_spawner,
107 ]
108 ), {
109 "hybrid_planning_gtest": hybrid_planning_gtest,
110 }
111
112
113class TestGTestWaitForCompletion(unittest.TestCase):
114 # Waits for test to complete, then waits a bit to make sure result files are generated
115 def test_gtest_run_complete(self, hybrid_planning_gtest):
116 self.proc_info.assertWaitForShutdown(hybrid_planning_gtest, timeout=4000.0)
117
118
119@launch_testing.post_shutdown_test()
120class TestGTestProcessPostShutdown(unittest.TestCase):
121 # Checks if the test has been completed with acceptable exit codes (successful codes)
122 def test_gtest_pass(self, proc_info, hybrid_planning_gtest):
123 launch_testing.asserts.assertExitCodes(proc_info, process=hybrid_planning_gtest)