Last active
September 2, 2024 02:39
-
-
Save chfritz/8c2adab45a94e091be77c55b0432ad2e to your computer and use it in GitHub Desktop.
Simple script to setup your machine env to use a remote ROS master
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
#!/bin/bash | |
# Simple script to setup your machine env to use a remote ROS master | |
# example usage: use_robot.sh myrobot | |
# where myrobot is a resolvable hostname or an IP address | |
NORMAL=`tput sgr0 2> /dev/null` | |
GREEN=`tput setaf 2 2> /dev/null` | |
# get the IP of our device we'll use to conect to the host | |
TARGET_IP=$1 | |
IP=`ip route get $TARGET_IP | head -n 1 | sed "s/.*src \(\S*\) .*/\1/"` | |
echo -e "${GREEN}using $1 ($TARGET_IP) via $IP${NORMAL}" | |
export ROS_MASTER_URI=http://$1:11311 | |
export ROS_HOSTNAME=$IP | |
export ROS_IP=$IP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! My robot had a different hostname for all the nodes than expected. By adding the correct hostname and IP to a container's
/etc/hosts
, I was able to successfully listen to the nodes.