Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
66 lines (52 loc) · 1.72 KB
/
Copy pathsetup.sh
File metadata and controls
66 lines (52 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
set -euo pipefail
# Usage:
# ./setup.sh [workspace_dir]
# Example:
# ./setup.sh ~/chars_ws
WORKSPACE_DIR="${1:-$HOME/chars_ws}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPOS_FILE="$SCRIPT_DIR/chars-main.repos"
if ! command -v vcs >/dev/null 2>&1; then
echo "Error: vcstool is not installed."
echo "Install it with: sudo apt update && sudo apt install -y python3-vcstool"
exit 1
fi
if ! command -v rosdep >/dev/null 2>&1; then
echo "Error: rosdep is not installed."
echo "Install it with: sudo apt update && sudo apt install -y python3-rosdep"
exit 1
fi
if ! command -v colcon >/dev/null 2>&1; then
echo "Warning: colcon is not installed. Build step instructions will still be shown."
fi
if [[ ! -f "$REPOS_FILE" ]]; then
echo "Error: $REPOS_FILE not found."
exit 1
fi
mkdir -p "$WORKSPACE_DIR/src"
echo "Importing repositories into $WORKSPACE_DIR ..."
vcs import "$WORKSPACE_DIR" < "$REPOS_FILE"
ROS_DISTRO_DEFAULT="${ROS_DISTRO:-humble}"
ROS_SETUP_FILE="/opt/ros/$ROS_DISTRO_DEFAULT/setup.bash"
if [[ -f "$ROS_SETUP_FILE" ]]; then
# shellcheck disable=SC1090
source "$ROS_SETUP_FILE"
else
echo "Warning: $ROS_SETUP_FILE not found."
echo "Set ROS_DISTRO to your distro and make sure ROS 2 is installed before building."
fi
if ! sudo rosdep init >/dev/null 2>&1; then
echo "rosdep already initialized or init skipped."
fi
echo "Updating rosdep indexes ..."
rosdep update
echo "Installing ROS dependencies ..."
rosdep install --from-paths "$WORKSPACE_DIR/src" --ignore-src -r -y
echo
echo "Setup complete. Build with:"
echo " cd $WORKSPACE_DIR"
echo " colcon build --symlink-install"
echo
echo "Then source your workspace:"
echo " source $WORKSPACE_DIR/install/setup.bash"