Navigation

    蓝鲸ROS机器人论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    ROS交流群
    ROS Group
    产品服务
    Product Service
    开源代码库
    Github
    官网
    Official website
    技术交流
    Technological exchanges
    激光雷达
    LIDAR
    ROS教程
    ROS Tourials
    深度学习
    Deep Learning
    机器视觉
    Computer Vision

    如何不设置HOST通过ROS远程连接

    ROS教程
    远程通信 robotupstart ros教程
    1
    1
    2188
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • weijiz
      weijiz last edited by weijiz

      在有些情况下我们想要连接远程的master节点是没办法设置hosts文件的。比如在Android上运行rosjava时。这样就导致我们能够发布消息到远程节点,但是却无法订阅远程消息。问题在于默认的ROS_MASTER_URI是http://computer-name:11311。而我们连接的时候是通过IP连接的,这样导致本地节点订阅的是http://xxx.xxx.xxx.xxx:11311,其中xxx.xxx.xxx.xxx是远程机器的IP。这两个不一致,导致无法订阅消息。

      解决方法是把远程的ROS_MASTER_URI也设置成IP的形式。这个可以通过设置ROS_IP变量实现。比如在launch文件内添加

      <env name="ROS_IP" value="xxx.xxx.xxx.xxx" />
      

      但是实际使用的时候远程节点IP可能并不是固定的。这样设置之后一旦IP发生变化,程序就没办法继续运行了。下面介绍一个更好的方法。使用robot_upstart软件包

      安装robot_upstart软件包

      sudo apt-get install ros-kinetic-robot-upstart
      

      安装自启动服务

      rosrun robot_upstart install --interface enp2s0 startup/launch/startup.launch
      

      需要注意的是这里的 --interface参数。这个参数指定网络设备,在程序启动的时候会自动获取这个网络设备的IP然后设置到ROS_IP环境变量。这样ROS_MASTER_URI就会和当前的IP一致。

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2015-2023 BlueWhale community