ROS2編程基礎(chǔ)課程--Launch

      網(wǎng)友投稿 977 2022-05-30

      Launching/monitoring multiple nodes with Launch

      使用Launch啟動/監(jiān)聽多個(gè)節(jié)點(diǎn)

      ROS 2 launch system?ROS 2?launch啟動系統(tǒng)

      The launch system in ROS 2 is responsible for helping the user describe the configuration of their system and then execute it as described. The configuration of the system includes what programs to run, where to run them, what arguments to pass them, and ROS specific conventions which make it easy to reuse components throughout the system by giving them each different configurations. It is also responsible for monitoring the state of the processes launched, and reporting and/or reacting to changes in the state of those processes.

      ROS 2中的啟動系統(tǒng)負(fù)責(zé)協(xié)助用戶描述其系統(tǒng)的配置,然后按照描述執(zhí)行。系統(tǒng)的配置包括運(yùn)行哪些程序、運(yùn)行它們的位置、傳遞它們的參數(shù)以及ROS特定約定,這些約定使得通過為每個(gè)不同的配置提供組件,可以輕松地在整個(gè)系統(tǒng)中重用組件。它還負(fù)責(zé)監(jiān)控已啟動的流程的狀態(tài),并報(bào)告和/或響應(yīng)這些流程的狀態(tài)變化。

      The ROS 2 Bouncy release includes a framework in which launch files, written in Python, can start and stop different nodes as well as trigger and act on various events. The package providing this framework is?launch_ros, which uses the non-ROS-specific?launch?framework underneath.

      ROS 2 Bouncy及之后版本包含一個(gè)框架,其中用Python編寫的launch文件可以啟動和停止不同的節(jié)點(diǎn),以及觸發(fā)和處理各種事件。提供此框架的launch_ros包使用下面的非ROS特定launch框架。

      The?design document (in review)?details the goal of the design of ROS 2’s launch system (not all functionality is currently available).

      這個(gè)設(shè)計(jì)文件(綜述)詳細(xì)描述ROS 2的launch啟動系統(tǒng)的設(shè)計(jì)目標(biāo)(不是所有的功能是目前可用)。

      Example of ROS 2 launch concepts

      ROS 2?launch啟動概念的例子

      The launch file in?this example?launches two nodes, one of which is a node with a?managed lifecycle?(a “l(fā)ifecycle node”). Lifecycle nodes launched through?launch_ros?automatically emit?events?when they transition between states. The events can then be acted on through the launch framework, e.g. by emitting other events (such as requesting another state transition, which lifecycle nodes launched through?launch_ros?automatically have event handlers for) or triggering other?actions?(e.g. starting another node).

      此示例中的啟動文件啟動兩個(gè)節(jié)點(diǎn),其中一個(gè)節(jié)點(diǎn)是具有托管生命周期的節(jié)點(diǎn)(“生命周期節(jié)點(diǎn)”)。生命周期節(jié)點(diǎn)通過launch_ros在狀態(tài)之間轉(zhuǎn)換時(shí)自動發(fā)出事件來啟動。然后可以通過啟動框架對事件進(jìn)行操作,例如通過發(fā)出其他事件(例如請求另一個(gè)狀態(tài)轉(zhuǎn)換,生命周期節(jié)點(diǎn)通過launch_ros自動啟動事件處理程序)或觸發(fā)其他操作(例如,啟動另一個(gè)節(jié)點(diǎn))。

      In the aforementioned example, various transition requests are requested of the?talker?lifecycle node, and its transition events are reacted to by, for example, launching a?listener?node when the lifecycle talker reaches the appropriate state.

      在前述示例中,請求talker生命周期節(jié)點(diǎn)的各種轉(zhuǎn)換請求,并且通過例如listener在生命周期發(fā)布器達(dá)到適當(dāng)狀態(tài)時(shí)啟動節(jié)點(diǎn)來響應(yīng)其轉(zhuǎn)換事件。

      Usage?用法

      While launch files can be written as standalone scripts, the typical usage in ROS is to have launch files invoked by ROS 2 tools.

      雖然啟動文件可以作為獨(dú)立腳本編寫,但ROS中的典型用法是使用ROS 2工具調(diào)用啟動文件。

      For example,?this launch file?has been designed such that it can be invoked by?ros2?launch:

      例如,此啟動文件的設(shè)計(jì)使其可以通過以下方式調(diào)用:ros2?launch

      ros2 launch demo_nodes_cpp add_two_ints.launch.py

      """Launch a add_two_ints_server and a (synchronous) add_two_ints_client."""

      import launch

      import launch_ros.actions

      def generate_launch_description():

      server = launch_ros.actions.Node(

      package='demo_nodes_cpp', node_executable='add_two_ints_server', output='screen')

      client = launch_ros.actions.Node(

      package='demo_nodes_cpp', node_executable='add_two_ints_client', output='screen')

      return launch.LaunchDescription([

      server,

      client,

      # TODO(wjwwood): replace this with a `required=True|False` option on ExecuteProcess().

      # Shutdown launch when client exits.

      launch.actions.RegisterEventHandler(

      event_handler=launch.event_handlers.OnProcessExit(

      target_action=client,

      on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())],

      )),

      ])

      Documentation?文檔

      The launch documentation?provides more details on concepts that are also used in?launch_ros.

      啟動文檔提供了有關(guān)其中使用的概念的更多詳細(xì)信息launch_ros。

      Additional documentation/examples of capabilities are forthcoming. See?the source code?in the meantime.

      其他文檔/功能示例即將發(fā)布。在此期間查看源代碼。

      Migrating launch files from ROS 1 to ROS 2

      將啟動文件從ROS 1遷移到ROS2

      This tutorial describes how to write XML launch files for an easy migration from ROS 1.

      本教程描述了如何編寫XML啟動文件以便從ROS 1輕松遷移到ROS 2。

      (僅用于ROS 1復(fù)習(xí))

      Background?背景

      A description of the ROS 2 launch system and its Python API can be found in?Launch System tutorial.

      可以在Launch System教程中找到有關(guān)ROS 2啟動系統(tǒng)及其Python API的說明。

      Migrating tags from ROS1 to ROS2

      從ROS1遷移標(biāo)簽ROS2

      launch?啟動

      Available in ROS 1.

      可用于ROS 1。

      launch?is the root element of any ROS 2 launch XML file.

      launch?是任何ROS 2啟動XML文件的根元素。

      node?節(jié)點(diǎn)

      Available in ROS1.

      ROS1中提供。

      Launches a new node.

      啟動一個(gè)新節(jié)點(diǎn)。

      Differences from ROS 1:?與ROS 1的區(qū)別:

      type?attribute is now?executable.

      type屬性現(xiàn)在executable。

      The following attributes aren’t available:?machine,?respawn,?respawn_delay,?clear_params.

      下面的屬性是不可用:machine,respawn,respawn_delay,clear_params。

      Example?示例

      from launch import LaunchDescription

      import launch_ros.actions

      def generate_launch_description():

      return LaunchDescription([

      launch_ros.actions.Node(

      node_namespace= "ros2", package='demo_nodes_cpp', node_executable='talker', output='screen'),

      launch_ros.actions.Node(

      node_namespace= "ros2", package='demo_nodes_cpp', node_executable='listener', output='screen'),

      ])

      param?參數(shù)

      Available in ROS1.

      ROS1中提供。

      Used for passing a parameter to a node.

      用于將參數(shù)傳遞給節(jié)點(diǎn)。

      ROS2編程基礎(chǔ)課程--Launch

      There’s no global parameter concept in ROS 2. For that reason, it can only be used nested in a?node?tag. Some attributes aren’t supported in ROS 2:?type,?textfile,?binfile,?executable,?command.

      ROS 2中沒有全局參數(shù)概念。因此,它只能嵌套在node標(biāo)簽中。某些屬性不支持ROS 2:type、textfile、 binfile、executablecommand。

      Example?示例

      Type inference rules?類型推斷規(guī)則

      Here are some examples of how to write parameters:

      以下是如何編寫參數(shù)的一些示例:

      Parameter grouping?參數(shù)分組

      In ROS 2,?param?tags are allowed to be nested. For example:

      在ROS 2中,param標(biāo)簽允許嵌套。例如:

      That will create two parameters:

      這將創(chuàng)建兩個(gè)參數(shù):

      A?group1.group2.my_param?of value?1, hosted by node?/an_absolute_ns/my_node.

      一個(gè)group1.group2.my_param的值1,由節(jié)點(diǎn)/an_absolute_ns/my_node托管。

      A?group1.another_param?of value?2?hosted by node?/an_absolute_ns/my_node.

      一個(gè)group1.another_param的值2,由節(jié)點(diǎn)/an_absolute_ns/my_node托管。

      It’s also possible to use full parameter names:

      也可以使用完整的參數(shù)名稱:

      rosparam

      Available in ROS1.

      ROS1中提供。

      Loads parameters from a yaml file.

      從yaml文件加載參數(shù)。

      It has been replaced with a?from?atribute in?param?tags.

      它已從from屬性替換param標(biāo)簽。

      Example?示例

      remap?重映射

      Available in ROS 1.

      可用于ROS 1。

      Used to pass remapping rules to a node.

      用于將重映射規(guī)則傳遞給節(jié)點(diǎn)。

      It can only be used within?node?tags.

      它只能在node標(biāo)簽中使用。

      Example?示例

      include?包括

      Available in ROS 1.

      可用于ROS 1。

      Allows including another launch file.

      允許包含另一個(gè)啟動文件。

      Differences from ROS 1:?與ROS 1的區(qū)別:

      Available in ROS 1, included content was scoped. In ROS 2, it’s not. Nest includes in?group?tags to scope them.

      在ROS 1中可用,包含的內(nèi)容是作用域。但在ROS 2中,它不是。Nest包含group標(biāo)記以限定它們。

      ns?attribute is not supported. See example of?push_ros_namespace?tag for a workaround.

      ns屬性不受支持。有關(guān)push_ros_namespace標(biāo)記替換方法,請參考示例。

      arg?tags nested in an?include?tag don’t support conditionals (if?or?unless).

      arg標(biāo)記嵌套在include標(biāo)記中,不支持條件(if或unless)。

      There is no support for nested?env?tags.?set_env?and?unset_env?can be used instead.

      不支持嵌套env標(biāo)記。?set_env并且unset_env可以替代使用。

      Both?clear_params?and?pass_all_args?attributes aren’t supported.

      這兩個(gè)clear_params和pass_all_args屬性不被支持。

      Examples?示例

      See?Replacing an include tag.?請參考替換包含標(biāo)記。

      arg

      Available in ROS 1.

      可用于ROS 1。

      arg?is used for declaring a launch argument, or to pass an argument when using?include?tags.

      arg用于聲明啟動參數(shù),或在使用include標(biāo)記時(shí)傳遞參數(shù)。

      Differences from ROS 1:?與ROS 1的區(qū)別:

      value?attribute is not allowed. Use?let?tag for this.

      value屬性是不允許的。使用let標(biāo)簽。

      doc?is now?description.

      doc現(xiàn)在是description。

      When nested within an?include?tag,?if?and?unless?attributes aren’t allowed.

      當(dāng)嵌套在一個(gè)include標(biāo)簽的范圍內(nèi),if和unless屬性是不允許的。

      Example?示例

      Passing an argument via the command line?通過命令行傳遞參數(shù)

      See?ROS 2 launch tutorial.?請參考ROS 2?launch啟動教程。

      env

      Available in ROS 1.

      可用于ROS 1。

      Sets an environment variable.

      設(shè)置環(huán)境變量。

      It has been replaced with?env,?set_env?and?unset_env:

      它已被替換為env,set_env和unset_env:

      env?can only be used nested in a?node?or?executable?tag.?if?and?unless?tags aren’t supported.

      env只能嵌套在一個(gè)node或executable標(biāo)簽中使用。?不支持if和unless標(biāo)簽。

      set_env?can be nested within the root tag?launch?or in?group?tags. It accepts the same attributes?as?env, and also?if?and?unless?tags.

      set_env可以嵌套在根標(biāo)簽launch或group標(biāo)簽中。它接受與env,if以及unless標(biāo)簽相同的屬性。

      unset_env?unsets an environment variable. It accepts a?name?attribute and conditionals.

      unset_env取消設(shè)置環(huán)境變量。它接受name屬性和條件。

      Example?示例

      group

      Available in ROS 1.

      可用于ROS 1。

      Allows limiting the scope of launch configurations. Usually used together with?let,??include?and?push_ros_namespace?tags.

      允許限制啟動配置的范圍。通常與let,include和push_ros_namespace標(biāo)簽一起使用。

      Differences from ROS 1:?與ROS 1的區(qū)別:

      There is no?ns?attribute. See the new?push_ros_namespace?tag as a workaround.

      沒有ns屬性。將新push_ros_namespace標(biāo)記視為替代方法。

      clear_params?attribute isn’t available.

      clear_params?屬性不可用。

      It doesn’t accept?remap?nor?param?tags as children.

      它不接受remap和param標(biāo)簽作子標(biāo)簽。

      Example?示例

      launch-prefix?configuration affects both?executable?and?node?tags’ actions. This example will use?time?as a prefix if?use_time_prefix_in_talker?argument is?1, only for the talker.

      launch-prefix配置會影響標(biāo)記executable和node標(biāo)記的操作。此示例將time用作use_time_prefix_in_talker參數(shù)的前綴1,僅用于發(fā)布器。

      machine

      It is not supported at the moment.?暫不支持。

      test

      It is not supported at the moment.?暫不支持。

      New tags in ROS 2?ROS 2中的新標(biāo)簽

      set_env and unset_env?set_env和unset_env

      See?env?tag decription.?請參考env標(biāo)簽說明。

      push_ros_namespace

      include?and?group?tags don’t accept an?ns?attribute. This action can be used as a workaround:

      include和group標(biāo)簽不接受ns屬性。此操作可用作解決方法:

      let

      It’s a replacement of?arg?tag with a value attribute.?它是使用value屬性arg標(biāo)記的替換。

      executable

      It allows running any executable.?它允許運(yùn)行任何可執(zhí)行文件

      Example?示例

      Replacing an include tag?替換包含標(biāo)記

      To have exactly the same behavior as Available in ROS 1,?include?tags must be nested in a?group?tag.

      要與ROS 1中的“可用”具有完全相同的行為,include標(biāo)記必須嵌套在group標(biāo)記中。

      To replace the?ns?attribute,?push_ros_namespace?action must be used:

      要替換ns屬性,必須使用push_ros_namespace操作:

      Substitutions?替換

      Documentation about ROS 1’s substitutions can be found in?roslaunch XML wiki. Substitutions syntax hasn’t changed, i.e. it still follows the?$(substitution-name?arg1?arg2?...)?pattern. There are, however, some changes w.r.t. ROS 1:

      有關(guān)ROS 1替換的文檔可以在roslaunch XML wiki中找到。替換語法沒有改變,即它仍然遵循$(substitution-name?arg1?arg2?...)模式。但是,ROS 1有一些變化:

      env?and?optenv?tags have been replaced by the?env?tag.?$(env?)?will fail if the environment variable doesn’t exist.?$(env??'')?does the same as ROS 1’s?$(optenv?).?$(env??)?does the same as ROS?1’s?$(env??)?or?$(optenv??).

      env和optenv標(biāo)簽已被標(biāo)簽env取代。?如果環(huán)境變量$(env?)不存在,則會失敗。?$(env??'') 與ROS 1$(optenv?)相同。?$(env??)與ROS 1$(env??)或 $(optenv??)相同。

      find?has been replaced with?find-pkg.

      find已被find-pkg取代。

      There is a new?exec-in-pkg?substitution. e.g.:?$(exec-in-pkg??).

      有一個(gè)新的exec-in-pkg替代品。例如:$(exec-in-pkg??)。

      There is a new?find-exec?substitution.

      有一個(gè)新的find-exec替代品。

      arg?has been replaced with?var. It looks at configurations defined either with?arg?or?let?tag.

      arg已被var取代。它查看之前使用arg或let標(biāo)記定義的配置。

      eval?and?dirname?substitutions haven’t changed.

      eval和dirname替換沒有改變。

      anon?substitution is not supported.

      anon?不支持替換。

      Type inference rules?類型推斷規(guī)則

      The rules that were shown in?Type?inference?rules?subsection of?param?tag applies to any attribute. For example:

      標(biāo)簽param子部分Type?inference?rules中顯示的規(guī)則適用于任何屬性。例如:

      Some attributes accept more than a single type, for example?value?attribute of?param?tag. It’s usual that parameters that are of type?int?(or?float) also accept an?str, that will be later substituted and tried to convert to an?int?(or?float) by the action.

      某些屬性接受多個(gè)類型,例如param標(biāo)記的value屬性。通常,int類型(或float類型)的參數(shù)也接受?str,稍后將替換并嘗試通過操作轉(zhuǎn)換為int(或float)。

      XML

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      上一篇:四大云原生行業(yè)解決方案之大企業(yè)【我們都是華為云專家】
      下一篇:解讀下一代網(wǎng)絡(luò):算力網(wǎng)絡(luò)正從理想照進(jìn)現(xiàn)實(shí)
      相關(guān)文章
      亚洲成a人片在线观看中文!!!| 亚洲精品无码久久| 亚洲夂夂婷婷色拍WW47| 亚洲综合在线观看视频| 一本色道久久综合亚洲精品| 亚洲精品无码久久久| 亚洲精品一级无码中文字幕| 亚洲午夜爱爱香蕉片| 亚洲精品无码久久不卡| 亚洲精品无码久久毛片| 久久久久亚洲AV成人网人人网站| 亚洲真人日本在线| 伊人久久大香线蕉亚洲五月天| jlzzjlzz亚洲乱熟在线播放| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 国产亚洲情侣久久精品| 精品久久久久久亚洲中文字幕| 国产成人综合亚洲| 亚洲一区二区三区在线视频| 中文字幕精品亚洲无线码一区应用| 亚洲小说区图片区另类春色| 国产亚洲综合久久系列| 亚洲bt加勒比一区二区| 亚洲色av性色在线观无码| 亚洲国产日韩女人aaaaaa毛片在线| 亚洲一区二区三区无码国产| 亚洲色成人网站WWW永久四虎| 亚洲AV无码专区在线观看成人| 亚洲欧美国产日韩av野草社区| 99亚洲乱人伦aⅴ精品| 亚洲国产成人乱码精品女人久久久不卡| 亚洲人成无码久久电影网站| 亚洲老妈激情一区二区三区| 亚洲Aⅴ无码专区在线观看q| 亚洲精品日韩专区silk| 亚洲人成图片网站| 国产亚洲福利一区二区免费看 | 亚洲日韩在线观看| 久久亚洲精品中文字幕三区| 亚洲天堂男人天堂| 久久精品亚洲AV久久久无码|