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 ],
43 output="screen",
44 )
45
46 panda_arm_controller_spawner = launch_ros.actions.Node(
47 package="controller_manager",
48 executable="spawner",
49 arguments=["panda_arm_controller", "-c", "/controller_manager"],
50 )
51
52 psm_gtest = launch_ros.actions.Node(
53 executable=launch.substitutions.PathJoinSubstitution(
54 [
55 launch.substitutions.LaunchConfiguration("test_binary_dir"),
56 "planning_scene_monitor_test",
57 ]
58 ),
59 parameters=[
60 moveit_config.to_dict(),
61 ],
62 output="screen",
63 )
64
65 return launch.LaunchDescription(
66 [
67 launch.actions.TimerAction(period=2.0, actions=[ros2_control_node]),
68 launch.actions.TimerAction(
69 period=4.0, actions=[joint_state_broadcaster_spawner]
70 ),
71 launch.actions.TimerAction(
72 period=6.0, actions=[panda_arm_controller_spawner]
73 ),
74 launch.actions.TimerAction(period=9.0, actions=[psm_gtest]),
75 launch_testing.actions.ReadyToTest(),
76 ]
77 ), {
78 "psm_gtest": psm_gtest,
79 }
80
81
82class TestGTestWaitForCompletion(unittest.TestCase):
83 @unittest.skip("Flaky test on humble, see moveit2#2821")
84 # Waits for test to complete, then waits a bit to make sure result files are generated
85 def test_gtest_run_complete(self, psm_gtest):
86 self.proc_info.assertWaitForShutdown(psm_gtest, timeout=4000.0)
87
88
89@launch_testing.post_shutdown_test()
90class TestGTestProcessPostShutdown(unittest.TestCase):
91 @unittest.skip("Flaky test on humble, see moveit2#2821")
92 # Checks if the test has been completed with acceptable exit codes (successful codes)
93 def test_gtest_pass(self, proc_info, psm_gtest):
94 launch_testing.asserts.assertExitCodes(proc_info, process=psm_gtest)