# metrox-eth/vector-dimos architecture

> Architecture diagram of the GitHub repository metrox-eth/vector-dimos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/metrox-eth/vector-dimos
- Repository: https://github.com/metrox-eth/vector-dimos

## Overview

#### Purpose and Integration

`vector-dimos` is an external Python blueprint package that integrates the VECTOR holonomic mecanum rover with dimOS. dimOS discovers deployable modules through Python entry points; the normal runtime starts with `dimos run`, notably `vector-dimos.base`, `vector-dimos.gamepad`, and `vector-dimos.rplidar`.

Core integration and blueprint registration live in:
- `vector_dimos/blueprints.py`
- `vector_dimos/nav_blueprints.py`
- `vector_dimos/rig_blueprints.py`

#### Base Motion Control

The base-control path converts a dimOS 3-DOF twist `[vx, vy, wz]` into safe per-wheel velocity commands, drives two dual-channel motor controllers, and returns feedback/odometry. `VectorBaseAdapter` implements dimOS’s `TwistBaseAdapter`; a coordinator subclass ensures adapter registration also occurs in dimOS forkserver workers.

- `vector_dimos/adapter.py`
- `vector_dimos/kinematics.py`
- `vector_dimos/zlac8015d.py`

The hardware boundary is MODBUS RTU over RS485 to two ZLAC8015D controllers. The drive core is standard-library-only until a real serial bus is opened; `VECTOR_MOCK_BUS=1` substitutes the in-memory bus for full control-pipeline testing.

#### Operator Inputs and Sensors

Teleoperation publishes twist commands, while lidar supplies planar point clouds to dimOS perception/navigation. The base consumes the coordinator command channel; commands must be continuously refreshed because dimOS applies a velocity watchdog.

- `vector_dimos/gamepad.py`
- `vector_dimos/rplidar_c1.py`
- `vector_dimos/esp_sensors.py`

Gamepad input uses optional `pygame`; RPLIDAR C1 serial access requires `pyserial` and produces `PointCloud2`. A RealSense D455F is composed from dimOS’s separate camera module; local camera support exists in `vector_dimos/camera.py`.

#### Localization, Persistent Mapping, and Costmap

Lidar odometry provides scan-to-map localization with a gyro prior. The 2D costmap is the decision map: it learns/unlearns obstacles, incorporates camera/lidar evidence, and overlays persistent keep-out zones after other layers so observations cannot erase forbidden space.

- `vector_dimos/lidar_odometry.py`
- `vector_dimos/costmap2d.py`
- `vector_dimos/persistent_map.py`

Persistent state is stored under `~/.local/state/vector/` as versioned `.npz` maps plus `keepout.json`. `PERSISTENT_MAP=0` disables persistence, relocalization, and zones.

#### Relocalization and Distributed Compute

At startup, planar scans are globally matched against the saved 2D map before accepting its coordinate frame. Re-localization also reruns when the robot is moved without wheel motion. This local planar matcher is intentionally separate from dimOS’s 3D reference-map relocalization.

- `vector_dimos/relocalize2d.py`
- `vector_dimos/relocalization.py`
- `tools/rig_runner.py`

A second machine can run the dimOS reference-map relocalization workload via `vector-dimos.reloc-rig`. Robot and rig communicate over the shared zenoh mesh, while namespaced coordinators keep lifecycle control independent.

#### Navigation Safety and Autonomy

Navigation/exploration blueprints combine voxel mapping, costmapping, planning, and recovery. Slip protections compare wheel/body behavior against observed movement; `no_slip_reflex` zones suppress these guards where intentional slip is expected, such as ramps.

- `vector_dimos/explorer2.py`
- `vector_dimos/recovering_planner.py`
- `_perime/slip_detectors_20260826/imu_slip.py`

GPU voxel mapping depends on CUDA-enabled Open3D on Jetson aarch64. Build recipes encode the required JetPack/Open3D workarounds in `tools/four_open3d_cuda.sh` and related scripts.

