Skip to content

Instantly share code, notes, and snippets.

@awesomebytes
Created September 22, 2020 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awesomebytes/a4017372abec0112e041e6f18c30aa1a to your computer and use it in GitHub Desktop.
Save awesomebytes/a4017372abec0112e041e6f18c30aa1a to your computer and use it in GitHub Desktop.
# this is part of .bashrc / .bash_profile
if [[ $(ps aux | grep bin/roscore | grep -v grep) ]]; then
export ROS_MASTER_URI=`python -c "import rosgraph; print(rosgraph.Master('ip_checker').getUri())"`
export ROS_IP=`python -c "import rosgraph; print(rosgraph.Master('ip_checker').getUri().replace('http://','').replace(':11311/',''))"`
export ROS_NETWORK_INTERFACE=`ifconfig | grep $ROS_IP -1 | awk 'NR==1{print $1}' | sed 's/://g'`
else
echo "No roscore found, setting ROS_MASTER_URI and ROS_IP to localhost defaults."
export ROS_MASTER_URI=http://localhost:11311
export ROS_IP=127.0.0.1
export ROS_NETWORK_INTERFACE=lo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment