All tools

Mission Runner

Declarative Nav2 missions that run headless on the robot: what starts them, what they do, and what may interrupt them, in one JSON file.

Docs

Build and run Nav2 robot missions without writing code.

A mission is a JSON file: when it starts (MQTT, a ROS topic, a PLC flag, a schedule, a button, an HTTP call, another mission finishing), what it does (every nav2_simple_commander call, loops, conditions, retries, waiting for external events, asking a person), and what may interrupt it (low battery, e-stop). mission_runner runs on the robot as an always-on service and needs no operator and no internet. The editor is a web page served by the robot (or run on a laptop) for building, deploying and watching missions; the same JSON can be exported as a plain Python script.

┌──────────── Windows / laptop / phone ────────────┐      ┌────────────── robot (Raspberry Pi 5, ROS 2 Jazzy) ──────────────┐
│ editor (web page)  ──HTTP/WS──▶ mission_runner   │      │ mission_runner ──▶ Nav2 (BasicNavigator, BT XML per goal)        │
│ iViz / any ROS node ──services/actions/topics──▶ │      │   ▲ triggers: MQTT · ROS topics · Modbus · GPIO · cron · webhook │
│ PLC / Node-RED ──Modbus / HTTP──▶                │      │   ▼ state: /mission/state · MQTT · WebSocket · run log (SQLite)  │
└──────────────────────────────────────────────────┘      └───────────────────────────────────────────────────────────────────┘

Repository

Path What
runner/ mission_runner ROS 2 (ament_python) package: interpreter, dispatcher, connectors, HTTP/WS API, web page. Runs without ROS in --sim mode.
mission_msgs/ RunMission service/action and Answer service (optional; the runner works without it).
editor/ Web mission editor (Vite + TypeScript), served by the runner. Still works, but Mission Builder is where missions are built now.
examples/ Example missions (the four sample scripts as missions, plus PLC pickup, patrol, charging, e-stop) and sites.json.
docs/mission-format.md The mission format: steps, triggers, policies, expressions.
docs/runner-api.md HTTP, WebSocket and ROS interfaces of the runner.
Mission Builder (phuwanat-vg/mission-builder) The Windows desktop application for building missions: the mission tree, the map and the route graph, maps, deploy, run and export. See docs/mission-builder-app.md.
docs/iviz-route-mode.md Route mode in iViz (parked: the button is greyed out in iViz 0.1.0): drawing the route graph, stops and their actions, over one foxglove_bridge connection.
docs/first-run-on-robot.md Checklist for the first run on real hardware: install, start order, what to check at each step, what usually goes wrong.
install.sh One-command install and update on a ROS 2 Jazzy robot.
docs/robot-startup.md bringup.launch.py, the station_answer node and autostart services (start the robot and the mission layer at boot).
docs/example-nodes.md Example ROS 2 nodes to copy: start a mission, answer its requests, trigger it from a topic, watch and stop runs.
docs/editor-spec.md Web editor design and behavior (legacy).

Quick start without a robot (any OS)

git clone https://github.com/phuwanat-vg/mission-runner.git && cd mission-runner
python -m venv .venv && . .venv/bin/activate     # Windows: .venv\Scripts\activate
pip install -r runner/requirements.txt
cd editor && npm install && npm run build && cd ..
cd runner && python -m mission_runner run --sim --port 8080

Open http://localhost:8080. The example missions are installed into ~/.mission on first start; press Run on go_to_point and watch the simulated robot drive. The sim mode also exposes POST /api/sim/topic (inject a ROS message, e.g. a low battery) and POST /api/sim/robot (move the robot, set the battery, block the path).

Install on the robot

Doing this for the first time? Follow docs/first-run-on-robot.md — same steps, plus what to verify at each stage and what usually goes wrong.

One command (Ubuntu 24.04 + ROS 2 Jazzy; run it again to update):

