Skip to content

Commit

Permalink
Disable ROS first time setup by default (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
filiparag authored Mar 16, 2024
1 parent 1cfdc1c commit 3dff4d4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 73 deletions.
8 changes: 4 additions & 4 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y -o Dpkg::Option
ros-humble-ros2-controllers \
ros-humble-rqt-common-plugins \
ros-humble-webots-ros2 \
ros-humble-dynamixel-workbench-toolbox \
ros-humble-dynamixel-workbench-toolbox \
ros-humble-behaviortree-cpp \
libopencv-dev \
python3-pip \
Expand All @@ -43,7 +43,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y -o Dpkg::Option
vim \
rsync \
dialog \
fish
fish



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



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

# Webots
RUN curl -L -o /tmp/webots.deb \
Expand Down
61 changes: 31 additions & 30 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
MAKEFLAGS+=--silent
UID:=$(shell id -u)
DOCKER_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
PROJECT_DIR:=$(shell dirname ${DOCKER_DIR})
Expand All @@ -7,23 +8,28 @@ IMAGE=ghcr.io/memristor/mep3

.PHONY: all

all: destroy test-nvidia run setup-default exec start-code-server
all: destroy test-nvidia run setup-default

colors:
$(eval NC=\033[1;0m)
$(eval RED=\033[1;31m)
$(eval GREEN=\033[1;32m)
$(eval BOLD=\033[1;37m)

vnc:
$(eval FLAVOR=vnc)
$(eval IMAGE=ghcr.io/memristor/mep3-vnc)
@true
true

build:
echo ${NO_CACHE_ARG}
@DOCKER_BUILDKIT=1 docker build ${DOCKER_DIR} -f ${DOCKER_DIR}/Dockerfile.base -t mep3 ${DOCKER_ARGS} --build-arg UID=${UID}
@[ ${FLAVOR} != 'devel' ] && \
DOCKER_BUILDKIT=1 docker build ${DOCKER_DIR} -f ${DOCKER_DIR}/Dockerfile.base -t mep3 ${DOCKER_ARGS} --build-arg UID=${UID}
[ ${FLAVOR} != 'devel' ] && \
DOCKER_BUILDKIT=1 docker build ${DOCKER_DIR} -f ${DOCKER_DIR}/Dockerfile.${FLAVOR} -t ${IMAGE} ${DOCKER_ARGS} || \
true

run:
@${MAKE} -s test-nvidia
@docker run \
run: test-nvidia
docker run \
--net=host \
--ipc=host \
--cap-add SYS_ADMIN \
Expand All @@ -37,42 +43,37 @@ run:
-v /dev/dri:/dev/dri:ro \
-v /dev:/dev:rw \
-v ${PROJECT_DIR}:/memristor/ros2_ws/src/mep3:rw \
-d -it ${IMAGE}

test-nvidia:
$(eval NC=\033[1;0m)
$(eval RED=\033[1;31m)
$(eval GREEN=\033[1;32m)
-d -it ${IMAGE} 1>/dev/null

@lspci | grep -qi nvidia && base64 --decode massage | unxz || true

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

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

stop-code-server:
@docker exec -it mep3-${FLAVOR} pkill -f code-server
docker exec -it mep3-${FLAVOR} pkill -f code-server

exec:
@docker exec -it mep3-${FLAVOR} bash
docker exec -it mep3-${FLAVOR} bash

destroy:
@docker container kill mep3-${FLAVOR} || true
@docker container rm -f mep3-${FLAVOR} || true
docker container kill mep3-${FLAVOR} 1>/dev/null || true
docker container rm -f mep3-${FLAVOR} 1>/dev/null || true

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

setup-interactive:
@docker exec -it mep3-${FLAVOR} sh -c '/usr/bin/setup.sh --all --interactive'
@echo 'Restarting mep3-${FLAVOR} container...'
@docker restart mep3-${FLAVOR}
setup-interactive: colors
docker exec -it mep3-${FLAVOR} sh -c '/usr/bin/setup.sh --interactive'
printf '%b\n%b\n' "${GREEN}Interactive setup complete!${NC}" \
"Run ${BOLD}make exec${NC} or ${BOLD}docker exec -it mep3-${FLAVOR}${NC} to access the container"
5 changes: 4 additions & 1 deletion docker/config/bashrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export WEBOTS_HOME=/usr/local/webots
export USERNAME=default
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
if uname -v | grep -qi 'ubuntu'; then
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
fi

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

test -f /opt/ros/humble/local_setup.bash && \
source /opt/ros/humble/local_setup.bash
Expand Down
59 changes: 21 additions & 38 deletions docker/config/setup.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/env bash

_help=false
_configure_proxy=false
_vnc=false
_first_time_ros_setup=false
_enhanced_shell_prompt=false
_shell_shortcuts=false
_all=false
interactive=false
_interactive=false

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

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

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

first_time_ros_setup() {
if $interactive; then
if $_interactive; then
if dialog --title 'mep3 config' --yesno 'Run first time ROS setup' 5 30; then
default_first_time_ros_setup
return
Expand All @@ -68,7 +65,7 @@ default_enhanced_shell_prompt() {
}

enhanced_shell_prompt() {
if $interactive; then
if $_interactive; then
if dialog --title 'mep3 config' --yesno 'Enable enhanced shell prompt' 5 38; then
default_enhanced_shell_prompt
return
Expand All @@ -86,7 +83,7 @@ default_shell_shortcuts() {
}

shell_shortcuts() {
if $interactive; then
if $_interactive; then
if dialog --title 'mep3 config' --yesno 'Enable shell shortcuts' 5 30; then
default_shell_shortcuts
return
Expand Down Expand Up @@ -131,7 +128,7 @@ vnc() {
echo "TurboVNC is not installed"
exit 1
fi
if $interactive; then
if $_interactive; then
interactive_vnc
return
fi
Expand All @@ -141,7 +138,6 @@ vnc() {
finalize() {
sed '/# Setup_shell/d' -i /memristor/.bashrc
echo 'echo "$-" | grep i -q && exec fish # Setup_shell' >>/memristor/.bashrc

clear
}

Expand All @@ -163,46 +159,33 @@ while [ "$#" -gt 0 ]; do
_shell_shortcuts=true
;;
--interactive)
interactive=true
;;
--help)
_help=true
_interactive=true
;;
--all)
_all=true
--default)
_enhanced_shell_prompt=true
_shell_shortcuts=true
;;
*)
--help|*)
usage
;;
esac
shift
done

if $_help; then
usage
fi

if $_all; then
if $_configure_proxy; then
configure_proxy
fi
if $_first_time_ros_setup; then
first_time_ros_setup
fi
if $_enhanced_shell_prompt; then
enhanced_shell_prompt
fi
if $_shell_shortcuts; then
shell_shortcuts
fi
if $_vnc; then
vnc
else
if $_configure_proxy; then
configure_proxy
fi
if $_first_time_ros_setup; then
first_time_ros_setup
fi
if $_enhanced_shell_prompt; then
enhanced_shell_prompt
fi
if $_shell_shortcuts; then
shell_shortcuts
fi
if $_vnc; then
vnc
fi
fi

finalize

0 comments on commit 3dff4d4

Please sign in to comment.