Skip to content

Commit d002f92

Browse files
fix(docker/tools): simplify visualizer container launch (#6088)
* simplify entrypoint and port exports Signed-off-by: Oguz Ozturk <oguzkaganozt@gmail.com> * . Signed-off-by: Oguz Ozturk <oguzkaganozt@gmail.com> * . Signed-off-by: Oguz Ozturk <oguzkaganozt@gmail.com> * . Signed-off-by: Oguz Ozturk <oguzkaganozt@gmail.com> * . Signed-off-by: Oguz Ozturk <oguzkaganozt@gmail.com> * style(pre-commit): autofix * . Signed-off-by: Oguz Ozturk <oguzkaganozt@gmail.com> --------- Signed-off-by: Oguz Ozturk <oguzkaganozt@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 79d4028 commit d002f92

3 files changed

Lines changed: 39 additions & 21 deletions

File tree

docker/tools/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@
33
This directory offers tools for [Open AD Kit](https://autoware.org/open-ad-kit/) containers to make deployment and simulation easier.
44

55
- `visualizer`: a container which visualizes the Autoware with RViz.
6-
- `scenario-simulator`: a container which runs scenario simulation with RViz.
6+
- `scenario-simulator`: a container which runs scenario-simulator.
77

88
## Visualizer
99

1010
### Run
1111

1212
```bash
13-
docker run --rm --name openadkit-visualizer -p 6080:6080 -p 5900:5900 ghcr.io/autowarefoundation/autoware-tools:visualizer
13+
docker run --rm --name visualizer -p 6080:6080 ghcr.io/autowarefoundation/autoware-tools:visualizer
1414
```
1515

1616
### Settings
1717

18-
The following environment variables can be configured for the visualizer container:
18+
The following environment variables can be configured with `-e` while launching the visualizer container:
1919

20-
| Variable | Default Value | Possible Values | Description |
21-
| -------------- | ------------------------------ | --------------- | ----------------------------------------------------------------- |
22-
| `RVIZ_CONFIG` | `/autoware/rviz/autoware.rviz` | Any valid path | The full path to the RViz configuration file inside the container |
23-
| `WEB_ENABLED` | `false` | `true`, `false` | Enable visualization through a web browser |
24-
| `WEB_PASSWORD` | - | Any string | Password for web visualization (required when `WEB_ENABLED=true`) |
20+
| Variable | Default Value | Possible Values | Description |
21+
| ----------------- | ------------------------------ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
22+
| `RVIZ_CONFIG` | `/autoware/rviz/autoware.rviz` | Any valid path | The full path to the RViz configuration file inside the container |
23+
| `REMOTE_DISPLAY` | `true` | `true`, `false` | By default, the rviz2 is redirected to a URL to enable browser-based visualization. Set this to `false` to launch a local rviz2 display. |
24+
| `REMOTE_PASSWORD` | `openadkit` | Any string | Password for remote display (only used when `REMOTE_DISPLAY=true`) |
2525

2626
## Scenario Simulator
2727

2828
### Run
2929

3030
```bash
31-
docker run --rm --name openadkit-scenario-simulator ghcr.io/autowarefoundation/autoware-tools:scenario-simulator
31+
docker run --rm --name scenario-simulator ghcr.io/autowarefoundation/autoware-tools:scenario-simulator
3232
```
3333

3434
### Settings
3535

36-
The following environment variables can be configured for the scenario simulator container:
36+
The following environment variables can be configured with `-e` while launching the scenario simulator container:
3737

3838
| Variable | Default Value | Possible Values | Description |
3939
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | -------------------------------------------------------- |

docker/tools/docker-compose.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
services:
2+
autoware:
3+
image: ghcr.io/autowarefoundation/autoware:universe
4+
volumes:
5+
- $HOME/autoware_map:/root/autoware_map
6+
command: >
7+
ros2 launch autoware_launch
8+
planning_simulator.launch.xml
9+
map_path:="/root/autoware_map/sample-map-planning"
10+
vehicle_model:=sample_vehicle
11+
sensor_model:=sample_sensor_kit
12+
rviz:=false
13+
14+
visualizer:
15+
image: ghcr.io/autowarefoundation/autoware-tools:visualizer
16+
ports:
17+
- 6080:6080

docker/tools/visualizer/entrypoint.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ if [ -z "$RVIZ_CONFIG" ]; then
1010
fi
1111

1212
configure_vnc() {
13-
# Check if WEB_PASSWORD is provided
14-
[ -z "$WEB_PASSWORD" ] && echo -e "\e[31mPassword is needed when WEB_ENABLED is true. Set WEB_PASSWORD environment variable\e[0m" && exit 1
15-
1613
# Create Openbox application configuration
1714
mkdir -p /etc/xdg/openbox
1815
cat >/etc/xdg/openbox/rc.xml <<'EOF'
@@ -35,7 +32,7 @@ EOF
3532
# Create rviz2 start script
3633
cat >/usr/local/bin/start-rviz2.sh <<'EOF'
3734
#!/bin/bash
38-
source /opt/ros/humble/setup.bash
35+
source /opt/ros/"$ROS_DISTRO"/setup.bash
3936
source /opt/autoware/setup.bash
4037
exec rviz2 -d "$RVIZ_CONFIG"
4138
EOF
@@ -44,8 +41,12 @@ EOF
4441
echo "/usr/local/bin/start-rviz2.sh" >>/etc/xdg/openbox/autostart
4542

4643
# Configure VNC password
44+
if [ -z "$REMOTE_PASSWORD" ]; then
45+
echo -e "\e[31mREMOTE_PASSWORD is not set, using *openadkit* as default\e[0m"
46+
REMOTE_PASSWORD="openadkit"
47+
fi
4748
mkdir -p ~/.vnc
48-
echo "$WEB_PASSWORD" | vncpasswd -f >~/.vnc/passwd && chmod 600 ~/.vnc/passwd
49+
echo "$REMOTE_PASSWORD" | vncpasswd -f >~/.vnc/passwd && chmod 600 ~/.vnc/passwd
4950

5051
# Start VNC server with Openbox
5152
echo "Starting VNC server with Openbox..."
@@ -68,9 +69,9 @@ EOF
6869

6970
# Print info
7071
echo -e "\033[32m-------------------------------------------------------------------------\033[0m"
71-
echo -e "\033[32mBrowser interface available at local address http://$(hostname -I | cut -d' ' -f1):6080/vnc.html?resize=scale&password=${WEB_PASSWORD}&autoconnect=true\033[0m"
72+
echo -e "\033[32mBrowser interface available at local address http://$(hostname -I | cut -d' ' -f1):6080/vnc.html?resize=scale&password=${REMOTE_PASSWORD}&autoconnect=true\033[0m"
7273
if curl -s --head 1.1.1.1 >/dev/null 2>&1; then
73-
echo -e "\033[32mIf you have a static public ip you can access it on WEB at http://$(curl -s ifconfig.me):6080/vnc.html?resize=scale&password=${WEB_PASSWORD}&autoconnect=true\033[0m"
74+
echo -e "\033[32mIf you have a static public ip you can access it on WEB at http://$(curl -s ifconfig.me):6080/vnc.html?resize=scale&password=${REMOTE_PASSWORD}&autoconnect=true\033[0m"
7475
else
7576
echo -e "\033[31mNo internet connection available\033[0m"
7677
fi
@@ -82,11 +83,11 @@ source "/opt/ros/$ROS_DISTRO/setup.bash"
8283
source "/opt/autoware/setup.bash"
8384

8485
# Execute passed command if provided, otherwise launch rviz2
85-
if [ "$WEB_ENABLED" == "true" ]; then
86-
configure_vnc
87-
[ $# -eq 0 ] && sleep infinity
86+
if [ "$REMOTE_DISPLAY" == "false" ]; then
87+
[ $# -eq 0 ] && rviz2 -d "$RVIZ_CONFIG"
8888
exec "$@"
8989
else
90-
[ $# -eq 0 ] && rviz2 -d "$RVIZ_CONFIG"
90+
configure_vnc
91+
[ $# -eq 0 ] && sleep infinity
9192
exec "$@"
9293
fi

0 commit comments

Comments
 (0)