Skip to content

Commit

Permalink
Improvements (#9)
Browse files Browse the repository at this point in the history
* Reverse proxy

* Fix revere proxy

* E stop read state

* test

* test

* Estop w8 for feedback

* layout

* compose

* Reverse proxy

* typo

* fix workflow

* Fix reverse proxy

* Simplify

* fix

* new topics paths

* Inverse logic and moving average filter

* clean up

* e-stop service fixes

---------

Co-authored-by: BOOTCFG <[email protected]>
  • Loading branch information
rafal-gorecki and BOOTCFG authored Jul 22, 2024
1 parent cc71bd7 commit bdf5c0c
Show file tree
Hide file tree
Showing 19 changed files with 284 additions and 328 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
.DS_Store
.webpack/
dist/
demo/
node_modules/
Dockerfile
8 changes: 4 additions & 4 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:
platforms: linux/amd64, linux/arm64
push: true
tags: |
husarion/foxglove:studio-${{ env.SHORT_DATE }}
husarion/foxglove:studio
husarion/foxglove:studio-nightly
husarion/foxglove:${{ github.head_ref || github.ref_name }}-${{ env.SHORT_DATE }}
husarion/foxglove:${{ github.head_ref || github.ref_name }}
husarion/foxglove:${{ github.head_ref || github.ref_name }}-nightly
cache-to: type=inline

- name: Build and push (feature branch)
Expand All @@ -49,5 +49,5 @@ jobs:
platforms: linux/amd64, linux/arm64
push: true
tags: |
husarion/foxglove:studio-nightly
husarion/foxglove:${{ github.head_ref || github.ref_name }}-nightly
cache-to: type=inline
46 changes: 21 additions & 25 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
# Listen on localhost on the specified port
:{$UI_PORT} {
tls internal

root * /src

# Handle requests from Husarnet IPv6 clients
@ipv6Client {
expression {http.request.host}.startsWith("fc94")
}
handle @ipv6Client {
vars full_host [{http.request.host}]
redir /ui /?ds={$DS_TYPE}&ds.url=ws%3A%2F%2F%5B{http.request.host}%5D%3A{$DS_PORT}
:8080 {
handle_path /ws {
reverse_proxy http://127.0.0.1:8765
}

# Handle all other requests (from non-IPv6 clients)
handle {
vars full_host {http.request.host}
redir /ui /?ds={$DS_TYPE}&ds.url=ws%3A%2F%2F{http.request.host}%3A{$DS_PORT}
}
handle_path /* {
root * /src

templates {
mime "application/json" "text/plain" "text/html"
}
# Handle IPv6 clients
@ipv6Client {
expression {http.request.host}.startsWith("fc94")
}

handle @ipv6Client {
redir /ui /?ds=foxglove-websocket&ds.url=ws%3A%2F%2F%5B{http.request.host}%5D%3A8765
}

file_server browse
# Handle all other requests (from non-IPv6 clients)
handle {
redir /ui /?ds=foxglove-websocket&ds.url=ws%3A%2F%2F{http.request.host}%3A8765
}

@urdf path /*.urdf
templates {
mime "text/html"
}

header @urdf {
Content-Type "text/plain"
file_server
}
}
38 changes: 0 additions & 38 deletions Caddyfile_reverse_proxy

This file was deleted.

14 changes: 3 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ARG ROS_DISTRO=humble

# =========================== Foxglove builder ===============================
FROM node:16 as foxglove_build
FROM node:16 AS foxglove_build
WORKDIR /src

RUN apt-get update && \
apt-get install -y git-lfs && \
git clone -b studio https://github.com/husarion/foxglove-docker . && \
git clone -b improvements https://github.com/husarion/foxglove-docker . && \
git lfs pull

RUN corepack enable
Expand All @@ -28,20 +28,12 @@ COPY disable_cache.js /
COPY disable_interaction.js /

COPY Caddyfile /etc/caddy/
COPY Caddyfile_reverse_proxy /etc/caddy/
COPY entrypoint.sh /
COPY run.sh /

EXPOSE 8080

ENV DS_TYPE=foxglove-websocket
ENV DS_PORT=8765
ENV UI_PORT=8080
ENV DISABLE_INTERACTION=false
ENV DISABLE_CACHE=true

# only for IPv6 -> IPv4 reverse proxy for foxglove-websocket datasource (that can listen only on IPv4)
ENV DS_HOST=

ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
CMD /run.sh
CMD caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
35 changes: 0 additions & 35 deletions demo/compose.local.yaml

This file was deleted.

25 changes: 14 additions & 11 deletions demo/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
x-common-config: &common-config
network_mode: host
ipc: host
environment:
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
- ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0}

services:
foxglove:
image: husarion/foxglove:studio-nightly
# build:
# context: ..
# dockerfile: Dockerfile
# runtime: nvidia
image: husarion/foxglove:improvements-nightly
<<: *common-config
ports:
- 8080:8080
- 8765:8765
volumes:
- ./foxglove-layout.json:/foxglove/default-layout.json
- ../Caddyfile:/etc/caddy/Caddyfile
environment:
- ROBOT_NAMESPACE=panther
- DS_HOST=foxglove-ds
- DISABLE_CACHE=true
- DISABLE_INTERACTION=false
# - NVIDIA_VISIBLE_DEVICES=all
# - NVIDIA_DRIVER_CAPABILITIES=all

foxglove-ds:
image: husarion/foxglove-bridge:humble-0.7.4-20240320
image: husarion/foxglove-bridge:humble-0.7.7-20240708
<<: *common-config
ports:
- 8765:8765
command: ros2 launch foxglove_bridge foxglove_bridge_launch.xml port:=8765 capabilities:=[clientPublish,parameters,parametersSubscribe,services,connectionGraph,assets]
9 changes: 5 additions & 4 deletions demo/foxglove-layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
"paths": [
{
"timestampMethod": "receiveTime",
"value": "<robot_namespace>/imu_broadcaster/imu.linear_acceleration.x",
"value": "<robot_namespace>/imu/data.linear_acceleration.x",
"enabled": true,
"label": "x",
"showLine": true
},
{
"timestampMethod": "receiveTime",
"value": "<robot_namespace>/imu_broadcaster/imu.linear_acceleration.y",
"value": "<robot_namespace>/imu/data.linear_acceleration.y",
"enabled": true,
"label": "y"
},
{
"timestampMethod": "receiveTime",
"value": "<robot_namespace>/imu_broadcaster/imu.linear_acceleration.z",
"value": "<robot_namespace>/imu/data.linear_acceleration.z",
"enabled": true,
"label": "z"
}
Expand Down Expand Up @@ -73,7 +73,7 @@
"foxglovePanelTitle": "RR"
},
"Battery!wppv5y": {
"path": "<robot_namespace>/battery.percentage",
"path": "<robot_namespace>/battery/battery_status.percentage",
"minValue": 0,
"maxValue": 1,
"colorMap": "red-yellow-green",
Expand All @@ -89,6 +89,7 @@
"serviceName": "",
"goServiceName": "<robot_namespace>/hardware/e_stop_reset",
"stopServiceName": "<robot_namespace>/hardware/e_stop_trigger",
"statusTopicName": "<robot_namespace>/hardware/e_stop.data",
"foxglovePanelTitle": "E-stop"
},
"Joy!3fmstz6": {
Expand Down
9 changes: 4 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#!/bin/bash
set -e

# replace localhost:8080 with {{placeholder "http.vars.full_host"}}:UI_PORT in /foxglove/default-layout.json file (change file to do not modify volumen)
sed 's|localhost:8080|{{placeholder "http.vars.full_host"}}:{{env "UI_PORT"}}|g' /foxglove/default-layout.json > /foxglove/remote-layout.json
cp /foxglove/default-layout.json /foxglove/local-layout.json
if [ -n "$ROBOT_NAMESPACE" ]; then
sed -i "s|<robot_namespace>|/$ROBOT_NAMESPACE|g" /foxglove/remote-layout.json
sed -i "s|<robot_namespace>|/$ROBOT_NAMESPACE|g" /foxglove/local-layout.json
else
sed -i "s|<robot_namespace>||g" /foxglove/remote-layout.json
sed -i "s|<robot_namespace>||g" /foxglove/local-layout.json
fi

# Optionally override the default layout with one provided via bind mount
index_html=$(cat index.html)
replace_pattern='/*FOXGLOVE_STUDIO_DEFAULT_LAYOUT_PLACEHOLDER*/'
replace_value=$(cat /foxglove/remote-layout.json)
replace_value=$(cat /foxglove/local-layout.json)
echo "${index_html/"$replace_pattern"/$replace_value}" > index.html

# Check if ENABLE_SCRIPT1 is set to true
Expand Down
Loading

0 comments on commit bdf5c0c

Please sign in to comment.