Networking¶
Case 1: Communication with Parrot SLAM Dunk¶
Consider the following setup
- the SLAM DUNK module is connected to ODROID XU4 using Ethernet over USB cable. The SLAM module has the IP
192.168.45.1 - The SLAM module runs
roscoreandROS_MASTER_URI=http://192.168.45.1:11311 - ODROID (Ubuntu 16/ROS Kinetic) detects new interface as
usb0and get an assigned IP from SLAM module. - ODROID also connects to a WiFi router
192.168.0.1through an interfacewlan0with a static IP e.g.192.168.0.118 - The
usb0and thewlan0interfaces are independent - There is a ground station PC that is connected to the WiFi router and has a static IP e.g.
192.168.0.105
Summary of network devices setup¶
SLAMDUNK¶
- IP:
192.168.45.1 - gateway:
192.168.45.1 - netmask:
255.255.255.0
ODROID¶
- IP (usb0):
192.168.45.2 - IP (wlan0):
192.168.0.118 ROS_MASTER_URI=http://192.168.45.1:11311ROS_HOSTNAME=192.168.45.2- Edit
/etc/hosts, and add SLAM DUNK host name (192.168.45.1 slamdunk-00316.local)
PC¶
- IP:
192.168.0.105 - gateway:
192.168.0.1, wifi router’s IP - netmask:
255.255.255.0 ROS_MASTER_URI=http://192.168.45.1:11311ROS_HOSTNAME=192.168.0.105
IP routing¶
We need to route between two networks on the ODROID
- Enable ip forward on ODROID:
- in
/etc/sysctl.conf, uncomment (or add)net.ipv4.ip_forward=1 - add static route on sLAM DUNK module
sudo route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.45.2
- Add static route on PC
sudo route add -net 192.168.45.0 netmask 255.255.255.0 gw 192.168.0.118
- (Optional): On ODROID, you can modify
iptablesas follows (they will re-set after reboot)
sudo iptables -A FORWARD --in-interface usb0 -j ACCEPT
sudo iptables --table nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE
Check if you can ping all devices to each other. Also, check if you can rostopic list and rostopic echo on all three devices.
To make the routing persistent¶
- create a script file in the
/etc/init.d/ folder. - add your route definitions to this file and change it to an executable file (
chmod +x /path/to/file). - run the
update-rc.d <filename> defaultscommand to make the script executable at boot time. - reboot the system and check whether the system adds the routes at startup(
netstat -rn).