Skip to content

Instantly share code, notes, and snippets.

@applecargo
Last active October 15, 2018 02:05
Show Gist options
  • Save applecargo/8712c466744db36f4257ff929d001e97 to your computer and use it in GitHub Desktop.
Save applecargo/8712c466744db36f4257ff929d001e97 to your computer and use it in GitHub Desktop.
ros launch / remote launch setup explained (ubuntu 16.04 / ros kinetic)
<?xml version="1.0"?>
<launch>
<machine name="imgproc" address="ubuntu-imgproc.local" user="ubuntu" timeout="10.0" default="never" env-loader="/home/ubuntu/ros_env.sh"/>
<!-- image processor -->
<node machine="imgproc" pkg="knut_ai_vehicle" type="image_processing.py" name="image_processor" ns="image_processor">
</node>
</launch>
<!--
ROS multiple machines setup. trouble shooting.
- simply, don't rely on avahi-daemon. they are unstable. unreliable. use /etc/hosts with ip.
- don't use ROS_IP & ROS_HOSTNAME. they are confusing. ROS_HOSTNAME has always precedence.
so. steps are like this:
1) bi-directional ping between machines. -> /etc/hosts and reboot. (don't use avahi-daemon's /etc/avahi/hosts.. or expect any automatic thing happens here.)
(master)
127.0.0.1 localhost
127.0.1.1 ubuntu-master.local ubuntu-master
192.168.0.104 ubuntu-imgproc.local ubuntu-imgproc
(slave)
127.0.0.1 localhost
127.0.1.1 ubuntu-imgproc.local ubuntu-imgproc
192.168.0.100 ubuntu-master.local ubuntu-master
useful commands: hostnamectl status / sudo hostnamectl set-hostname hostname
2) bi-directional ssh login -> share a ssh key. and auth. file. + use ssh -oHostKeyAlgorithms='ssh-rsa' hostname to finalize the setup with right encryption(ssh-rsa, which is not a default one for 16.04)
(NOTE on 'ssh-rsa')
ubuntu@ubuntu-imgproc:~$ cat .ssh/known_hosts
|1|bop97M9Wtuhl0luBKiStcjkzSno=|2zWDyhyUPttisJk21Zy2sym2gFE= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGovGfqO16SNqY+6uPgK/p+7gUQDlNea3KlVfj1ASJKV95T/bPUHWnCWCzgUw+aRkcC24z8vNCS++vWXxmtZQt4XpfJxz0uYQTjk01KuIIj/J3pTkLqylpgLP+NsxsjdI6Kz2L8gCevOZAKHY7E+G3DYlNaiLFzfS86gMSWtYyI+0jbI1BMyn6F0HjyzF3aHzDBtkaJSWtIzTNymYCRyIBTmiP9DBqfEW9uMOnOug6AXTNU/TL5nzIVeqfJq1iPqvMtxzgN7RO4rQz7MNTODrg2TRie967pUtkEs/X5kdcx/JDlmdxKLdJezQ+UxIIDptgeaD2mBySt8iQ1y+UwY//
|1|zvFQIUe3hfCumm0OoQmJmoEnIdY=|kJXQY89jigW6rTGdPnyp1zBJVZU= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGovGfqO16SNqY+6uPgK/p+7gUQDlNea3KlVfj1ASJKV95T/bPUHWnCWCzgUw+aRkcC24z8vNCS++vWXxmtZQt4XpfJxz0uYQTjk01KuIIj/J3pTkLqylpgLP+NsxsjdI6Kz2L8gCevOZAKHY7E+G3DYlNaiLFzfS86gMSWtYyI+0jbI1BMyn6F0HjyzF3aHzDBtkaJSWtIzTNymYCRyIBTmiP9DBqfEW9uMOnOug6AXTNU/TL5nzIVeqfJq1iPqvMtxzgN7RO4rQz7MNTODrg2TRie967pUtkEs/X5kdcx/JDlmdxKLdJezQ+UxIIDptgeaD2mBySt8iQ1y+UwY//
3) set environment variables. for master(local):
(... other bashrc script ...)
export ROS_MASTER_URI=http://localhost:11311
export ROS_HOSTNAME=ubuntu-master
(... source ros env. ...)
(NOTE: ROS_HOSTNAME should be 'ubuntu-master'(alias) not 'ubuntu-master.local'(hostname) -> i.e. one that you get when you type cat /etc/hostname)
4) set environment variable + env.loader script for slave(remote):
(... other bashrc script ...)
export ROS_MASTER_URI=http://ubuntu-master.local:11311
export ROS_HOSTNAME=ubuntu-imgproc
(... source ros env. ...)
(NOTE: ROS_HOSTNAME should be 'ubuntu-imgproc'(alias) not 'ubuntu-imgproc.local'(hostname) -> i.e. one that you get when you type cat /etc/hostname)
and env. script
ubuntu@ubuntu-imgproc:~$ cat ros_env.sh
#!/bin/bash
export ROS_MASTER_URI=http://ubuntu-master.local:11311
export ROS_HOSTNAME=ubuntu-imgproc
source /opt/ros/kinetic/setup.bash
source /home/ubuntu/catkin_ws/devel/setup.bash
exec "$@"
5) then start *.launch @ host(master) machine
-->
<!--
UPDATE:
6) to get access of the screen @ remote machine (its own screen)
add 'export DISPLAY=:0' to the env. script
running the node on its own machine has no prob.
but, when remotely launched (through ssh), the node don't know where is the display
so, we need to explicitly tell where it is.
for example:
ubuntu@ubuntu-imgproc:~$ cat ros_env.sh
#!/bin/bash
export ROS_MASTER_URI=http://ubuntu-uav.local:11311
export ROS_HOSTNAME=ubuntu-imgproc
source /opt/ros/kinetic/setup.bash
source /home/ubuntu/catkin_ws/devel/setup.bash
export DISPLAY=:0
exec "$@"
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment