Skip to content

Commit 00fb576

Browse files
committed
Migrate setup script
1 parent b8e5e8f commit 00fb576

2 files changed

Lines changed: 13 additions & 176 deletions

File tree

scripts/ros.plugin.sh

Lines changed: 0 additions & 68 deletions
This file was deleted.

scripts/setup.sh

Lines changed: 13 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,7 @@ set -eEuo pipefail
44
# static/global variables
55
DIR="$(dirname "$(readlink -f "$0")")"
66
BRANCH="${1:-main}"
7-
ROS_DISTRO=${ROS_DISTRO:-"jazzy"}
8-
COLCON_WS="${COLCON_WS:-"$HOME/bitbots_main"}"
97
REPO_URL="git@github.com:bit-bots/bitbots_main.git"
10-
SHELL_CONFIG="$(cat <<EOF
11-
12-
# >>> bit-bots initialize >>>
13-
14-
# Add python pip bins to PATH
15-
export PATH="\$HOME/.local/bin:\$PATH"
16-
17-
# Ignore some deprecation warnings
18-
export PYTHONWARNINGS="ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources,ignore:easy_install command is deprecated,ignore:setup.py install is deprecated"
19-
20-
# Limit ROS 2 communication to localhost (can be overridden when needed)
21-
export ROS_DOMAIN_ID=24
22-
export ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST
23-
24-
# Set the default colcon workspace
25-
export COLCON_WS="\$HOME/bitbots_main"
26-
27-
# Set the default log level for colcon
28-
export COLCON_LOG_LEVEL=30
29-
30-
# Define a log layout
31-
export RCUTILS_COLORIZED_OUTPUT=1
32-
export RCUTILS_CONSOLE_OUTPUT_FORMAT="[{severity}] [{name}]: {message}"
33-
34-
# Set the default Middleware
35-
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
36-
37-
# Load our ros plugin script containing useful functions and aliases for ROS 2 development
38-
if [[ -f \$COLCON_WS/scripts/ros.plugin.sh ]]; then
39-
source \$COLCON_WS/scripts/ros.plugin.sh
40-
fi
41-
42-
# <<< bit-bots initialize <<<
43-
44-
EOF
45-
)"
468

479
ask_question() {
4810
while true; do
@@ -56,34 +18,8 @@ ask_question() {
5618
done
5719
}
5820

59-
setup_ros() {
60-
if (( has_sudo )); then
61-
echo "Setting up ROS 2..."
62-
63-
if [[ ! -f /etc/apt/sources.list.d/ros2.list ]]; then
64-
echo "Adding ROS 2 repository..."
65-
sudo apt install -y curl lsb-release
66-
sudo sh -c "curl -fsSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key > /usr/share/keyrings/ros-archive-keyring.gpg"
67-
sudo sh -c "echo 'deb [signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main' > /etc/apt/sources.list.d/ros2.list"
68-
fi
69-
70-
sudo apt update && sudo apt install -y \
71-
just \
72-
clang-format \
73-
cppcheck \
74-
python3-colcon-clean \
75-
python3-colcon-common-extensions \
76-
python3-pip \
77-
python3-rosdep \
78-
python3-vcstool \
79-
"ros-${ROS_DISTRO}-desktop-full" \
80-
"ros-${ROS_DISTRO}-plotjuggler-ros" \
81-
"ros-${ROS_DISTRO}-rmw-cyclonedds-cpp" \
82-
"ros-${ROS_DISTRO}-rqt-robot-monitor" \
83-
"ros-${ROS_DISTRO}-rqt-runtime-monitor"
84-
else
85-
echo "Please install ROS 2 manually!"
86-
fi
21+
setup_pixi() {
22+
curl -fsSL https://pixi.sh/install.sh | sh
8723
}
8824

8925
setup_repo() {
@@ -103,59 +39,29 @@ setup_repo() {
10339
fi
10440

10541
echo "Installing dependencies..."
106-
if (( has_sudo )); then
107-
just install
108-
else
109-
echo "Cannot use rosdep as it requires sudo."
110-
just install-no-root
111-
fi
42+
$HOME/.pixi/bin/pixi install
11243
}
11344

114-
setup_colcon() {
115-
echo "Installing/Updating colcon extensions..."
116-
117-
# Install/Update colcon extensions / patches
118-
python3 -m pip install --upgrade --user --break-system-packages \
119-
git+https://github.com/timonegk/colcon-core.git@colors \
120-
git+https://github.com/timonegk/colcon-notification.git@colors \
121-
git+https://github.com/timonegk/colcon-output.git@colors
45+
setup_host() {
46+
echo "Setting up system dependencies not covered by pixi. This may require sudo rights. For non-Ubuntu systems, please install the required packages manually."
47+
if (( has_sudo )); then
48+
$meta_dir/scripts/make_basler.sh
49+
$meta_dir/scripts/make_webots.sh
50+
fi
12251
}
12352

12453
build_repository() {
125-
echo "Running full colcon build for bitbots_main repository..."
126-
cd "$COLCON_WS"
127-
54+
echo "Running full colcon build..."
12855
set +u
129-
source "/opt/ros/${ROS_DISTRO}/setup.bash"
130-
131-
just build
132-
}
133-
134-
setup_shell_aliases() {
135-
if ask_question "Do you want to setup/update the Bit-Bots ROS 2 and colcon shell configuration?"; then
136-
local shell_config_file
137-
138-
if [[ "$SHELL" =~ "bash" ]]; then
139-
shell_config_file="$HOME/.bashrc"
140-
elif [[ "$SHELL" =~ "zsh" ]]; then
141-
shell_config_file="$HOME/.zshrc"
142-
else
143-
echo "Your shell is not supported!"
144-
exit 1
145-
fi
146-
147-
if ! grep -q ">>> bit-bots initialize >>>" "$shell_config_file"; then
148-
echo "$SHELL_CONFIG" >> "$shell_config_file"
149-
fi
150-
fi
56+
$HOME/.pixi/bin/pixi run build
15157
}
15258

15359
has_sudo=0
15460
if ask_question "Do you have sudo rights?"; then
15561
has_sudo=1
15662
fi
15763
if (( ! has_sudo )); then
158-
echo "Because, you don't have sudo rights, ensure all necessary ROS 2 packages are installed."
64+
echo "Because, you don't have sudo rights, no host dependencies will be installed."
15965
fi
16066

16167
in_repo=1
@@ -166,6 +72,5 @@ fi
16672

16773
setup_ros
16874
setup_repo
169-
setup_colcon
170-
setup_shell_aliases
75+
setup_host
17176
build_repository

0 commit comments

Comments
 (0)