Beam Bots Logo

BB.LiveView

CILicense: Apache 2.0Hex version badgeREUSE status

Interactive LiveView dashboard for Beam Bots robots. Mount a fully-featured control interface into any Phoenix application with a single line of code.

Features

Installation

Add bb_liveview to your dependencies in mix.exs:

def deps do
[
{:bb_liveview, "~> 0.2.0"}
]
end

Quick Start

1. Add the dashboard route

In your Phoenix router, import the macro and mount the dashboard:

defmodule MyAppWeb.Router do
use MyAppWeb, :router
import BB.LiveView.Router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {MyAppWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
end
scope "/" do
pipe_through :browser
bb_dashboard "/robot", robot: MyApp.Robot
end
end

2. Serve the bundled assets

Add the static plug to your endpoint, beforePlug.Session:

defmodule MyAppWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :my_app
# ... other plugs ...
# Add this BEFORE Plug.Session
plug Plug.Static,
at: "/__bb_assets__",
from: {:bb_liveview, "priv/static"},
gzip: false
plug Plug.Session, ...
plug MyAppWeb.Router
end

3. Start your robot supervisor

Ensure your robot's supervision tree is started in your application:

defmodule MyApp.Application do
use Application
def start(_type, _args) do
children = [
# ... other children ...
%{
id: BB.Supervisor,
start: {BB.Supervisor, :start_link, [MyApp.Robot]}
},
MyAppWeb.Endpoint
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
end

4. Visit the dashboard

Navigate to http://localhost:4000/robot to see your robot dashboard.

Multiple Robots

Mount multiple dashboards for different robots:

scope "/" do
pipe_through :browser
bb_dashboard "/arm", robot: MyApp.ArmRobot
bb_dashboard "/base", robot: MyApp.MobileBase
end

Configuration Options

The bb_dashboard/2 macro accepts the following options:

OptionRequiredDescription
:robotYesThe robot module (must use BB)

Dashboard Components

Safety Widget

Displays the robot's safety state and provides arm/disarm controls:

Joint Control

Shows all movable joints with:

3D Visualisation

Interactive Three.js renderer showing:

Event Stream

Real-time PubSub message monitor:

Command Panel

Execute robot commands defined in the DSL:

Parameters

View and edit runtime parameters:

Styling

The dashboard uses bundled CSS with CSS custom properties for theming. The default theme uses neutral greys with accent colours for status indicators.

To customise, you can override the CSS custom properties in your own stylesheet:

:root {
--bb-primary: #your-color;
--bb-success: #your-success-color;
--bb-danger: #your-danger-color;
}

Development

To run the development server with the test robot:

cd bb_liveview
mix deps.get
cd assets && npm install && cd ..
mix phx.server

Visit http://localhost:4000 to see the dashboard with a simulated WidowX-200 style robot arm.

Requirements

Documentation

Full documentation is available at HexDocs.