日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ros 中的环境变量 ROS_MASTER_URI 和 ROS_HOSTNAME 两三事

發布時間:2024/1/18 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ros 中的环境变量 ROS_MASTER_URI 和 ROS_HOSTNAME 两三事 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

事件背景。我再同一個物理機上開了兩個docker,一個docker負責維護 master 和 一些服務,另一個docker負責調用那些服務。那環境變量應該如何設置?

其實問題就是,多系統的ros應該如何通信?

robot1 192.168.1.1locally running ros-package: control1 subscribing topic2publishing topic1 robot2 192.168.1.2locally running ros-package: control2subscribing topic1publishing topic2

需要一個ros-master來控制整個通信,選擇robot1作為master,因此,在robot1中:

export ROS_MASTER_URI=http://192.168.1.1:11311 export ROS_HOSTNAME=192.168.1.1 或者 export ROS_IP=192.168.1.1 roscore

為了連接到robot1中的master,在robot2中這么設置:

export ROS_MASTER_URI=http://192.168.1.1:11311 (export ROS_IP=192.168.1.2 ) 或者 (export ROS_HOSTNAME=192.168.1.2)

準確回答:

1 兩個設備的?export ROS_HOSTNAME ..?是不需要的。

2 在多個設備之間運行ros節點的時候,僅僅需要運行一個master進程。ROS_MASTER_URI 中必須包含運行master設備的ip(通過roscore或者roslaunch等命令)。因此,該環境變量在所有設備中必須是一模一樣的。然而,ROS_HOSTNAME?or?ROS_IP設置為運行ros節點的本機IP. 所以,他們的值在不同設備間是不同的。

3 如果一臺機器的hostname設置為其他設備不可尋址的值,你就需要設置?ROS_IP?or?ROS_HOSTNAME?環境變量,不需要同時設置,他們是互相排斥的。

ROS_IP?and?ROS_HOSTNAME?are optional environment variable that sets the declared network address of a ROS?Node?or tool. The options are mutually exclusive, if both are set?ROS_HOSTNAME?will take precedence. Use?ROS_IP?if you are specifying an IP address, and?ROS_HOSTNAME?if you are specifying a host name. When a ROS component reports a URI to the master or other components, this value will be used. This setting is only needed in situations where you have multiple addresses for a computer and need to force ROS to a particular one.

With the exception of 'localhost', it does?not?affect the actual bound address as ROS components bind to all available network interfaces. If the value is set to localhost, the ROS component will bind only to the loopback interface. This will prevent remote components from being able to talk to your local component.

官方文檔說明http://wiki.ros.org/ROS/EnvironmentVariables#ROS_IP.2BAC8-ROS_HOSTNAME

總結

以上是生活随笔為你收集整理的ros 中的环境变量 ROS_MASTER_URI 和 ROS_HOSTNAME 两三事的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。