Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Visualizations for Dev Container #3523

Merged
merged 38 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
04468cc
Add visualizer stage
ruffsl Mar 31, 2023
880f95e
Install foxglove
ruffsl Mar 31, 2023
0407cb4
Install gzweb
ruffsl Mar 31, 2023
089b8e2
Add hack for resolvable mesh URIs
ruffsl Mar 31, 2023
99c59bc
Revert hack and use fork
ruffsl Mar 31, 2023
a6d9531
Update target stage to visualizer
ruffsl Mar 31, 2023
fa3d1c3
Comment out gzclient and rviz for debugging
ruffsl Mar 31, 2023
38c8b0e
Add hack for resolvable mesh URIs
ruffsl Mar 31, 2023
e09b309
Reorder stages for readability
ruffsl Apr 4, 2023
f6523da
fix typo
ruffsl Apr 4, 2023
e9947b0
Install gdb for launching ros launch files
ruffsl Apr 4, 2023
feb9b60
Add vscode tasks file
ruffsl Apr 4, 2023
95bbe1b
Add Start Gzweb task
ruffsl Apr 4, 2023
6f9161b
Add Start Foxglove tasks
ruffsl Apr 4, 2023
d2f0f7f
Add Start Foxglove compound task
ruffsl Apr 4, 2023
175db4f
Set default problemMatcher to empty
ruffsl Apr 4, 2023
3db3691
Source overlay before running foxglove_bridge
ruffsl Apr 4, 2023
56fe95b
Formatting
ruffsl Apr 4, 2023
4d701be
Generalize and simplify hack
ruffsl Apr 4, 2023
307760c
Generalize gazebo model discovery
ruffsl Apr 4, 2023
1b22087
Patch gzserver to run headless using xvfb
ruffsl Apr 4, 2023
02740fa
Set isBackground for start tasks
ruffsl Apr 5, 2023
1f76e0a
Add stop tasks
ruffsl Apr 5, 2023
36f0a78
Add restart foxglove task
ruffsl Apr 5, 2023
20d6a8e
Switch to shell for commanding pkill
ruffsl Apr 5, 2023
e40fb5c
Add icons to tasks
ruffsl Apr 5, 2023
83a7e19
Add restart gzweb task
ruffsl Apr 5, 2023
fe44e87
Add global start, stop, and restart tasks
ruffsl Apr 5, 2023
7a0741f
Formatting
ruffsl Apr 5, 2023
e1aafa5
Hide tasks users need not run manually
ruffsl Apr 5, 2023
b7a53fa
Shorten label for background tasks
ruffsl Apr 5, 2023
9521005
Show global start and stop visualizations tasks
ruffsl Apr 5, 2023
2149076
Revert "Comment out gzclient and rviz for debugging"
ruffsl Apr 6, 2023
11c526a
Add --ipc=host to runArgs
ruffsl Apr 12, 2023
cf42480
Add --pid=host to runArgs
ruffsl Apr 12, 2023
66f01b0
Add to runArgs
ruffsl Apr 12, 2023
f25fe27
Add comments
ruffsl Apr 12, 2023
c83172b
Comment out runArgs unintended side effects
ruffsl Apr 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
"build": {
"dockerfile": "../Dockerfile",
"context": "..",
"target": "dever",
"target": "visualizer",
"cacheFrom": "ghcr.io/ros-planning/navigation2:main"
},
"runArgs": [
"--privileged",
"--network=host"
// "--cap-add=SYS_PTRACE", // enable debugging, e.g. gdb
// "--ipc=host", // shared memory transport with host, e.g. rviz GUIs
// "--network=host", // network access to host interfaces, e.g. eth0
// "--pid=host", // DDS discovery with host, without --network=host
// "--privileged", // device access to host peripherals, e.g. USB
// "--security-opt=seccomp=unconfined", // enable debugging, e.g. gdb
],
"workspaceMount": "source=${localWorkspaceFolder},target=/opt/overlay_ws/src/navigation2,type=bind",
"workspaceFolder": "/opt/overlay_ws/src/navigation2",
Expand Down
174 changes: 174 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Gzweb",
"icon": {
"id": "debug-start"
},
"type": "process",
"command": "npm",
"args": [
"start"
],
"options": {
"cwd": "/opt/gzweb",
"env": {
"npm_config_port": "9090"
}
},
"hide": true,
"isBackground": true,
"problemMatcher": []
},
{
"label": "Stop Gzweb",
"icon": {
"id": "debug-stop"
},
"type": "shell",
"command": "pkill -SIGTERM -f 'npm start' || true",
"hide": true,
"problemMatcher": []
},
{
"label": "Restart Gzweb",
"icon": {
"id": "debug-restart"
},
"dependsOn": [
"Stop Gzweb",
"Gzweb"
],
"dependsOrder": "sequence",
"problemMatcher": []
},
{
"label": "Foxglove Bridge",
"icon": {
"id": "debug-start"
},
"type": "shell",
"command": "source ./install/setup.bash && ros2 run foxglove_bridge foxglove_bridge",
"options": {
"cwd": "/opt/overlay_ws",
},
"isBackground": true,
"hide": true,
"problemMatcher": []
},
{
"label": "Stop Foxglove Bridge",
"icon": {
"id": "debug-stop"
},
"type": "shell",
"command": "pkill -SIGTERM -f 'ros2 run foxglove_bridge foxglove_bridge' || true",
"hide": true,
"problemMatcher": []
},
{
"label": "Foxglove Studio",
"icon": {
"id": "debug-start"
},
"type": "process",
"command": "caddy",
"args": [
"file-server",
"--listen",
":8080"
],
"options": {
"cwd": "/opt/foxglove",
},
"isBackground": true,
"hide": true,
"problemMatcher": []
},
{
"label": "Stop Foxglove Studio",
"icon": {
"id": "debug-stop"
},
"type": "shell",
"command": "pkill -SIGTERM -f 'caddy file-server --listen :8080' || true",
"hide": true,
"problemMatcher": []
},
{
"label": "Foxglove",
"icon": {
"id": "debug-start"
},
"dependsOn": [
"Foxglove Bridge",
"Foxglove Studio"
],
"hide": true,
"problemMatcher": []
},
{
"label": "Stop Foxglove",
"icon": {
"id": "debug-stop"
},
"dependsOn": [
"Stop Foxglove Bridge",
"Stop Foxglove Studio"
],
"hide": true,
"problemMatcher": []
},
{
"label": "Restart Foxglove",
"icon": {
"id": "debug-restart"
},
"dependsOn": [
"Stop Foxglove",
"Foxglove"
],
"dependsOrder": "sequence",
"problemMatcher": []
},
{
"label": "Start Visualizations",
"icon": {
"id": "debug-start"
},
"dependsOn": [
"Gzweb",
"Foxglove"
],
// "hide": true,
"problemMatcher": []
},
{
"label": "Stop Visualizations",
"icon": {
"id": "debug-stop"
},
"dependsOn": [
"Stop Gzweb",
"Stop Foxglove"
],
// "hide": true,
"problemMatcher": []
},
{
"label": "Restart Visualizations",
"icon": {
"id": "debug-restart"
},
"dependsOn": [
"Stop Visualizations",
"Start Visualizations"
],
"dependsOrder": "sequence",
"problemMatcher": []
}
]
}
85 changes: 71 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,6 @@ RUN . $UNDERLAY_WS/install/setup.sh && \
--ignore-src \
&& rm -rf /var/lib/apt/lists/*

# multi-stage for developing
FROM builder AS dever

# edit apt for caching
RUN mv /etc/apt/apt.conf.d/docker-clean /etc/apt/

# install developer dependencies
RUN apt-get update && \
apt-get install -y \
bash-completion

# source underlay for shell
RUN echo 'source "$UNDERLAY_WS/install/setup.bash"' >> /etc/bash.bashrc

# multi-stage for testing
FROM builder AS tester

Expand Down Expand Up @@ -146,3 +132,74 @@ RUN if [ -n "$RUN_TESTS" ]; then \
colcon test-result \
|| ([ -z "$FAIL_ON_TEST_FAILURE" ] || exit 1) \
fi

# multi-stage for developing
FROM builder AS dever

# edit apt for caching
RUN mv /etc/apt/apt.conf.d/docker-clean /etc/apt/

# install developer dependencies
RUN apt-get update && \
apt-get install -y \
bash-completion \
gdb

# source underlay for shell
RUN echo 'source "$UNDERLAY_WS/install/setup.bash"' >> /etc/bash.bashrc

# multi-stage for visualizing
FROM dever AS visualizer

# install foxglove dependacies
RUN echo "deb https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" > /etc/apt/sources.list.d/caddy-stable.list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have a separate docker container in .devcontainer for this? I'd like to keep the root docker file as straight forward as possible for use as the base of other people's systems.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 65760c51edea2017cea2ca15155b6d79ca56ea34

# install demo dependencies
RUN apt-get update && apt-get install -y \
ros-$ROS_DISTRO-aws-robomaker-small-warehouse-world \
ros-$ROS_DISTRO-rviz2 \
ros-$ROS_DISTRO-turtlebot3-simulations

# install gzweb dependacies
RUN apt-get install -y --no-install-recommends \
imagemagick \
libboost-all-dev \
libgazebo-dev \
libgts-dev \
libjansson-dev \
libtinyxml-dev \
nodejs \
npm \
psmisc \
xvfb

# clone gzweb
ENV GZWEB_WS /opt/gzweb
RUN git clone --branch python3 https://github.com/ruffsl/gzweb.git $GZWEB_WS

# build gzweb
RUN cd $GZWEB_WS && . /usr/share/gazebo/setup.sh && \
GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$(find /opt/ros/$ROS_DISTRO/share \
-mindepth 1 -maxdepth 2 -type d -name "models" | paste -s -d: -) && \
xvfb-run -s "-screen 0 1280x1024x24" ./deploy.sh -m local && \
ln -s $GZWEB_WS/http/client/assets http/client/assets/models

# patch gzsever
RUN GZSERVER=$(which gzserver) && \
mv $GZSERVER $GZSERVER.orig && \
echo '#!/bin/bash' > $GZSERVER && \
echo 'xvfb-run -s "-screen 0 1280x1024x24" gzserver.orig "$@"' >> $GZSERVER && \
chmod +x $GZSERVER

# install foxglove dependacies
RUN apt-get install -y --no-install-recommends \
caddy \
ros-$ROS_DISTRO-foxglove-bridge

# copy foxglove
ENV FOXGLOVE_WS /opt/foxglove
COPY --from=ghcr.io/foxglove/studio /src $FOXGLOVE_WS

# multi-stage for exporting
FROM tester AS exporter