gggggraziegrazie

graizegrazieさんのやったこと、学んだことを記録する雑記帳です

ROSネットワークの環境変数設定用スクリプト

表記のスクリプトを書いてみました。参考になれば幸いです。

                                    • -

#!/bin/bash
# this script sets ROS network related environemt variables, ROS_IP and ROS_MASTER_URI
IP_ADDR=`ip addr show enp0xxxx | grep "inet\b" | awk '{print $2}' | cut -d/ -f1`

if $IP_ADDR ; then
export ROS_IP=$IP_ADDR
export ROS_MASTER_URI=http://$(getent hosts nxo | cut -d' ' -f 1):11311
else
echo "No Ether IP address detected!"
fi
# this case ethernet is used. if enp0xxx is replaced another device such as wlp0xxx, this script is used for it.

                  • -

#!/bin/bash
# following script unset ROS network related environment variables
export ROS_MASTER_URI=http://localhost:11311
unset ROS_IP