1 from pathlib
import Path
3 from launch
import LaunchContext
4 from launch.actions
import SetLaunchConfiguration
5 from launch.frontend.parse_substitution
import parse_substitution
6 from launch.substitutions
import (
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)
28 xacro =
Xacro([ThisLaunchFileDir(),
"robot.urdf.xacro"])
29 context = LaunchContext()
30 context.extend_locals(
31 {
"current_launch_file_directory": str(Path(__file__).parent) +
"/"}
33 assert xacro.perform(context)
38 PathJoinSubstitution([ThisLaunchFileDir(),
"robot.urdf.xacro"]),
40 (
"test_", LaunchConfiguration(
"myrobot")): [
41 LaunchConfiguration(
"myrobot"),
44 "number": LaunchConfiguration(
"number"),
45 "postfix": LaunchConfiguration(
"postfix"),
48 context = LaunchContext()
49 context.extend_locals(
50 {
"current_launch_file_directory": str(Path(__file__).parent) +
"/"}
52 SetLaunchConfiguration(
"myrobot",
"robot").visit(context)
53 SetLaunchConfiguration(
"number",
"2000").visit(context)
54 SetLaunchConfiguration(
"postfix",
"mypostfix").visit(context)
55 assert xacro.perform(context)
def test_xacro_no_mappings()
def test_xacro_with_mappings()