#### Operations and External Services

Flight launch is gated and defaults to piloted operation; `EXPLORE=1` explicitly arms autonomy. Operational visibility spans both LCM and zenoh, with a panel and change-only state vigil.

- `tools/fly.sh`
- `tools/stats_server.py`
- `tools/vigie_iris.py`

Zone editing is isolated from robot control: a small HTTP service reads/writes only the persistent map and zone file, and is deployable as a systemd service.

- `tools/zone_server.py`
- `tools/zone_ui.html`
- `tools/vector-zones.service`

Main entry points: [`vector_dimos/lidar_odometry.py`](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/lidar_odometry.py) (Lidar odometry), [`vector_dimos/costmap2d.py`](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/costmap2d.py) (2D costmap), [`vector_dimos/rplidar_c1.py`](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/rplidar_c1.py) (RPLIDAR C1), [`vector_dimos/persistent_map.py`](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/persistent_map.py) (Persistent map and zones)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["dimOS runtime"]
  node_entrypoints{{"Deployable entry points<br/>Python entry points"}}
  node_blueprints["Blueprint registration<br/>blueprints<br/>[blueprints.py]"]
  node_rig_blueprints["Rig blueprints<br/>[rig_blueprints.py]"]
  node_coordinator["dimOS coordinators<br/>lifecycle and command channels"]
  node_gamepad["Gamepad teleop<br/>input publisher<br/>[gamepad.py]"]
  node_lidar["RPLIDAR C1<br/>PointCloud2 source<br/>[rplidar_c1.py]"]
  node_sensors["ESP sensors<br/>sensor integration<br/>[esp_sensors.py]"]
  node_zenoh["Shared zenoh mesh<br/>distributed transport"]
  node_reloc_rig["Remote relocation rig<br/>reference-map workload<br/>[rig_runner.py]"]
end

subgraph group_motion["Motion hardware"]
  node_base_adapter["Vector base adapter<br/>TwistBaseAdapter<br/>[adapter.py]"]
  node_kinematics["Mecanum kinematics<br/>twist-to-wheel mixer<br/>[kinematics.py]"]
  node_motor_drivers["ZLAC8015D drivers<br/>dual motor controllers<br/>[zlac8015d.py]"]
  node_rs485["RS485 MODBUS bus<br/>hardware boundary"]
  node_rover["Mecanum rover<br/>physical hardware"]
end

subgraph group_mapping["Mapping and navigation"]
  node_nav_blueprints["Navigation blueprints<br/>[nav_blueprints.py]"]
  node_lidar_odom["Lidar odometry<br/>scan-to-map localization<br/>[lidar_odometry.py]"]
  node_costmap["2D costmap<br/>decision map<br/>[costmap2d.py]"]
  node_persistent_map[("Persistent map and zones<br/>versioned map store<br/>[persistent_map.py]")]
  node_relocalize2d["Planar relocalizer<br/>global scan matcher<br/>[relocalize2d.py]"]
  node_autonomy["Exploration and recovery<br/>navigation pipeline<br/>[explorer2.py]"]
  node_slip_guard["Slip guards<br/>safety reflexes<br/>[imu_slip.py]"]
end

subgraph group_operations["Operations"]
  node_flight_ops["Flight and visibility<br/>operations tooling<br/>[fly.sh]"]
  node_zone_service["Zone editor service<br/>HTTP and systemd service<br/>[zone_server.py]"]
end

