|
1 | 1 | import unittest |
2 | | -import os |
3 | | -import yaml |
4 | 2 |
|
| 3 | +import launch_testing |
| 4 | +import pytest |
5 | 5 | from launch import LaunchDescription |
6 | 6 | from launch.actions import DeclareLaunchArgument |
7 | 7 | from launch.substitutions import LaunchConfiguration |
8 | | -import launch_testing |
9 | | -from launch_testing.asserts import assertExitCodes |
10 | | -from launch_testing.util import KeepAliveProc |
11 | | -from launch_testing.actions import ReadyToTest |
12 | | -from ament_index_python.packages import get_package_share_directory |
13 | 8 | from launch_ros.actions import Node |
14 | | - |
15 | | -import pytest |
16 | | - |
17 | | -import xacro |
18 | | - |
19 | | - |
20 | | -def load_file(package_name, file_path): |
21 | | - package_path = get_package_share_directory(package_name) |
22 | | - absolute_file_path = os.path.join(package_path, file_path) |
23 | | - |
24 | | - try: |
25 | | - with open(absolute_file_path, "r") as file: |
26 | | - return file.read() |
27 | | - except EnvironmentError: # parent of IOError, OSError *and* WindowsError where available |
28 | | - return None |
29 | | - |
30 | | - |
31 | | -def load_yaml(package_name, file_path): |
32 | | - package_path = get_package_share_directory(package_name) |
33 | | - absolute_file_path = os.path.join(package_path, file_path) |
34 | | - |
35 | | - try: |
36 | | - with open(absolute_file_path, "r") as file: |
37 | | - return yaml.safe_load(file) |
38 | | - except EnvironmentError: # parent of IOError, OSError *and* WindowsError where available |
39 | | - return None |
| 9 | +from launch_testing.actions import ReadyToTest |
| 10 | +from launch_testing.util import KeepAliveProc |
| 11 | +from moveit_configs_utils import MoveItConfigsBuilder |
40 | 12 |
|
41 | 13 |
|
42 | 14 | @pytest.mark.launch_test |
43 | 15 | def generate_test_description(): |
44 | | - # planning_context |
45 | | - robot_description_config = xacro.process_file( |
46 | | - os.path.join( |
47 | | - get_package_share_directory("moveit_resources_panda_moveit_config"), |
48 | | - "config", |
49 | | - "panda.urdf.xacro", |
50 | | - ) |
| 16 | + moveit_config = ( |
| 17 | + MoveItConfigsBuilder("moveit_resources_panda") |
| 18 | + .robot_description(file_path="config/panda.urdf.xacro") |
| 19 | + .to_moveit_configs() |
51 | 20 | ) |
52 | | - robot_description = {"robot_description": robot_description_config.toxml()} |
53 | | - |
54 | | - robot_description_semantic_config = load_file( |
55 | | - "moveit_resources_panda_moveit_config", "config/panda.srdf" |
56 | | - ) |
57 | | - robot_description_semantic = { |
58 | | - "robot_description_semantic": robot_description_semantic_config |
59 | | - } |
60 | | - |
61 | | - kinematics_yaml = load_yaml( |
62 | | - "moveit_resources_panda_moveit_config", "config/kinematics.yaml" |
63 | | - ) |
64 | | - robot_description_kinematics = {"robot_description_kinematics": kinematics_yaml} |
65 | | - |
66 | | - robot_description_planning = { |
67 | | - "robot_description_planning": load_yaml( |
68 | | - "moveit_resources_panda_moveit_config", "config/joint_limits.yaml" |
69 | | - ) |
70 | | - } |
71 | 21 |
|
72 | 22 | test_exec = Node( |
73 | 23 | executable=[ |
74 | 24 | LaunchConfiguration("test_binary"), |
75 | 25 | ], |
76 | 26 | output="screen", |
77 | 27 | parameters=[ |
78 | | - robot_description, |
79 | | - robot_description_semantic, |
80 | | - robot_description_kinematics, |
81 | | - robot_description_planning, |
| 28 | + moveit_config.robot_description, |
| 29 | + moveit_config.robot_description_semantic, |
| 30 | + moveit_config.robot_description_kinematics, |
| 31 | + moveit_config.joint_limits, |
82 | 32 | ], |
83 | 33 | ) |
84 | 34 |
|
|
0 commit comments