moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
planning_scene_monitor.test.py
Go to the documentation of this file.
1import os
2import launch
3import unittest
4import launch_ros
5import launch_testing
6from ament_index_python.packages import get_package_share_directory
7from moveit_configs_utils import MoveItConfigsBuilder
8
9
11 moveit_config = (
12 MoveItConfigsBuilder("moveit_resources_panda")
13 .robot_description(file_path="config/panda.urdf.xacro")
14 .to_moveit_configs()
15 )
16
17 # ros2_control using FakeSystem as hardware
18 ros2_controllers_path = os.path.join(
19 get_package_share_directory("moveit_resources_panda_moveit_config"),
20 "config",
21 "ros2_controllers.yaml",
22 )
23 ros2_control_node = launch_ros.actions.Node(
24 package="controller_manager",
25 executable="ros2_control_node",
26 parameters=[ros2_controllers_path],
27 remappings=[
28 ("/controller_manager/robot_description", "/robot_description"),
29 ],
30 output="screen",
31 )
32
33 joint_state_broadcaster_spawner = launch_ros.actions.Node(
34 package="controller_manager",
35 executable="spawner",
36 arguments=[
37 "joint_state_broadcaster",
38 "--controller-manager-timeout",
39 "300",
40 "--controller-manager",
41 "/controller_manager",
42 "--param-file",
43 ros2_controllers_path,
44 ],
45 output="screen",
46 )
47
48 panda_arm_controller_spawner = launch_ros.actions.Node(
49 package="controller_manager",
50 executable="spawner",
51 arguments=[
52 "panda_arm_controller",
53 "-c",
54 "/controller_manager",
55 "--param-file",
56 ros2_controllers_path,
57 ],
58 )
59
60 psm_gtest = launch_ros.actions.Node(
61 executable=launch.substitutions.PathJoinSubstitution(
62 [
63 launch.substitutions.LaunchConfiguration("test_binary_dir"),
64 "planning_scene_monitor_test",
65 ]
66 ),
67 parameters=[
68 moveit_config.to_dict(),
69 ],
70 output="screen",
71 )
72
73 return launch.LaunchDescription(
74 [
75 launch.actions.TimerAction(period=2.0, actions=[ros2_control_node]),
76 launch.actions.TimerAction(
77 period=4.0, actions=[joint_state_broadcaster_spawner]
78 ),
79 launch.actions.TimerAction(
80 period=6.0, actions=[panda_arm_controller_spawner]
81 ),
82 launch.actions.TimerAction(period=9.0, actions=[psm_gtest]),
83 launch_testing.actions.ReadyToTest(),
84 ]
85 ), {
86 "psm_gtest": psm_gtest,
87 }
88
89
90class TestGTestWaitForCompletion(unittest.TestCase):
91 # Waits for test to complete, then waits a bit to make sure result files are generated
92 def test_gtest_run_complete(self, psm_gtest):
93 self.proc_info.assertWaitForShutdown(psm_gtest, timeout=4000.0)
94
95
96@launch_testing.post_shutdown_test()
97class TestGTestProcessPostShutdown(unittest.TestCase):
98 # Checks if the test has been completed with acceptable exit codes (successful codes)
99 # NOTE: This test currently terminates with exit code 11 in some cases.
100 # Need to further look into this.
101 def test_gtest_pass(self, proc_info, psm_gtest):
102 launch_testing.asserts.assertExitCodes(
103 proc_info, process=psm_gtest, allowable_exit_codes=[0, -11]
104 )