We can build a robot control protocol that works with any HTTP‑capable device and streams video using MJPEG. The result is a lightweight, easy‑to‑debug interface that developers can adopt quickly.
The core idea is to expose a few REST‑like endpoints for commands and a continuous MJPEG endpoint for live video.
Why choose HTTP and MJPEG for robot control
Simplicity of plain HTTP
HTTP is universally supported; every device that can reach a robot already knows how to issue GET or POST requests. You do not need a custom binary protocol stack or special libraries. A typical command looks like POST /move?dir=forward&speed=50, which any language can build with a single line of code. Because the Carpathron Robot Protocol is built on HTTP, you can test commands with a browser or curl without installing extra tools. This lowers the entry barrier for hobbyists and speeds up debugging.
Statelessness also helps. Each request carries all the information the robot needs to act, so you avoid session management complexities. If the robot restarts, the client simply sends the next command; no reconnection handshake is required. The trade‑off is a modest increase in latency compared to a persistent TCP stream, but for low‑speed locomotion the delay is negligible.
Why MJPEG for video streaming
MJPEG delivers a continuous series of JPEG frames over a single HTTP connection. The robot’s ESP32‑CAM can serve the stream at /video.mjpg without transcoding. Clients receive frames as they arrive, which means you get a live view with minimal buffering. Unlike H.264 or WebRTC, MJPEG does not require a separate signaling channel or codec negotiation, keeping the implementation lightweight.
Because MJPEG uses standard HTTP headers, you can embed the stream in an <img> tag or view it in any browser. This matches the Carpathron Avatar’s ability to show the robot camera on Meta Quest 3/3S without additional plugins. The main downside is higher bandwidth consumption; each frame is a full JPEG image, so you should limit resolution or frame rate on constrained networks.
Combining plain HTTP commands with an MJPEG video feed gives you a uniform, firewall‑friendly stack. No special ports, no NAT traversal tricks, and you can reuse existing web infrastructure for both control and monitoring. For a quick prototype, this approach lets you focus on robot behavior rather than networking plumbing.
Core endpoints of the robot control protocol
/cmd – command dispatcher
This endpoint receives a JSON payload that describes a single robot action. The payload must contain a type field (e.g., "move", "turn") and a params object with numeric values such as speed or angle. The server validates the request, queues it, and returns a 202 status with a short identifier that can be used to query execution state later. I prefer keeping the JSON flat; nested structures add parsing overhead on low‑power ESP32‑CAM boards.
/status – state reporter
A GET request to /status returns a JSON document with the robot’s current pose, battery level, and any active error flags. The response includes a lastCmdId field so you can match the identifier from /cmd with the reported state. If the robot is idle, the mode key reads "standby". This endpoint is safe to poll every few seconds; it does not trigger any motion.
/video – MJPEG stream
Connecting to /video opens an HTTP multipart response that continuously delivers JPEG frames from the onboard camera. The Carpathron Robot Protocol uses the standard MJPEG MIME type (multipart/x-mixed-replace;boundary=frame), so any browser or <img> tag can render the live feed without extra plugins. The stream runs independently of /cmd and /status, which means you can monitor video while issuing commands.
Minimal set summary
- /cmd – POST JSON to move or act.
- /status – GET current telemetry.
- /video – GET MJPEG live view.
These three URLs cover the essential control loop: issue a command, verify execution, and watch the robot. For deeper integration, see the Carpathon robotics page at /robotics or the product description at /products.
How to send a movement command over HTTP
To make a robot move you issue a POST request to the /move endpoint of the Carpathron Robot Protocol. The body must be JSON, and the server replies with a standard HTTP status code indicating success or failure. Below is a concrete example that works with the Baby Carpathron ESP32‑CAM robot car.
- Open a terminal or use a HTTP client library in your preferred language. The target URL is
http://<robot‑ip>/move. - Construct a JSON payload that contains three fields:
direction,speed, andduration.directionaccepts"forward","backward","left"or"right".speedis an integer from 0 to 255.durationis the time in milliseconds the robot should travel. - Example payload:
{ "direction": "forward", "speed": 180, "duration": 1500 } - Send the POST request with the
Content-Type: application/jsonheader. Incurlthe command looks like:curl -X POST http://192.168.1.42/move -H "Content-Type: application/json" -d '{"direction":"forward","speed":180,"duration":1500}' - Wait for the robot’s response. A
200 OKstatus means the command was accepted and queued. Any 4xx or 5xx code signals a problem – for instance400 Bad Requestif a field is missing or out of range. - If the response includes a JSON body, it usually contains a
statusfield such as"queued"or"error". Log this value for debugging. - Repeat the request for subsequent moves, adjusting the fields as needed. Keep the interval between commands short enough to avoid buffer overflow on the robot.
- For a complete reference of all supported endpoints, see the Carpathron robotics page. If you need to integrate this flow into a larger system, the same pattern works with the Carpathron Robotics & Coding Windows app.
Streaming live video with MJPEG
Serving a multipart JPEG stream
The Baby Carpathon ESP32‑CAM robot car implements the open Carpathon Robot Protocol over HTTP. To expose video, the device runs a lightweight HTTP server that responds to /video.mjpeg with a multipart response. Each part begins with a boundary line, followed by Content-Type: image/jpeg and the JPEG payload. The server continuously captures frames from the camera and writes them to the response stream, flushing after each JPEG.
Reading the stream on a client
On a Windows workstation you can open the stream with any HTTP‑capable client. For quick testing, a browser navigates to http://robot-ip/video.mjpeg and renders the moving image automatically. In code, a simple loop reads the response, splits on the boundary string, extracts the JPEG bytes, and feeds them to an Image control. The Carpathon robotics documentation shows a minimal C# snippet that uses HttpClient and a StreamReader to handle the multipart data.
Bandwidth and performance considerations
Each JPEG frame size depends on resolution and compression quality. A 640×480 frame at 70 % quality typically occupies 30–50 KB. At 15 fps this translates to roughly 4–6 Mbps upstream from the robot. If the network is constrained, lower the resolution or increase compression; the ESP32‑CAM firmware lets you adjust these parameters via HTTP query strings, e.g., /video.mjpeg?res=320x240&quality=50.
Because MJPEG repeats full images, latency is low but bandwidth usage is higher than modern video codecs. For battery‑powered robots, monitor the robot’s Wi‑Fi signal strength and consider throttling the frame rate during long missions. When multiple clients connect, the robot serves the same stream to each, multiplying the bandwidth demand. A single dedicated viewer is safest for reliable operation.
Extending the protocol safely for next week’s features
Versioning the API
Introduce a version segment in every URL, for example /v2/command. Keep the previous version active until all clients have migrated. I recommend incrementing the major number only when you remove or change existing fields; minor bumps can add optional parameters. Document each version on the QuBIOS project page so developers can compare schemas side by side.
Adding new command types
Define a new JSON field called type that enumerates actions such as move, rotate, or arm_extend. When you need a fresh command, add a new enum value rather than overloading an existing one. The server should reject unknown types with a 400 response, which forces the client to handle upgrades explicitly. I prefer to keep the payload flat; nested objects increase parsing overhead on low‑power boards.
Testing strategies
Set up an automated test suite that runs against a simulated robot exposing the same HTTP endpoints. Use unit tests for request validation and integration tests that stream a short MJPEG clip to verify bandwidth handling. Run the suite on each commit and on a separate branch that targets the new API version. For live verification, deploy the new version to a dedicated test robot and exercise every new command via curl or a simple Python script.
Iterative rollout
Start with a feature flag that toggles the new version on the server. Enable it for a single robot, observe logs for unexpected payloads, then gradually expand. If a regression appears, roll back the flag without affecting the stable version. This approach mirrors the incremental development shown on the QuBIOS page and keeps your control protocol reliable while you add functionality.
Frequently asked questions
How do I secure the HTTP endpoints without adding TLS?
You can restrict access by placing the robot on a private LAN and using firewall rules to allow only trusted IP ranges. Adding a token query parameter or an HTTP header that the robot validates before processing any request also helps. Combine both approaches for a simple, TLS‑free security layer.
Can the protocol work on low‑power microcontrollers like ESP32?
The Carpathron Robot Protocol uses plain HTTP for commands and an MJPEG stream for video, both of which are supported by the ESP32‑CAM firmware. The ESP32 can serve JPEG frames over an HTTP endpoint and listen for short GET/POST requests without heavy processing. Keep the command set minimal to stay within the MCU’s RAM and CPU limits.
Wrapping up the open robot protocol
I recommend you prototype the HTTP commands on a single ESP32‑CAM board before scaling to a fleet. Keep the MJPEG stream lightweight: limit resolution to 640×480 and use a modest frame rate to avoid saturating Wi‑Fi. If you later need secure control, add TLS at the reverse‑proxy level rather than re‑engineering the robot firmware. Test error handling aggressively; a dropped packet should trigger a safe‑stop routine on the robot. Once the basics work, you can integrate the Carpathron Avatar for visual feedback, which lets you steer by head movement. The next step is to publish a concise API reference on your internal wiki and point developers to the most relevant Qubitpage page for the latest protocol details.




