Remote machine running ROS nodes

博客原文地址: https://www.mikoychinese.top/post/20190921-Remote-machine-running-ROS-nodes/

Prefence:

This document describes how can you launch roslaunch file to run remote machine running ROS nodes.

The following requires you need to meet:

  1. Local machine
  2. Remote machine
  3. ROS_MASTER_URL
1. Build SSH Connection Between Local And Remote:

The way roslaunch-nodes works, needs a valid ssh-connection between the local and the remote machines. To ensure connection, create an authorized-key:

# 1. Creat an ssh-key on local machine.(Because ros node ssh not the linux ssh, so it must choose rsa way.)
ssh-keygen -t rsa
# 2. The following messages you will get:
Enter file in which to save the key (/home/localhost/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):
# 3. Copy the public key into the new machine's authorized_keys file, using the ssh-copy-id command:
# <ssh-key-path> eg: ~/.ssh/id_rsa.pub
ssh-copy-id -i <ssh-key-path> remote-machine-user@remote-machine-ip

# If  Unable to establish ssh connection:
export ROSLAUNCH_SSH_UNKNOWN=1
2. Create An Env-loader Script:

Due to the automated nature of ROS launch, it avoids executing the user's .bashrc on the remote nodes and requires an envirnoment file to assign remote environment variables.

Let's assume that we need to create env-loader for a workspace located under /home/nvidia/workspace:

The following is an example of the env-loader script:

#!/bin/bash

export ROS_IP=172.16.1.102
export ROS_MASTER_URI=http://172.16.1.100:11311

source /root/workspace/ros/devel/setup.bash

exec "$@"

Finally save the above created env-loader script on the remote-machine. Let's assume that we saved the above mentioned env-loader script into /home/nvidia/workspace/devel/remote_env_loader.sh.

3. Create The Roslaunch File:

The following example configure:

<launch>
    <machine
        name="<remote-machine-name>"
        address="<remote-machine-ip>"
        user="<remote-machine-user>"
        password="<ssh-password of the remote-machine>"
        timeout="<timeout-value for the ssh-connection>"
        env-loader="<env-loader file path>"
        ssh-port="<SSH Port>"
        default="true"
    />
    
    <!-- Remote Machine Running Node -->
    <node
        machine="<remote-machine-name>"
        name="<node name>"
        pkg="<node package>"
        type="<node executive>"
    />
    
</launch>    
5. Allow Remote Docker SSH:
  1. First step install openssh-server

    apt-get install openssh-server
    
  2. If you docker run images with parameter '--net=host', the local host ports are your container ports. So you need to change ssh port to connect container.

    vim /etc/ssh/sshd_config
    ########################
    
    # 1. Change Port 22 to Your port.
    Port 22 --> Port 22333
    
    # 2. Change PermitRootLogin to yes.
    PermitRootLogin prohibit-password --> PermitRootLogin yes
    
    # 3. If you want to connect container without root password, change PermitEmptyPasswords to yes.
    PermitEmptyPasswords no --> PermitEmptyPasswords yes
    

    If docker container's root need password to connect, please set new password.

    # Input the root password.
    passwd root
    

    Finally, restart ssh service. service ssh restart

  3. If you docker run images without parameter '--net=host', you need to set the port.

    # <local-host-port>:<container-ssh-port>
    docker run -p 22333:22 <image>
    
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 221,888评论 6 515
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 94,677评论 3 399
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 168,386评论 0 360
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,726评论 1 297
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,729评论 6 397
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 52,337评论 1 310
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,902评论 3 421
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,807评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 46,349评论 1 318
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,439评论 3 340
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,567评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 36,242评论 5 350
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,933评论 3 334
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,420评论 0 24
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,531评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,995评论 3 377
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,585评论 2 359

推荐阅读更多精彩内容