Created
September 22, 2020 01:13
-
-
Save awesomebytes/a4017372abec0112e041e6f18c30aa1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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