node_entrypoints -->|"loads"| node_blueprints
node_blueprints -->|"assembles"| node_coordinator
node_nav_blueprints -->|"assembles"| node_autonomy
node_rig_blueprints -->|"deploys"| node_reloc_rig
node_gamepad -->|"publishes twist"| node_coordinator
node_coordinator -->|"command channel"| node_base_adapter
node_base_adapter -->|"3-DOF twist"| node_kinematics
node_kinematics -->|"wheel velocities"| node_motor_drivers
node_motor_drivers -->|"MODBUS RTU"| node_rs485
node_rs485 -->|"drives and reads feedback"| node_rover
node_lidar -->|"planar scans"| node_lidar_odom
node_sensors -->|"gyro prior"| node_lidar_odom
node_lidar_odom -->|"pose"| node_costmap
node_lidar -->|"obstacle evidence"| node_costmap
node_persistent_map -->|"keep-out overlay"| node_costmap
node_persistent_map -->|"saved 2D map"| node_relocalize2d
node_lidar -->|"startup/move scans"| node_relocalize2d
node_relocalize2d -->|"accepted frame"| node_lidar_odom
node_costmap -->|"decision map"| node_autonomy
node_slip_guard -->|"motion safety"| node_autonomy
node_coordinator -->|"robot namespace"| node_zenoh
node_reloc_rig -->|"rig namespace"| node_zenoh
node_flight_ops -->|"launches"| node_coordinator
node_zone_service -->|"reads and writes"| node_persistent_map

