Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dist/
build/
out/
apps/desktop-app/release/
Projects/
*.tsbuildinfo

# Logs
Expand All @@ -29,4 +30,4 @@ pnpm-lock.yaml
# Secrets / environment
.env
*.env
apps/desktop-app/.env
apps/desktop-app/.env
10 changes: 6 additions & 4 deletions Projects/hello_ros/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
services:
bros_helloros:
image: ros:humble
container_name: bros_helloros
bros2_helloros:
image: bros2/ros2-humble:latest
container_name: bros2_helloros
command: bash -lc "sleep infinity"
working_dir: /workspace
tty: true
volumes:
- "/Users/trieutran/BROS2/Projects/hello_ros/workspace:/workspace"
- "/Users/noahhathout/BROS2/Projects/hello_ros/workspace:/workspace"
ports:
- "9090:9090"
85 changes: 77 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="left">
<p align="center">
<img src="assets/logos/BROS2-logo-long.png" alt="BROS2 logo" width="440">
</p>

Expand All @@ -23,6 +23,51 @@ Verify Docker access before continuing:
docker ps
```

## Quick Dev Loop

1. Select Node 20.19.x

```bash
source ~/.nvm/nvm.sh
nvm use 20.19.0
```

2. Refresh deps (clean if things feel stale):

```bash
pnpm install -r
pnpm -r clean # optional, only if builds seem out of date
```

If you did clean, run the workspace builds in the Daily Development section (step 3) before moving on below.

3. Build the ROS image once per machine (safe to rerun):

```bash
pnpm --filter ./apps/desktop-app ros:build-image
```

4. Regenerate the Electron main + preload bundle (needed after a clean):

```bash
pnpm --filter ./apps/desktop-app build:main
```

5. Launch the desktop dev stack (Electron main + Vite renderer):

```bash
pnpm --filter ./apps/desktop-app dev
```

6. In Electron DevTools, bring up ROS 2 + rosbridge when you need it:

```js
await window.runner.up("hello_ros");
await window.runner.exec('bash -lc "source /opt/ros/humble/setup.bash && ros2 launch rosbridge_server rosbridge_websocket_launch.xml"');
```

Skip to the sections below for the full workflow details and tests.

## First-Time Setup

```bash
Expand All @@ -48,13 +93,13 @@ It launches the packaged app once everything compiles. If the script adds an `nv
nvm use 20.19.0
```

2. **Refresh dependencies** after pulling changes:
2. **Refresh dependencies** after pulling changes (rerun `pnpm -r clean` first if builds look stale):

```bash
pnpm install -r
```

3. **Build the workspace libraries** so their `.d.ts` files exist for the Electron main process. Run each filter separately from the repo root (brace expansion is not supported):
3. **Build the workspace libraries** (run this after changing any of these packages so their `.d.ts` files stay fresh for Electron main):

```bash
pnpm --filter @bros2/runtime build
Expand All @@ -64,8 +109,14 @@ It launches the packaged app once everything compiles. If the script adds an `nv
pnpm --filter @bros2/runner build
```

4. **Emit the desktop main + preload bundle** (run from the repo root).
_Do not skip this step after running `pnpm -r clean`; it regenerates the preload bridges and the runtime registry that power `window.runtime`._
4. **Keep the ROS runner image up to date** (once per machine, rerun after touching `packages/services/runner/images/ros2-humble`):

```bash
pnpm --filter ./apps/desktop-app ros:build-image
```

5. **Emit the desktop main + preload bundle** (run from the repo root).
_Do not skip this step after running `pnpm -r clean`; it regenerates the preload bridges and the runtime registry that power `window.runtime`._

```bash
pnpm --filter ./apps/desktop-app build:main
Expand All @@ -77,7 +128,7 @@ It launches the packaged app once everything compiles. If the script adds an `nv
pnpm --filter ./apps/desktop-app build:renderer
```

5. **Start the dev environment** (Electron main + Vite renderer):
6. **Start the dev environment** (Electron main + Vite renderer):

```bash
pnpm --filter ./apps/desktop-app dev
Expand Down Expand Up @@ -116,7 +167,7 @@ await window.runner.exec("ros2 pkg list | head -n 5");
await window.runner.down();
```

This spins up the `bros_hello_ros` container defined in `Projects/hello_ros` and exercises the ROS 2 CLI.
This spins up the `bros2_hello_ros` container defined in `Projects/hello_ros` and exercises the ROS 2 CLI.

### IR build + validation example

Expand Down Expand Up @@ -153,6 +204,21 @@ window.runtime.list(); // ["ArrowKeyPub_1", "ConsoleSub_1"]

If `window.runtime` is missing, run `pnpm --filter ./apps/desktop-app build:main` again to regenerate the preload bridges.

