Skip to content

Instantly share code, notes, and snippets.

@NovoG93
Created April 21, 2022 07:57
Show Gist options
  • Save NovoG93/e9c74c75dcde4e8dc94f58471144135e to your computer and use it in GitHub Desktop.
Save NovoG93/e9c74c75dcde4e8dc94f58471144135e to your computer and use it in GitHub Desktop.
Switching between ROS1 and ROS2 in .bashrc
srROS1()
{
unset ROS_VERSION ROS_PYTHON_VERSION ROS_DOMAIN_ID ROS_LOCALHOST_ONLY ROS_DISTRO
source /opt/ros/noetic/setup.bash
source /home/georg/catkin_ws/devel/setup.bash
source /home/georg/paper_ws/devel/setup.bash
touch /tmp/ros1.tmp
rm -f /tmp/ros2.tmp || true
}
srROS2()
{
unset ROS_VERSION ROS_PYTHON_VERSION ROS_PACKAGE_PATH ROSLISP_PACKAGE_DIRECTORIES ROS_ETC_DIR ROS_MASTER_URI ROS_ROOT ROS_DISTRO
source /opt/ros/foxy/setup.bash
source /home/georg/ros2_ws/install/setup.bash
export ROS_DOMAIN_ID=0 # see: https://docs.ros.org/en/foxy/Concepts/About-Domain-ID.html
touch /tmp/ros2.tmp
rm -f /tmp/ros1.tmp || true
}
if [ -f /tmp/ros2.tmp ]; then
srROS2
else
srROS1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment