-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobocup_container.def
executable file
·211 lines (168 loc) · 7 KB
/
robocup_container.def
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
##
## RoboCup / LASR-Base Container
## Based on TIAGo OSS Noetic container
##
## PAL proprietary container support untested
##
Bootstrap: localimage
From: ./tiago_noetic_opensource.sif
%post -c /bin/bash
echo $ROS_PACKAGE_PATH $ROS_DISTRO
unset ROS_PACKAGE_PATH ROS_ETC_DIR ROS_ROOT ROS_DISTRO
START=$(date +%s.%N)
##
## Install packages and prepare container
##
# Ensure container is up to date
apt update
apt upgrade -y
# Additional apt packages
apt install ros-noetic-audio-common python3-numpy python3-opencv python3-testresources python3-empy python3-pykdl libasound-dev libportaudio2 libportaudiocpp0 portaudio19-dev ffmpeg ca-certificates curl gnupg bc -y
# Install Node.js v20.x (LTS)
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20 echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
sudo apt-get install nodejs npm -y
# Prepare folder for installing additional dependencies from source
mkdir /deps
###
### Install alternative Python versions from source
###
# Dependencies for Python builds (we want all optional modules)
apt install -y build-essential gdb lcov pkg-config libbz2-dev libffi-dev libgdbm-dev \
libgdbm-compat-dev liblzma-dev libncurses5-dev libreadline6-dev libsqlite3-dev \
libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev
##
## Install Python 3.9 from source
##
# Download sources and extract
PYTHON_VERSION=3.9.18
cd /deps
wget https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz
tar zxvf Python-$PYTHON_VERSION.tgz
cd Python-$PYTHON_VERSION
# Build and install
./configure --with-pydebug --with-ensurepip=install
make -s -j$(nproc)
make install
# Install additional global packages
python3.9 -m pip install pyyaml==6.0.1 rospkg==1.5.0 \
pip==23.2.1 setuptools==68.0.0 wheel==0.41.1
##
## Install Python 3.10 from source
##
# Download sources and extract
PYTHON_VERSION=3.10.9
cd /deps
wget https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz
tar zxvf Python-$PYTHON_VERSION.tgz
cd Python-$PYTHON_VERSION
# Build and install
./configure --with-pydebug --with-ensurepip=install
make -s -j$(nproc)
make install
# Install additional global packages
python3.10 -m pip install pyyaml==6.0.1 rospkg==1.5.0 \
pip==23.2.1 setuptools==68.0.0 wheel==0.41.1
##
## Configure global Python installation
##
# Reconfigure Python symlinks
unlink /usr/bin/python
ln -s /usr/bin/python3.8 /usr/bin/python
unlink /usr/local/bin/python3
# Additional Python packages (stuff we want to preload + commonly need)
python3.8 -m pip install --ignore-installed scipy==1.10.1 open3d==0.17.0 point-cloud-utils==0.30.0 shapely==2.0.3 pykalman==0.9.7
python3.9 -m pip install tensorflow==2.14.0 shapely==2.0.3 pykalman==0.9.7
python3.10 -m pip install torch==2.1.0 torchvision==0.16.0 opencv-python==4.8.1.78 shapely==2.0.3 pykalman==0.9.7
python3.8 -m pip install git+https://github.com/eric-wieser/ros_numpy@74879737c8648f48adb507a5bdf4e51c0d194124
python3.9 -m pip install git+https://github.com/eric-wieser/ros_numpy@74879737c8648f48adb507a5bdf4e51c0d194124
python3.10 -m pip install git+https://github.com/eric-wieser/ros_numpy@74879737c8648f48adb507a5bdf4e51c0d194124
##
## Configure overlay workspace with additional packages
##
# Create workspace
source /opt/ros/noetic/setup.bash
# PAL container
if [ -f "/opt/pal/gallium/setup.bash" ]; then
source /opt/pal/gallium/setup.bash
# Opensource container
else
source /opt/tiago_public_ws/devel/setup.bash
fi
mkdir -p /overlay_ws/src
# Clone catkin_virtualenv
git clone https://github.com/locusrobotics/catkin_virtualenv /overlay_ws/src/catkin_virtualenv
cd /overlay_ws/src/catkin_virtualenv
git reset --hard 4af99703e6c7faf12c5d328dbab346250fd085f7
git clean -df
git fetch --depth=1
# Clone video_stream_opencv
git clone https://github.com/ros-drivers/video_stream_opencv /overlay_ws/src/video_stream_opencv
cd /overlay_ws/src/video_stream_opencv
git reset --hard 65949bdc5c9468d18c51aed9073d020bec892532
git clean -df
git fetch --depth=1
# Build workspace
cd /overlay_ws
catkin build
# Ensure workspace is loaded on container start
#
# This updates /opt/env.sh which is executed on container start,
# this will source the overlay workspace straight after the PAL workspace
# PAL container
if [ -f "/opt/pal/gallium/setup.bash" ]; then
BASE=pal
sed -i '/source \/opt\/pal\/gallium\/setup.bash/a source \/overlay_ws\/devel\/setup.bash' /opt/env.sh
# Opensource container
else
BASE=oss
sed -i '/source \/opt\/tiago_public_ws\/devel\/setup.bash/a source \/overlay_ws\/devel\/setup.bash' /opt/env.sh
fi
##
## Clean up
##
# Remove build folder
rm -r /deps
# Capture build information
VERSION=0005
BUILD_DATE=$(date)
END=$(date +%s.%N)
DIFF=$(printf "%.0f\n" $(echo "$END - $START" | bc))
BUILD_TIME=$(date -ud "@$DIFF" +"$(( $DIFF/3600/24 )) days %H hours %M minutes %S seconds")
echo "RoboCup Container (Version: $VERSION, Bootstrapped from: $BASE, Build date: $BUILD_DATE, Build took: $BUILD_TIME)" >> /.build_info
# Unset variables
unset PYTHON_VERSION ROS_PACKAGE_PATH ROS_ETC_DIR ROS_ROOT ROS_DISTRO START END BASE BUILD_DATE END DIFF BUILD_TIME
%runscript
#!/bin/bash
if [ $# -eq 0 ]; then
export TIAGO_ROBOT="tiago-157c";
echo -e "\e[1;31mNo tiago robot specified.\e[0m Using default $TIAGO_ROBOT."
else
export TIAGO_ROBOT="$1"
if [[ $TIAGO_ROBOT = "rexy" || $TIAGO_ROBOT = "rex" || $TIAGO_ROBOT = "157c" || $TIAGO_ROBOT = "gerard" ]]; then
export TIAGO_ROBOT="tiago-157c";
elif [[ $TIAGO_ROBOT = "local" || $TIAGO_ROBOT = "roslocal" ]]; then
export TIAGO_ROBOT="localhost";
elif [[ $TIAGO_ROBOT = "matteo" || $TIAGO_ROBOT = "144c" || $TIAGO_ROBOT = "frutty" || $TIAGO_ROBOT = "matish" || $TIAGO_ROBOT = "mattish" ]]; then
export TIAGO_ROBOT="tiago-144c";
fi
fi
#echo -e "\e[1;31mSetting up connection to \e[30m\e[1;103m$TIAGO_ROBOT\e[1m.\e[0m"
[[ "$(find /tmp/.tiago_container_update_check -mmin +720 2>/dev/null)" ]] && rm /tmp/.tiago_container_update_check # Remove the lock file if older than 12h. From https://stackoverflow.com/questions/552724/how-do-i-check-in-bash-whether-a-file-was-created-more-than-x-time-ago
if [[ ! -f "/tmp/.tiago_container_update_check" ]]; then
echo "Checking for updates to the $(basename $SINGULARITY_CONTAINER) container..."
bash /opt/check_md5.sh
touch /tmp/.tiago_container_update_check
fi
if [[ $TIAGO_ROBOT = "terminator" ]]; then
export TIAGO_ROBOT="localhost";
echo "Running terminator. This terminal will be unresponsive until terminator is closed."
exec terminator -u --config /opt/terminator_config --title "TIAGo Gallium Apptainer" &>/dev/null
elif [[ $2 = "terminator" ]]; then
echo "Running terminator. This terminal will be unresponsive until terminator is closed."
exec terminator -u --config /opt/terminator_config --title "TIAGo Gallium Apptainer" &>/dev/null
else
exec bash --init-file /opt/env.sh
fi