ROS

From Open MAV project

Revision as of 22:26, 23 September 2011 by Viatcheslav (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How to set-up networking correctly

1. In the terminal:
gedit ~/.bashrc
2. Check or copy the following script at the end of the file:
source /opt/ros/electric/setup.bash

# lo - local loop, wlanX - WiFi, ethX - Ethernet
Interface="lo" 
# Interface="wlan0"
# Interface="eth0"

export SELECTED_INTERFACE=$Interface
/sbin/ifconfig $Interface | grep "inet addr" | grep -v "ddr: " | while read a b c ; do echo $b ; done | ( IFS=':' ; while read a b ; do echo $b ; done ) > /tmp/currentIP.tmp
while read line
    do
export SELECTED_IP=$line
    done < /tmp/currentIP.tmp
rm -f /tmp/currentIP.tmp

if [ $Interface == "lo" ]; then
export ROS_HOSTNAME=localhost
else
export ROS_HOSTNAME=$HOSTNAME
fi

export ROS_IP=$SELECTED_IP
if [ $Interface == "lo" ]; then
export ROS_MASTER_URI=http://${ROS_HOSTNAME}:11311
else
export ROS_MASTER_URI=http://yourHostName:11311/
fi

#used for printing out, comment out if not needed
echo SELECTED_INTERFACE is $SELECTED_INTERFACE
echo ROS_HOSTNAME is $ROS_HOSTNAME
echo ROS_IP is $ROS_IP
echo ROS_MASTER_URI is $ROS_MASTER_URI
3. In the terminal:
bash
Personal tools