設定方法

vscodeなどのエディタで~/.bashrcに以下を追加

## ROS ##
LOCAL_IP=`hostname -I | cut -d' ' -f1`
alias noetic='
    source /opt/ros/noetic/setup.bash;
    export ROS_WORKSPACE=${HOME}/catkin_ws;
    export ROS_PACKAGE_PATH=${ROS_WORKSPACE}/:$ROS_PACKAGE_PATH;
    export ROS_IP=f11.local;
    export ROS_MASTER_URI=http://localhost:11311;
    source ~/catkin_ws/devel/setup.bash;
    export PS1="\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]\\[\\033[01;31m\\]<noetic>\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ "
    '
alias foxy='
    source /opt/ros/foxy/setup.bash;
    export ROS_WORKSPACE=${HOME}/ros2_ws;
    source ${ROS_WORKSPACE}/install/local_setup.bash;
    export ROS_LOCALHOST_ONLY=1;
    export ROS_DOMAIN_ID=30;
    export TURTLEBOT3_MODEL=burger;
    export PS1="\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]\\[\\033[01;33m\\]<foxy>\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ "
    '
function ros_src() {
    if [[ $ROS_DISTRO == "noetic" ]]; then
        cd $ROS_WORKSPACE/src;
    elif [[ $ROS_DISTRO == "foxy" ]]; then
        cd $ROS_WORKSPACE/src;
    else
        echo "set ros distribution";
    fi
}
function ros_work() {
    if [[ $ROS_DISTRO == "noetic" ]]; then
        cd $ROS_WORKSPACE;
    elif [[ $ROS_DISTRO == "foxy" ]]; then
        cd $ROS_WORKSPACE;
    else
        echo "set ros distribution";
    fi
}
function ros_make() {
		dir=$PWD;
    cd $ROS_WORKSPACE;
    if [[ $ROS_DISTRO == "noetic" ]]; then
        catkin_make --cmake-args -DCMAKE_BUILD_TYPE=Release;
			  #. devel/setup.zsh;
        . devel/setup.bash;
    elif [[ $ROS_DISTRO == "foxy" ]]; then
        if [ $# -gt 0 ]; then
            colcon build --packages-select $1 --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release;
        else
            colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release;
        fi;
        #    . install/local_setup.zsh;
        source install/setup.bash
    else
        echo "set ros distribution";
    fi;
    cd $dir;
}

Foxyを使う場合

無題の画像.png

noeticを使う場合

無題の画像.png

参考文献

ROS1とROS2の環境変数管理 - Qiita

現在の設定