迁移launch文件ROS 1ROS 2 [待校准@6189]
目录
本指南介绍了如何编写XMLlaunch文件以便于从ROS 1迁移。 [待校准@6190]
背景
对ROS 2launch系统及其Python API的描述可以在 Launch System tutorial 中找到。 [待校准@6192]
替换包含标签 [待校准@6269]
为了将一个launch文件包含在一个命名空间下,如在ROS 1中,那么 include
标签必须嵌套在 group
标签中。 [待校准@6270]
<group>
<include file="another_launch_file"/>
</group>
然后,添加 push-ros-namespace
动作标签以指定命名空间,而不是使用 ns
属性: [待校准@6271]
<group>
<push-ros-namespace namespace="my_ns"/>
<include file="another_launch_file"/>
</group>
套料 include
标签下 group
标签只需指定命名空间 [待校准@6272]
替换 [待校准@6273]
关于ROS 1取代的文件可以在 roslaunch XML wiki 中找到。替换语法没有改变,即它仍然遵循 “$ (替换名称arg1 arg2 ...)” 模式。然而,w.r.t.有一些变化。ROS 1: [待校准@6274]
env
andoptenv
tags have been replaced by theenv
tag.$(env <NAME>)
will fail if the environment variable doesn't exist.$(env <NAME> '')
does the same as ROS 1's$(optenv <NAME>)
.$(env <NAME> <DEFAULT>)
does the same as ROS 1's$(env <NAME> <DEFAULT>)
or$(optenv <NAME> <DEFAULT>)
. [待校准@6275][需手动修复的语法]``find`` has been replaced with
find-pkg-share
(substituting the share directory of an installed package). Alternativelyfind-pkg-prefix
will返回已安装包的根目录。 [待校准@6276]有一种新的
exec-in-pkg
替代品。例如: “$ (执行pkg <package_name> <exec_name>)”。 [待校准@6277]有一种新的
find-exec
替代品。 [待校准@6278]arg
has been replaced withvar
. It looks at configurations defined either witharg
orlet
tag. [待校准@6279]eval
anddirname
substitutions没变。 [待校准@6280]不支持``anon`` substitution。 [待校准@6281]
类型推理规则 [待校准@6209]
在 param
标签的 Type inference rules
小节中显示的规则适用于任何属性。例如: [待校准@6282]
<!--Setting a string value to an attribute expecting an int will raise an error.-->
<tag1 attr-expecting-an-int="'1'"/>
<!--Correct version.-->
<tag1 attr-expecting-an-int="1"/>
<!--Setting an integer in an attribute expecting a string will raise an error.-->
<tag2 attr-expecting-a-str="1"/>
<!--Correct version.-->
<tag2 attr-expecting-a-str="'1'"/>
<!--Setting a list of strings in an attribute expecting a string will raise an error.-->
<tag3 attr-expecting-a-str="asd, bsd" str-attr-sep=", "/>
<!--Correct version.-->
<tag3 attr-expecting-a-str="don't use a separator"/>
一些属性接受多个类型,例如 value
属性 param
标签。通常情况下, int
(或 float
) 类型的参数也接受 str
,稍后将被替换,并通过动作试图转换为 int
(或 float
)。 [待校准@6283]