Connecting to a ROS Master Over a VPN
Preamble
This is a nice build on from my previous post on creating a VPN server. If you are using ROS and a VPN server it is possible to remotely connect to the ROS master on one of your robots from either another robot or other device. Basically the only requirement is that both systems are clients on the VPN and can run ROS. It also helps if you have provisioned each system with a static IP address, again details are in my previous post on creating a VPN server.
How To
In my example I’ll run through connecting a local laptop to a robot, again both need to be able to run ROS and connected to the same network/ VPN. We’ll assume that the ROS master is already up and running on the robot and we want to use our laptop to connect in and monitor some data with RViz or just in the terminal for now.
Configuration Laptop Side
We need to edit the hosts file on the laptop we want to connect to the robot.
# Laptop
sudo nano /etc/hosts
Add the robot IP and hostname, here I’ve used 10.8.0.12 and “robot_hostname”.
127.0.0.1 localhost
# Robot
10.8.0.12 robot_hostname
Exit and save with Ctrl+x followed by y and hit enter.
Configuration Robot Side
We also need to edit the hosts file on the robot we want to connect to from the laptop.
# Robot
sudo nano /etc/hosts
Add the laptop IP and hostname, here I’ve used 10.8.0.10 and “laptop_hostname”.
127.0.0.1 localhost
# User
10.8.0.10 laptop_hostname
Exit and save with Ctrl+x followed by y and hit enter.
Connecting
# Local Machine
export ROS_MASTER_URI="http://robothostnameorIPaddress:11311"
You should now be able to use rostopic list
and rostopic echo /my_topic
to confirm operation.
Hey you!
Found this useful or interesting?
Consider donating to support.
Any question, comments, corrections or suggestions?
Reach out on the social links below through the buttons.