Skip to content

Commit 3dff4d4

Browse files
authored
Disable ROS first time setup by default (#290)
1 parent 1cfdc1c commit 3dff4d4

File tree

4 files changed

+60
-73
lines changed

4 files changed

+60
-73
lines changed

docker/Dockerfile.base

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y -o Dpkg::Option
2828
ros-humble-ros2-controllers \
2929
ros-humble-rqt-common-plugins \
3030
ros-humble-webots-ros2 \
31-
ros-humble-dynamixel-workbench-toolbox \
31+
ros-humble-dynamixel-workbench-toolbox \
3232
ros-humble-behaviortree-cpp \
3333
libopencv-dev \
3434
python3-pip \
@@ -43,7 +43,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y -o Dpkg::Option
4343
vim \
4444
rsync \
4545
dialog \
46-
fish
46+
fish
4747

4848

4949

@@ -58,7 +58,7 @@ RUN su memristor -c 'code --install-extension eamodio.gitlens' && \
5858
su memristor -c 'code --install-extension ms-vscode.cpptools-extension-pack' && \
5959
su memristor -c 'code --install-extension usernamehw.errorlens' && \
6060
su memristor -c 'code --install-extension redhat.vscode-xml' && \
61-
su memristor -c 'code --install-extension ms-iot.vscode-ros'
61+
su memristor -c 'code --install-extension ms-iot.vscode-ros'
6262

6363

6464

@@ -69,7 +69,7 @@ RUN su memristor -c 'curl -fsSL https://code-server.dev/install.sh | sh' && \
6969
su memristor -c 'code-server --install-extension ms-vscode.cpptools-extension-pack' && \
7070
su memristor -c 'code-server --install-extension usernamehw.errorlens' && \
7171
su memristor -c 'code-server --install-extension redhat.vscode-xml' && \
72-
su memristor -c 'code-server --install-extension ms-iot.vscode-ros'
72+
su memristor -c 'code-server --install-extension ms-iot.vscode-ros'
7373

7474
# Webots
7575
RUN curl -L -o /tmp/webots.deb \

docker/Makefile

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
MAKEFLAGS+=--silent
12
UID:=$(shell id -u)
23
DOCKER_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
34
PROJECT_DIR:=$(shell dirname ${DOCKER_DIR})
@@ -7,23 +8,28 @@ IMAGE=ghcr.io/memristor/mep3
78

89
.PHONY: all
910

10-
all: destroy test-nvidia run setup-default exec start-code-server
11+
all: destroy test-nvidia run setup-default
12+
13+
colors:
14+
$(eval NC=\033[1;0m)
15+
$(eval RED=\033[1;31m)
16+
$(eval GREEN=\033[1;32m)
17+
$(eval BOLD=\033[1;37m)
1118

1219
vnc:
1320
$(eval FLAVOR=vnc)
1421
$(eval IMAGE=ghcr.io/memristor/mep3-vnc)
15-
@true
22+
true
1623

1724
build:
1825
echo ${NO_CACHE_ARG}
19-
@DOCKER_BUILDKIT=1 docker build ${DOCKER_DIR} -f ${DOCKER_DIR}/Dockerfile.base -t mep3 ${DOCKER_ARGS} --build-arg UID=${UID}
20-
@[ ${FLAVOR} != 'devel' ] && \
26+
DOCKER_BUILDKIT=1 docker build ${DOCKER_DIR} -f ${DOCKER_DIR}/Dockerfile.base -t mep3 ${DOCKER_ARGS} --build-arg UID=${UID}
27+
[ ${FLAVOR} != 'devel' ] && \
2128
DOCKER_BUILDKIT=1 docker build ${DOCKER_DIR} -f ${DOCKER_DIR}/Dockerfile.${FLAVOR} -t ${IMAGE} ${DOCKER_ARGS} || \
2229
true
2330

24-
run:
25-
@${MAKE} -s test-nvidia
26-
@docker run \
31+
run: test-nvidia
32+
docker run \
2733
--net=host \
2834
--ipc=host \
2935
--cap-add SYS_ADMIN \
@@ -37,42 +43,37 @@ run:
3743
-v /dev/dri:/dev/dri:ro \
3844
-v /dev:/dev:rw \
3945
-v ${PROJECT_DIR}:/memristor/ros2_ws/src/mep3:rw \
40-
-d -it ${IMAGE}
41-
42-
test-nvidia:
43-
$(eval NC=\033[1;0m)
44-
$(eval RED=\033[1;31m)
45-
$(eval GREEN=\033[1;32m)
46+
-d -it ${IMAGE} 1>/dev/null
4647

47-
@lspci | grep -qi nvidia && base64 --decode massage | unxz || true
48-
49-
@docker run --rm \
48+
test-nvidia: colors
49+
lspci | grep -qi nvidia && base64 --decode massage | unxz || true
50+
docker run --rm \
5051
-e NVIDIA_DRIVER_CAPABILITIES=all ${NVIDIA_GPU} \
5152
-e DISPLAY=${DISPLAY} \
5253
${IMAGE} | grep -qi 'nvidia' && \
5354
printf '%b\n' "${RED}Detected NVIDIA GPU in system, but missing packets, look up NVIDIA GPU section in README!\n${NC}" || \
54-
printf '%b\n' "${GREEN}Everything set up!${NC}"
55+
true
5556

5657
start-code-server:
57-
@docker exec -d -it mep3-${FLAVOR} bash -c 'pgrep code-server || code-server /memristor/ros2_ws/src/mep3' && \
58+
docker exec -d -it mep3-${FLAVOR} bash -c 'pgrep code-server || code-server /memristor/ros2_ws/src/mep3' && \
5859
xdg-open 'localhost:31415?folder=/memristor/ros2_ws/src/mep3'
5960

6061
stop-code-server:
61-
@docker exec -it mep3-${FLAVOR} pkill -f code-server
62+
docker exec -it mep3-${FLAVOR} pkill -f code-server
6263

6364
exec:
64-
@docker exec -it mep3-${FLAVOR} bash
65+
docker exec -it mep3-${FLAVOR} bash
6566

6667
destroy:
67-
@docker container kill mep3-${FLAVOR} || true
68-
@docker container rm -f mep3-${FLAVOR} || true
68+
docker container kill mep3-${FLAVOR} 1>/dev/null || true
69+
docker container rm -f mep3-${FLAVOR} 1>/dev/null || true
6970

70-
setup-default:
71-
@docker exec -it mep3-${FLAVOR} sh -c '/usr/bin/setup.sh --all'
72-
@echo 'Restarting mep3-${FLAVOR} container...'
73-
@docker restart mep3-${FLAVOR}
71+
setup-default: colors
72+
docker exec -it mep3-${FLAVOR} sh -c '/usr/bin/setup.sh --default'
73+
printf '%b\n%b\n' "${GREEN}Default setup complete!${NC}" \
74+
"Run ${BOLD}make exec${NC} or ${BOLD}docker exec -it mep3-${FLAVOR}${NC} to access the container"
7475

75-
setup-interactive:
76-
@docker exec -it mep3-${FLAVOR} sh -c '/usr/bin/setup.sh --all --interactive'
77-
@echo 'Restarting mep3-${FLAVOR} container...'
78-
@docker restart mep3-${FLAVOR}
76+
setup-interactive: colors
77+
docker exec -it mep3-${FLAVOR} sh -c '/usr/bin/setup.sh --interactive'
78+
printf '%b\n%b\n' "${GREEN}Interactive setup complete!${NC}" \
79+
"Run ${BOLD}make exec${NC} or ${BOLD}docker exec -it mep3-${FLAVOR}${NC} to access the container"

docker/config/bashrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
export WEBOTS_HOME=/usr/local/webots
22
export USERNAME=default
3-
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
3+
if uname -v | grep -qi 'ubuntu'; then
4+
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
5+
fi
46

57
alias cb='colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Debug'
8+
alias rr='rm -rf /memristor/ros2_ws/build /memristor/ros2_ws/install'
69

710
test -f /opt/ros/humble/local_setup.bash && \
811
source /opt/ros/humble/local_setup.bash

docker/config/setup.sh

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#!/usr/bin/env bash
22

3-
_help=false
43
_configure_proxy=false
54
_vnc=false
65
_first_time_ros_setup=false
76
_enhanced_shell_prompt=false
87
_shell_shortcuts=false
9-
_all=false
10-
interactive=false
8+
_interactive=false
119

1210
usage() {
1311
echo "Usage: $0 [--help] [--configure-proxy] [--vnc] [--first-time-ros-setup] [--enhanced-shell-prompt] [--shell-shortcuts] [--interactive]"
@@ -28,7 +26,7 @@ default_configure_proxy() {
2826
}
2927

3028
configure_proxy() {
31-
if $interactive; then
29+
if $_interactive; then
3230
# FTN proxy is actually enabled here
3331
if dialog --title 'mep3 config' --defaultno --yesno 'Enable UNS proxy' 5 30; then
3432
sed '/# Setup_proxy/d' -i /memristor/.bashrc
@@ -44,15 +42,14 @@ configure_proxy() {
4442
}
4543

4644
default_first_time_ros_setup() {
47-
clear
4845
sudo -E rosdep init
4946
sudo -E apt-get install -y python3-vcstool
5047
rosdep --rosdistro "${ROS_DISTRO}" update
5148
cd /memristor/ros2_ws && yes | rosdep --rosdistro "${ROS_DISTRO}" install -r --from-paths src --ignore-src
5249
}
5350

5451
first_time_ros_setup() {
55-
if $interactive; then
52+
if $_interactive; then
5653
if dialog --title 'mep3 config' --yesno 'Run first time ROS setup' 5 30; then
5754
default_first_time_ros_setup
5855
return
@@ -68,7 +65,7 @@ default_enhanced_shell_prompt() {
6865
}
6966

7067
enhanced_shell_prompt() {
71-
if $interactive; then
68+
if $_interactive; then
7269
if dialog --title 'mep3 config' --yesno 'Enable enhanced shell prompt' 5 38; then
7370
default_enhanced_shell_prompt
7471
return
@@ -86,7 +83,7 @@ default_shell_shortcuts() {
8683
}
8784

8885
shell_shortcuts() {
89-
if $interactive; then
86+
if $_interactive; then
9087
if dialog --title 'mep3 config' --yesno 'Enable shell shortcuts' 5 30; then
9188
default_shell_shortcuts
9289
return
@@ -131,7 +128,7 @@ vnc() {
131128
echo "TurboVNC is not installed"
132129
exit 1
133130
fi
134-
if $interactive; then
131+
if $_interactive; then
135132
interactive_vnc
136133
return
137134
fi
@@ -141,7 +138,6 @@ vnc() {
141138
finalize() {
142139
sed '/# Setup_shell/d' -i /memristor/.bashrc
143140
echo 'echo "$-" | grep i -q && exec fish # Setup_shell' >>/memristor/.bashrc
144-
145141
clear
146142
}
147143

@@ -163,46 +159,33 @@ while [ "$#" -gt 0 ]; do
163159
_shell_shortcuts=true
164160
;;
165161
--interactive)
166-
interactive=true
167-
;;
168-
--help)
169-
_help=true
162+
_interactive=true
170163
;;
171-
--all)
172-
_all=true
164+
--default)
165+
_enhanced_shell_prompt=true
166+
_shell_shortcuts=true
173167
;;
174-
*)
168+
--help|*)
175169
usage
176170
;;
177171
esac
178172
shift
179173
done
180174

181-
if $_help; then
182-
usage
183-
fi
184-
185-
if $_all; then
175+
if $_configure_proxy; then
186176
configure_proxy
177+
fi
178+
if $_first_time_ros_setup; then
187179
first_time_ros_setup
180+
fi
181+
if $_enhanced_shell_prompt; then
188182
enhanced_shell_prompt
183+
fi
184+
if $_shell_shortcuts; then
189185
shell_shortcuts
186+
fi
187+
if $_vnc; then
190188
vnc
191-
else
192-
if $_configure_proxy; then
193-
configure_proxy
194-
fi
195-
if $_first_time_ros_setup; then
196-
first_time_ros_setup
197-
fi
198-
if $_enhanced_shell_prompt; then
199-
enhanced_shell_prompt
200-
fi
201-
if $_shell_shortcuts; then
202-
shell_shortcuts
203-
fi
204-
if $_vnc; then
205-
vnc
206-
fi
207189
fi
190+
208191
finalize

0 commit comments

Comments
 (0)