Skip to content

Commit 36abb0c

Browse files
committed
fix: Check if ROS2 is installed and if we all required packages
1 parent 3dd44eb commit 36abb0c

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

scripts/setup_workspace.sh

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -279,33 +279,37 @@ setup_ubuntu() {
279279
lsb-release \
280280
software-properties-common
281281

282-
# Step 2: Install ROS2 if not already installed
282+
# Step 2: Install ROS2 and required packages
283283
log_info "[2/6] Setting up ROS2 $ROS_DISTRO..."
284+
285+
# Check if ROS2 base is installed, if not install it
284286
if ! command -v ros2 &> /dev/null; then
285287
log_info "Installing ROS2 $ROS_DISTRO..."
286288

287289
# Add ROS2 apt repository
288290
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
289291
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
290292

291-
# Install ROS2
292293
sudo apt update
293-
sudo apt install -y \
294-
ros-$ROS_DISTRO-desktop \
295-
ros-$ROS_DISTRO-xacro \
296-
ros-$ROS_DISTRO-joint-state-publisher-gui \
297-
ros-$ROS_DISTRO-robot-state-publisher \
298-
ros-$ROS_DISTRO-hardware-interface \
299-
ros-$ROS_DISTRO-controller-interface \
300-
ros-$ROS_DISTRO-controller-manager \
301-
ros-$ROS_DISTRO-ros2-control \
302-
ros-$ROS_DISTRO-ros2-controllers \
303-
python3-colcon-common-extensions
304-
305-
log_success "ROS2 $ROS_DISTRO installed"
306294
else
307-
log_success "ROS2 already installed"
295+
log_success "ROS2 base already installed"
308296
fi
297+
298+
# Always ensure all required packages are installed (whether ROS2 was already present or not)
299+
log_info "Ensuring all required ROS2 packages are installed..."
300+
sudo apt install -y \
301+
ros-$ROS_DISTRO-desktop \
302+
ros-$ROS_DISTRO-xacro \
303+
ros-$ROS_DISTRO-joint-state-publisher-gui \
304+
ros-$ROS_DISTRO-robot-state-publisher \
305+
ros-$ROS_DISTRO-hardware-interface \
306+
ros-$ROS_DISTRO-controller-interface \
307+
ros-$ROS_DISTRO-controller-manager \
308+
ros-$ROS_DISTRO-ros2-control \
309+
ros-$ROS_DISTRO-ros2-controllers \
310+
python3-colcon-common-extensions
311+
312+
log_success "All required ROS2 packages installed"
309313

310314
# Step 3: Create Python virtual environment
311315
log_info "[3/6] Setting up Python virtual environment..."

0 commit comments

Comments
 (0)