moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
test_xacro.py
Go to the documentation of this file.
1from pathlib import Path
2
3from launch import LaunchContext
4from launch.actions import SetLaunchConfiguration
5from launch.frontend.parse_substitution import parse_substitution
6from launch.substitutions import (
7 LaunchConfiguration,
8 PathJoinSubstitution,
9 TextSubstitution,
10 ThisLaunchFileDir,
11)
12
14
15
17 subst = parse_substitution(r"$(xacro '$(dirname)/robot.urdf.xacro')")
18 context = LaunchContext()
19 context.extend_locals({"current_launch_file_directory": str(Path(__file__).parent)})
20 assert len(subst) == 1
21 assert isinstance(subst[0].file_path[0], ThisLaunchFileDir)
22 assert isinstance(subst[0].file_path[1], TextSubstitution)
23 assert isinstance(subst[0], Xacro)
24 subst[0].perform(context)
25
26
28 xacro = Xacro([ThisLaunchFileDir(), "robot.urdf.xacro"])
29 context = LaunchContext()
30 context.extend_locals(
31 {"current_launch_file_directory": str(Path(__file__).parent) + "/"}
32 )
33 assert xacro.perform(context)
34
35
37 xacro = Xacro(
38 PathJoinSubstitution([ThisLaunchFileDir(), "robot.urdf.xacro"]),
39 mappings={
40 ("test_", LaunchConfiguration("myrobot")): [
41 LaunchConfiguration("myrobot"),
42 "sadf",
43 ],
44 "number": LaunchConfiguration("number"),
45 "postfix": LaunchConfiguration("postfix"),
46 },
47 )
48 context = LaunchContext()
49 context.extend_locals(
50 {"current_launch_file_directory": str(Path(__file__).parent) + "/"}
51 )
52 SetLaunchConfiguration("myrobot", "robot").visit(context)
53 SetLaunchConfiguration("number", "2000").visit(context)
54 SetLaunchConfiguration("postfix", "mypostfix").visit(context)
55 assert xacro.perform(context)
test_xacro_subst()
Definition test_xacro.py:16
test_xacro_with_mappings()
Definition test_xacro.py:36
test_xacro_no_mappings()
Definition test_xacro.py:27