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:
#  eg: ~/.ssh/id_rsa.pub
ssh-copy-id -i  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:


    
    
    
    
    
    
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.

    # :
    docker run -p 22333:22 
    

你可能感兴趣的:(Remote machine running ROS nodes)