diff --git a/scripts/build_ros2_workspace.bash b/scripts/build_ros2_workspace.bash index a1994432..4003feff 100755 --- a/scripts/build_ros2_workspace.bash +++ b/scripts/build_ros2_workspace.bash @@ -71,6 +71,7 @@ if [ -z $ros_distro ]; then else # source the ROS2 environment (from arg) source $ros_path + ros_path_sourced=1 fi fi ;; @@ -89,6 +90,7 @@ if [ -z $ros_distro ]; then else # source the ROS2 environment (from arg) source $ros_path + ros_path_sourced=1 fi fi ;; @@ -97,8 +99,11 @@ if [ -z $ros_distro ]; then exit 1 ;; esac - # source the ROS2 environment - source /opt/ros/$ROS_DISTRO/setup.bash + # source only if not already sourced from ros_path + if [ -z $ros_path_sourced ]; then + # source the ROS2 environment + source /opt/ros/$ROS_DISTRO/setup.bash + fi else if [ -z $ros_path ]; then echo "- Warning: You set a ROS 2 manually to be used."