### API cheatsheet (DevTools)

- `window.runner.up(projectName)` – start/update the Docker container `bros2_<projectName>` backed by `bros2/ros2-humble:latest`.
- `window.runner.exec(command)` – run commands like `ros2 topic list` or launching rosbridge:

```js
await window.runner.exec('bash -lc "source /opt/ros/humble/setup.bash && ros2 launch rosbridge_server rosbridge_websocket_launch.xml"');
```

- `window.runner.down()` – stop/remove the ROS 2 container.
- `window.runtime.create(type, config)` – instantiate nodes registered in `apps/desktop-app/src/renderer/runtime/registry.ts` (`ArrowKeyPub`, `ConsoleSub`, `RosbridgeBridge`, `Forwarder`).
- `window.runtime.start(id)`, `window.runtime.stop(id)`, `window.runtime.stopAll()` – control renderer-runtime nodes.
- `window.ir.build(...)` / `window.ir.validate(...)` – convert block graphs to IR and run validators.
- `globalThis.__rosbridge__` – dev-only handle populated by `RosbridgeBridge` with helpers like `publishRos(topic, msg)`.

## Cleaning & Full Rebuild

1. Remove build outputs everywhere (this clears `dist/` folders and `tsconfig.main.tsbuildinfo`, ensuring the desktop main bundle re-emits `dist/main.js`):
Expand Down Expand Up @@ -184,7 +250,10 @@ If `window.runtime` is missing, run `pnpm --filter ./apps/desktop-app build:main
pnpm -r build
```

You may ignore macOS code-sign warnings on local development machines.
## Supporting docs

- [`apps/desktop-app/README.md`](apps/desktop-app/README.md) – ROS 2 quickstart snippet, DevTools walkthrough, and desktop-specific scripts.
- [`packages/services/runner/images/ros2-humble/README.md`](packages/services/runner/images/ros2-humble/README.md) – maintenance notes for the Docker image used by `window.runner`.

## Tips
- Keep Docker running whenever you use `window.runner.*`; the runner manages containers in `Projects/`.
Expand Down
11 changes: 11 additions & 0 deletions apps/desktop-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# BROS2 Desktop

## ROS2 Quickstart (Dev)

Build the local ROS 2 image once before launching the desktop app:

```bash
pnpm --filter ./apps/desktop-app ros:build-image
```

After the app is running (`pnpm -r build` then `pnpm --filter ./apps/desktop-app dev`), open DevTools and execute the runner/runtime snippet from the acceptance checklist to spin up `window.runner`, create a `RosbridgeBridge`, start `ArrowKeyPub`, add a `Forwarder`, and interact with ROS 2 topics.
14 changes: 14 additions & 0 deletions apps/desktop-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
"build:renderer": "vite build --config src/renderer/vite.config.ts",
"start": "cross-env NODE_ENV=production electron ./dist/main.js",
"clean": "rimraf dist release tsconfig.main.tsbuildinfo",
"ros:build-image": "docker build -t bros2/ros2-humble:latest ../../packages/services/runner/images/ros2-humble",
"typecheck": "pnpm tsc -b tsconfig.main.json && pnpm tsc --noEmit -p tsconfig.renderer.json",
"postinstall": "electron-builder install-app-deps"
},
"build": {
"appId": "com.bros2.desktop",
"productName": "BROS2 Desktop",
"icon": "../../assets/logos/bros-logo-icon.ico",
"directories": {
"output": "release"
},
Expand All @@ -29,6 +31,16 @@
"package.json"
],
"asar": true,
"extraResources": [
{
"from": "../../assets/logos/bros-logo-icon.ico",
"to": "bros-logo-icon.ico"
},
{
"from": "../../assets/logos/BROS2-logo.PNG",
"to": "BROS2-logo.PNG"
}
],
"mac": {
"category": "public.app-category.developer-tools",
"target": [
Expand Down Expand Up @@ -60,6 +72,7 @@
"cross-env": "^10.1.0",
"electron": "^39.0.0",
"electron-builder": "^26.0.12",
"electron-devtools-installer": "^4.0.0",
"rimraf": "^6.0.1",
"ts-node": "^10.9.2",
"typescript": "^5.6.3",
Expand All @@ -71,6 +84,7 @@
"@bros2/shared": "workspace:*",
"@bros2/ui": "workspace:*",
"@bros2/validation": "workspace:*",
"@xyflow/react": "^12.9.3",
"bootstrap": "^5.3.8",
"dotenv": "^17.2.3",
"express": "^5.1.0",
Expand Down
Binary file added apps/desktop-app/src/assets/BROS2-logo-long.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/desktop-app/src/assets/BROS2-logo.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading