7. Protocols
7.1 The handheld: teleop UDP v1
The X30 speaks the teleop protocol v1 of Pashupati: the same datagrams, so a handheld of either robot drives the other; the X30’s additions are ignored by a v1 handheld. One UDP port on the navigation host (9870); the handheld sends JSON, the robot answers JSON (control) and chunked binary datagrams (streams). The full reference is x30_bridge/PROTOCOL.md.
7.1.1 Session
The handheld sends
hello(again every second when idle). The robot answerswelcome(its commands, the stick’s limits, the camera names) and the route, then streamsstateat 10 Hz.One driver at a time: another device’s
hellois answeredbusywhile the current one lives; after 2 s of silence the robot drops it and zeroes the stick.With a shared secret (
X30_TELEOP_TOKEN) every message carries"k", compared in constant time; ahellowithout it is answereddenied, anything else dropped.Discovery: a broadcast
{"t": "discover"}is answered by every robot’sbeacon(name,secured,in_use_by, mode, battery), without a token.
7.1.2 Messages
t | Fields | |
|---|---|---|
hello | name, streams | register, keep alive |
joy | vx, vy (m/s), wz (rad/s) | the stick, 20–30 Hz; drives in remote only |
cmd | id, name, args | a command; resent every 200 ms until its ack; runs once per id |
streams | camera, lidar, video, camera_fps, camera_name | which streams |
ack | id, ok (null: pending), msg, data | a command’s answer; long ones (inspect, nav_start) answer pending first |
state | mode, e-stop, field, nav state, pose, battery, health, trip, speed, X30: camera, recorder, substation | the robot |
Commands map one to one onto the stack’s services (Chapter 3): estop, set_mode, nav_start…, record_start, mark_stop, list_routes, load_route, localize, record_tags, dock, nav_speed, trip_reset, and the X30’s recorder_start, recorder_stop, inspect, plus the driver’s robot commands.
7.1.3 Binary streams
Each datagram starts with a 13-byte little-endian header: magic PSH1, u8 stream (1 camera, 2 LiDAR, 3 route), u32 frame, u16 chunk index, u16 chunk count; chunks of at most 1400 bytes. The camera is one JPEG per frame, the LiDAR int16
7.2 NETRA: robot API v1
7.2.1 The WebSocket
/api/v1/robot/ws with Authorization: Bearer <token> and X-Robot-Id. The robot sends hello, telemetry (1 Hz), patrol_event (started, lap, finished), stop_event, alert (blocked, off the path, failed, the e-stop), ack and time_sync; events wait while NETRA is unreachable and the connection comes back with a backoff. NETRA sends commands, acknowledged with the service’s answer:
| Command | The stack |
|---|---|
start_patrol {route_id, patrol_id} | the route and its plan into the site, then navigation/load_path and navigation/start |
stop_patrol, pause, resume | navigation/stop, pause, resume |
localize | localization/start |
estop, estop_release | control/estop_request at once, then control/estop/engage; release |
dock, undock | docking/dock, undock |
recorder_start, recorder_stop | recorder/start, stop |
inspect_point {point} | one NETRA point where the robot stands; refused while moving |
7.2.2 Downloads and uploads
GET /api/v1/robot/routes/<id>/filethe route CSV, into<site>/netra/.GET /api/v1/robot/routes/<id>/inspectionNETRA’s inspection points of the route, by stop: each stop a pointnetra_stop<k>, each NETRA point a targetnetra_<id>(its PTZ pose, its regions, its temperature limit).POST /api/v1/robot/inspectionsone NETRA point’s result, always multipart: ametapart (JSON:uid<robot_id>.<report>.<point>, the time on NETRA’s clock, the patrol, the pose, the ambient, the readings) and the imagesthermal,visual,acoustic. Theuidmakes a retry idempotent.POST /api/v1/robot/routesa route taught on the robot, for NETRA’s route database.
Uploads go through the spool (~/x30/spool): an item leaves the robot’s disk only once NETRA answered it, so nothing is lost offline or across restarts.