ROS Package bob_av_tools
A collection of audio-visual utilities for the Bob ROS 2 ecosystem. This package provides high-fidelity web-based video rendering, interactive terminal overlays, and robust FIFO stream orchestration.
Key Features
webvideo: Offscreen browser renderer for overlays. Output: FIFO (raw BGRA) or ROS Image.webview: Interactive GUI terminal sibling with chat support (“Uplink Echo”).webscreen: Capture any URL (website/local) offscreen. Supports authentications & automation.write_fifo.sh: Helper script to pipe external streams (FFmpeg, etc.) into a managed FIFO.Robust FIFO Reconnect: Advanced producer/consumer handling (
O_NONBLOCK+fcntl) for seamless hot-swapping of readers.Nexus Aesthetic: Built-in “Nexus Style” UI: Cyberspace/Terminal design with typewriter effects.
Installation
1. Python Dependencies
pip install PySide6 numpy
2. System Requirements (QtWebEngine/Chromium)
The renderer requires several X11 and GL libraries for offscreen rendering:
sudo apt update && sudo apt install -y \
libxcb-cursor0 libgbm1 libnss3 libasound2 libxcomposite1 \
libxdamage1 libxrandr2 libxcb-icccm4 libxcb-image0 \
libxcb-keysyms1 libxcb-render-util0 libgl1 libegl1
Node Documentation
1. Web Video Renderer (webvideo)
Renders a localized HTML overlay for LLM text streams. Optimized for embedding in video mixers.
ROS API
Subscribed Topics:
llm_stream(std_msgs/msg/String): Incoming text chunks for display.llm_tool_calls(std_msgs/msg/String): Feed for visualized tool/agent actions.
Published Topics:
web_image(sensor_msgs/msg/Image): Rendered frames (Requirescv_bridge).
Configuration (Parameters & Env Vars)
Parameter |
Env Var Equivalent |
Default |
Description |
|---|---|---|---|
|
|
|
Path to the base HTML template. |
|
|
|
Rendering width (px). |
|
|
|
Rendering height (px). |
|
|
|
Frames per second. |
|
|
|
Path to output raw pipe. |
|
|
|
If |
|
|
|
Subscription queue size. |
|
|
|
Max chars to keep (0=unlimited). Prevents slowdown. |
|
|
|
Path to a custom .css file. |
2. Webview Terminal (webview)
Interactive window for human-in-the-loop interaction. Opens a GUI window on the primary display.
ROS API
Subscribed Topics:
llm_stream(std_msgs/msg/String): Feed for the terminal display.llm_tool_calls(std_msgs/msg/String): Visualized agent tool calls.
Published Topics:
chat_out(std_msgs/msg/String): Published when a user sends a message in the UI.
Configuration (Parameters & Env Vars)
Parameter |
Env Var Equivalent |
Default |
Description |
|---|---|---|---|
|
|
|
Path to the base HTML template. |
|
|
|
Window width (px). |
|
|
|
Window height (px). |
|
|
|
Enable/Disable chat input area. |
|
|
|
Subscription queue size. |
|
|
|
Max chars to keep in JS buffer (0=unlimited). |
|
|
|
Path to a custom .css file. |
3. URL Screen Capture (webscreen)
Renders any external URL or local file offscreen. Ideal for capturing Twitch chats, dashboards, or static web pages.
ROS API
Subscribed Topics:
llm_tool_calls(std_msgs/msg/String): Overlay tool calls on top of the captured URL.
Published Topics:
webscreen_image(sensor_msgs/msg/Image): Captures views as ROS messages.
Configuration (Parameters & Env Vars)
Parameter |
Env Var Equivalent |
Default |
Description |
|---|---|---|---|
|
|
|
Required. URL or |
|
|
|
Viewport width. |
|
|
|
Viewport height. |
|
|
|
Capture rate. |
|
|
|
Path to raw pipe. |
|
|
|
If |
|
|
|
Max chars for LLM overlays (0=unlimited). |
|
|
|
Path to JSON cookies for auth. |
|
|
|
Path to JS automation script. |
|
|
|
Initial horizontal scroll. |
|
|
|
Initial vertical scroll. |
Configuration Examples
Pre-Script JS (pre_script)
Automate page actions (dismiss banners, focus elements, click buttons) before capture begins.
// Hide persistent cookie banners or ads
const banner = document.querySelector('.cookie-consent');
if (banner) banner.style.display = 'none';
// Force dark mode if supported
document.documentElement.setAttribute('data-theme', 'dark');
console.log('Page automation complete.');
Custom Styling (override_css)
Override the default “Nexus” look for webvideo and webview.
Layout Variables
You can override these in your .css file for precise layout control without worrying about CSS specificity of IDs:
--root-padding: Padding of the outer container (default:40pxfor overlay,20pxfor webview).--content-padding: Padding inside the terminal/content area (default:20px).--content-bg: Background color/alpha of the content area.--content-border-left: Style of the left accent border.--line-height: Line height in the content area (default:1.4).--cursor-display: (Webview only) Toggle cursor visibility (default:inline-block, set tononeto hide).--chat-bg: (Webview only) Background of the chat input area.
Example:
:root {
--accent-color: #ff00ff; /* Cyberpink */
--root-padding: 0px; /* Full screen capture */
--content-bg: transparent;
--content-border-left: none;
}
Utility Scripts
write_fifo.sh
Orchestrates streams from external processes (like FFmpeg) into managed FIFOs.
# Capture webcam and pipe to FIFO for sdlviz
ffmpeg -i /dev/video0 -f rawvideo -pixel_format bgr24 - | \
ros2 run bob_av_tools write_fifo.sh --path /tmp/cam_fifo
Advanced Configuration (Chromium Flags)
The nodes automatically set QTWEBENGINE_CHROMIUM_FLAGS for headless compatibility. You can override these via the environment if needed:
export QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox --disable-setuid-sandbox --disable-gpu"
HTML Templates & Custom Interactivity
The renderer nodes (webvideo, webview, webscreen) communicate with the HTML templates via a standardized JavaScript bridge. If you provide a custom ui_path, your HTML should implement one of the following functions:
JS Bridge Interface
/**
* Main update function called by the ROS node.
* @param {string} content - The full current markdown/text content.
*/
window.updateContent = function(content) {
// Render markdown, update terminal, etc.
document.body.innerText = content;
};
/**
* Alternative streaming interface.
* @param {string} chunk - New token/chunk to append.
*/
window.appendStream = function(chunk) {
document.body.innerText += chunk;
};
Provided Layouts
webvideo.html: Default full-screen overlay for text streams.webview.html: Interactive terminal with chat input area.smallchat.html: Compact, high-refresh rate overlay. Supports syntax highlighting viahighlight.js(requiresvendor/files).
Vendor Dependencies
For offline use, required libraries are located in bob_av_tools/vendor/:
highlight.min.js: Syntax highlighting for code blocks.atom-one-dark.min.css: Dark theme for highlighting.