click node_blueprints "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/blueprints.py"
click node_nav_blueprints "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/nav_blueprints.py"
click node_rig_blueprints "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/rig_blueprints.py"
click node_base_adapter "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/adapter.py"
click node_kinematics "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/kinematics.py"
click node_motor_drivers "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/zlac8015d.py"
click node_gamepad "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/gamepad.py"
click node_lidar "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/rplidar_c1.py"
click node_sensors "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/esp_sensors.py"
click node_lidar_odom "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/lidar_odometry.py"
click node_costmap "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/costmap2d.py"
click node_persistent_map "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/persistent_map.py"
click node_relocalize2d "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/relocalize2d.py"
click node_autonomy "https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/explorer2.py"
click node_slip_guard "https://github.com/metrox-eth/vector-dimos/blob/main/_perime/slip_detectors_20260826/imu_slip.py"
click node_reloc_rig "https://github.com/metrox-eth/vector-dimos/blob/main/tools/rig_runner.py"
click node_flight_ops "https://github.com/metrox-eth/vector-dimos/blob/main/tools/fly.sh"
click node_zone_service "https://github.com/metrox-eth/vector-dimos/blob/main/tools/zone_server.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entrypoints,node_blueprints,node_rig_blueprints,node_coordinator,node_gamepad,node_lidar,node_sensors,node_zenoh,node_reloc_rig toneBlue
class node_base_adapter,node_kinematics,node_motor_drivers,node_rs485,node_rover toneAmber
class node_nav_blueprints,node_lidar_odom,node_costmap,node_persistent_map,node_relocalize2d,node_autonomy,node_slip_guard toneMint
class node_flight_ops,node_zone_service toneRose
```

## Components

### dimOS runtime

- **Deployable entry points**: Python entry points · Exposes base, gamepad, lidar, and relocation-rig modules to dimOS.
- [Blueprint registration](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/blueprints.py): blueprints · `vector_dimos/blueprints.py`
- [Rig blueprints](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/rig_blueprints.py): blueprints · `vector_dimos/rig_blueprints.py`
- **dimOS coordinators**: lifecycle and command channels · Namespaced coordinators isolate robot and rig lifecycle control.
- [Gamepad teleop](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/gamepad.py): input publisher · Optional pygame input publishes twist commands. · `vector_dimos/gamepad.py`
- [RPLIDAR C1](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/rplidar_c1.py): PointCloud2 source · pyserial-backed planar scan source. · `vector_dimos/rplidar_c1.py`
- [ESP sensors](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/esp_sensors.py): sensor integration · `vector_dimos/esp_sensors.py`
- **Shared zenoh mesh**: distributed transport
- [Remote relocation rig](https://github.com/metrox-eth/vector-dimos/blob/main/tools/rig_runner.py): reference-map workload · Runs dimOS 3D reference-map relocalization on a second machine. · `tools/rig_runner.py`

### Motion hardware

- [Vector base adapter](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/adapter.py): TwistBaseAdapter · Registers in forkserver workers and consumes watchdog-refreshed twist commands. · `vector_dimos/adapter.py`
- [Mecanum kinematics](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/kinematics.py): twist-to-wheel mixer · `vector_dimos/kinematics.py`
- [ZLAC8015D drivers](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/zlac8015d.py): dual motor controllers · `vector_dimos/zlac8015d.py`
- **RS485 MODBUS bus**: hardware boundary · Mock bus is selected with VECTOR_MOCK_BUS=1.
- **Mecanum rover**: physical hardware

### Mapping and navigation

- [Navigation blueprints](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/nav_blueprints.py): blueprints · `vector_dimos/nav_blueprints.py`
- [Lidar odometry](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/lidar_odometry.py): scan-to-map localization · Uses a gyro prior. · `vector_dimos/lidar_odometry.py`
- [2D costmap](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/costmap2d.py): decision map · Fuses evidence, learns obstacles, and applies zones last. · `vector_dimos/costmap2d.py`
- [Persistent map and zones](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/persistent_map.py): versioned map store · Stores .npz maps and keepout.json under the local state directory. · `vector_dimos/persistent_map.py`
- [Planar relocalizer](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/relocalize2d.py): global scan matcher · Separately matches planar scans against the saved 2D map. · `vector_dimos/relocalize2d.py`
- [Exploration and recovery](https://github.com/metrox-eth/vector-dimos/blob/main/vector_dimos/explorer2.py): navigation pipeline · Combines voxel mapping, planning, recovery, and slip safety. · `vector_dimos/explorer2.py`
- [Slip guards](https://github.com/metrox-eth/vector-dimos/blob/main/_perime/slip_detectors_20260826/imu_slip.py): safety reflexes · no_slip_reflex zones suppress guards where slip is intentional. · `_perime/slip_detectors_20260826/imu_slip.py`

### Operations

- [Flight and visibility](https://github.com/metrox-eth/vector-dimos/blob/main/tools/fly.sh): operations tooling · Piloted by default; EXPLORE=1 arms autonomy. · `tools/fly.sh`
- [Zone editor service](https://github.com/metrox-eth/vector-dimos/blob/main/tools/zone_server.py): HTTP and systemd service · Edits only persistent maps and keep-out zones. · `tools/zone_server.py`

## Connections

- Deployable entry points → Blueprint registration: loads
- Blueprint registration → dimOS coordinators: assembles
- Navigation blueprints → Exploration and recovery: assembles
- Rig blueprints → Remote relocation rig: deploys
- Gamepad teleop → dimOS coordinators: publishes twist
- dimOS coordinators → Vector base adapter: command channel
- Vector base adapter → Mecanum kinematics: 3-DOF twist
- Mecanum kinematics → ZLAC8015D drivers: wheel velocities
- ZLAC8015D drivers → RS485 MODBUS bus: MODBUS RTU
- RS485 MODBUS bus → Mecanum rover: drives and reads feedback
- RPLIDAR C1 → Lidar odometry: planar scans
- ESP sensors → Lidar odometry: gyro prior
- Lidar odometry → 2D costmap: pose
- RPLIDAR C1 → 2D costmap: obstacle evidence
- Persistent map and zones → 2D costmap: keep-out overlay
- Persistent map and zones → Planar relocalizer: saved 2D map
- RPLIDAR C1 → Planar relocalizer: startup/move scans
- Planar relocalizer → Lidar odometry: accepted frame
- 2D costmap → Exploration and recovery: decision map
- Slip guards → Exploration and recovery: motion safety
- dimOS coordinators → Shared zenoh mesh: robot namespace
- Remote relocation rig → Shared zenoh mesh: rig namespace
- Flight and visibility → dimOS coordinators: launches
- Zone editor service → Persistent map and zones: reads and writes