curl -fsSL https://raw.githubusercontent.com/phuwanat-vg/mission-runner/main/install.sh | bash
# options: ... | bash -s -- --ws ~/robot_ws --domain 7 --project ~/line2.mproj --no-autostart

It clones into ~/ros2_ws/src/mission-runner (or pulls), runs rosdep install, builds mission_msgs and mission_runner, turns on linger, creates the mission autostart service and prints the ws://<ip>:8765 address to type into Mission Builder. sudo is asked once.

By hand:

cd ~/ros2_ws/src && git clone https://github.com/phuwanat-vg/mission-runner.git
cd ~/ros2_ws && rosdep install --from-paths src -y --ignore-src     # apt packages, incl. foxglove_bridge
colcon build --packages-select mission_msgs mission_runner && source install/setup.bash
# optional: pip install pymodbus; sudo apt install python3-gpiozero
ros2 launch mission_runner bringup.launch.py        # mission_runner + foxglove_bridge (+ station answer nodes)

bringup.launch.py takes project:=FILE (import a project before starting), bridge:=true, stations:=FILE (a station_answer node per station), sim:=, home:=, port:=; see docs/robot-startup.md. mission_runner.launch.py still starts the runner alone.

Start at boot, as systemd user services (no root; Mission Builder has the same under Robot startup):

sudo loginctl enable-linger $USER      # once: user services start at boot without a login
mission_runner autostart add robot --launch ~/robot_ws/src/my_robot/launch/robot.launch.py   # your drivers + Nav2
mission_runner autostart add mission --package mission_runner --launch bringup.launch.py --after robot --start
mission_runner autostart list          # also start|stop|restart|log|remove NAME

Then:

  1. Copy runner/config/runner.example.yaml to ~/.mission/runner.yaml and set nav2.localizer (amcl, or "" with FAST-LIO2).
  2. Copy runner/config/connectors.example.yaml to ~/.mission/connectors.yaml for MQTT / Modbus; put secrets in /etc/mission_runner.env.
  3. Open http://<robot>:8080 from any browser on the LAN, or connect Mission Builder to ws://<robot>:8765, build a mission, Deploy.

Writing your own nodes that start missions, answer their questions or watch them? Copy one of the example nodes (ros2 run mission_runner example_start_mission, ...).

Build the editor once (cd editor && npm run build) before colcon build so the web page is bundled; without it the robot serves a minimal status page (STOP, run buttons, prompts) that still works from a phone.

How it works

  • Mission = data. docs/mission-format.md is the contract. The editor, the runner and the Python exporter all consume the same JSON.
  • Runner = the brain. One active run at a time, a priority queue, suspended runs that resume where they stopped, and dispatch policies (queue, preempt, preempt_latest, reject_if_busy, interrupt_and_resume). Triggers are armed the moment a mission is deployed and stay armed after every reboot. Everything that happens is recorded in runs.sqlite and streamed over WebSocket, /mission/event and MQTT.
  • Nav2 stays Nav2. Steps map one to one onto BasicNavigator; a per-step behavior_tree template is expanded to a Nav2 BT XML file, so recovery behavior can differ per goal without touching the global configuration.
  • Offline first. Local MQTT broker, LAN web page, GPIO buttons, cron and PLC flags all work with no internet; cloud connectors reconnect on their own and never block a mission.

Development

cd runner && python -m pytest          # 139 tests, sim backend, ~1.5 min
cd editor && npm test && npm run build

mission_runner validate examples/*.json --sites examples/sites.json checks mission files from the command line; mission_runner bt '{"template": "navigate_with_recovery"}' prints a behavior tree.

Roadmap

  • Graph view and a Nav2 behavior-tree editor with the nav2_behavior_tree node palette (the data model already carries per-step trees).
  • Pose picking on the map inside iViz (the editor exposes a pose callback; iViz already has the click-and-drag goal tool).
  • parallel step and per-waypoint task executor options for nav.follow_waypoints.
  • Open-RMF task adapter.

License

Apache-2.0