Skip to content
Atreyu Sutton

Hardware / Software

TorQ

A tracked garage robot that listens, answers car-repair questions out loud with Claude, and keeps its safety logic off the network. Built by a team of four.

  • Python
  • Anthropic API
  • Tool use
  • Prompt caching
  • Whisper
  • Piper
  • Raspberry Pi
  • Arduino
  • asyncio
  • WebSockets
  • 3D printing
In the garage with the 1988 4Runner it was built to help with.1 / 15
wait before it starts answering, first version to now
90 s to 1 s
integration tests, all passing
20
tools the model can call
4
motor watchdog, in firmware
300 ms

The 90 seconds is what we saw with the first version, not a logged measurement. About 1 second is Claude Haiku to first spoken words on the current build.

TorQ is a small tracked robot for a home garage. You ask it a question while your hands are on a wrench, like "what's the lug nut torque on my Civic?", and it answers through a speaker. It remembers which vehicle you are working on and keeps job notes. You can also drive it from a browser dashboard.

Four of us built it. Diya and Spatika wrote the first version of the software, Zach designed and built the enclosure, and I did the electronics and the code it runs now.

The part I want an AI/ML reader to look at is the voice assistant: speech in, a streaming tool-use loop written directly against the Anthropic SDK, and speech out. The other thing worth a minute is how the software got from a 90 second wait to about one second, which is the section called "Then and now".

01

Spec

LaneHardware / Software
StatusRunning
RoleElectronics, wiring and all of the current software: Claude tool loop, speech in and out, body service, drive firmware, dashboard and tests
TeamFour people. Diya and Spatika wrote the first version of the software. Zach designed and built the enclosure. I did the hardware and the code it runs now.
StartedSeptember 2026
ModelsClaude Haiku 5.5 at low effort and Claude Sonnet 5.5 at medium effort, through the Anthropic API
StackPython, asyncio, aiohttp, WebSockets, Anthropic SDK, faster-whisper, Piper, C++ firmware, pytest
HardwareRaspberry Pi 5, Arduino Uno R3 with Motor Shield Rev3, two 12 V gearmotors on tracks, Logitech C920, USB speaker, 3S battery pack, PLA enclosure

02

Team

Four people, one robot

This was a group build, and the robot in the photos is the sum of three kinds of work. This page is mostly about my part, so here is who did what.

  • Diya and Spatika

    First version of the software

    Wrote the first version: a wake word, speech recognition, a search over the service manuals and a spoken answer, all running on the Raspberry Pi.

  • Zach

    Enclosure

    Designed and built the whole enclosure, printed in PLA. Everything you see in black on the outside is his.

  • Atreyu

    Hardware and current code

    The electronics and wiring, the drive firmware, and the rewrite of the software into the body and brain split described below.

03

Then and now

From 90 seconds to about one

The first version of the software, written by Diya and Spatika, proved the idea, and it did a lot. You said "Hey TorQ", asked a question, and it searched the service manuals and answered out loud with the page it came from.

Nearly all of that ran on the Raspberry Pi inside the robot: a Vosk wake-word model listening all the time, Whisper on the CPU, an embedding search over the manuals, and a Piper process started fresh for each reply. Only the language model call left the board. The code's own notes record Piper taking about 3 seconds just to start, and a larger wake-word model was killed for running out of memory. On a 4 GB Pi it added up to about 90 seconds for a response. That is too long to stand there holding a wrench.

I rewrote the software around one question: what actually has to be on the robot? Very little. The Pi keeps the jobs that touch hardware, which are the microphone, the speaker, the camera and the motors. The speech models run on a laptop on the same network, with Piper loaded once instead of started for each reply. Stopping the motors went the other way, down to an Arduino, so it does not depend on either computer being healthy.

Two versions of the same robot. In the first version one Raspberry Pi 5 ran the Vosk wake word, Whisper speech-to-text on the CPU, a bge-small search over the manuals, Piper text-to-speech started for each reply, and the drive scripts, and called a cloud model over HTTPS for the answer. A response took about 90 seconds. In the current version a Mac runs Whisper, the Claude tool loop, Piper, job memory and the dashboard. It connects by WebSocket to the Raspberry Pi 5, which only handles the microphone, speaker, camera stream and motor commands. The Pi connects by USB serial to an Arduino Uno that runs the motors, the watchdog and the E-stop. The robot now starts answering in about 1 second.

Then

Nearly everything on the Pi

  1. Raspberry Pi 5, 4 GB

    • Vosk wake word, always listening
    • Whisper (base.en) on the CPU
    • bge-small search over the manuals
    • Piper, started for each reply
    • Drive scripts, run over SSH
  2. Connected by HTTPS:

    Cloud model

    • Reads the manual page, writes the answer

about 90 sfor a response

Now

Each job on the right computer

  1. Mac, the brain

    • Whisper (small.en)
    • Claude tool loop, streaming
    • Piper, kept loaded
    • Job memory, dashboard
  2. Connected by WebSocket:

    Raspberry Pi 5, the body

    • Microphone and speaker
    • Camera stream
    • Motor commands, clamps
  3. Connected by USB serial:

    Arduino Uno

    • Motors, watchdog, E-stop

about 1 sto first spoken words, on Claude Haiku

Moving the work is most of the gain, but not all of it. The reply is also streamed. TorQ starts speaking the first sentence while Claude is still writing the second, so the wait you feel is the time to the first sentence and not the time to the whole answer.

The rewrite is faster, but it does not yet do everything the first version did. The wake word and the manual search with page numbers have not been carried across. Both are under "What is next".

04

Architecture

A body and a brain

The robot is split in two on purpose. Anything slow or expensive, meaning the speech models and the language model, runs on the laptop. Anything that has to keep working when the network drops, meaning stopping the motors, runs on the robot.

Three computers in a chain. A Mac, the brain, runs the brain server, Whisper speech-to-text, the Claude tool loop, Piper text-to-speech, job memory and the browser dashboard. It talks over a WebSocket, carrying JSON and binary audio frames in both directions, to a Raspberry Pi 5, the body, which runs motor control with clamps and trim, microphone capture, speaker playback, telemetry and the camera stream. The Pi talks over USB serial, in both directions, to an Arduino Uno with a motor shield running the drive firmware: a 300 ms watchdog, a latched E-stop, an overcurrent cutoff, ramping and active braking.
  1. Mac, the brain

    Brain server (aiohttp). Whisper speech-to-text, the Claude tool loop, Piper text-to-speech, job memory, browser dashboard.

    Slow and expensive work lives here.

  2. Then, WebSocket, both ways: JSON and binary audio frames:

    Raspberry Pi 5, the body

    Body service (Python, asyncio). Motor control, clamps and trim. Mic capture, speaker playback, telemetry, camera stream (MJPEG).

    Runs headless. Starts on boot under systemd.

  3. Then, USB serial, both ways:

    Arduino Uno and motor shield

    Drive firmware (C++). 300 ms watchdog, latched E-stop, overcurrent cutoff, ramping, active braking.

    Keeps working with no network at all.

05

LLM loop

How the AI part works

The loop is written directly against the Anthropic SDK, with no agent framework. Each question is routed first. Everyday questions go to Claude Haiku 5.5 at low effort, for speed. Questions that look diagnostic, containing words like "why", "noise", "leak" or "misfire", go to Claude Sonnet 5.5 at medium effort.

The model has four tools: get_vehicle_info, set_vehicle, save_note and stop. Every tool input is validated in code before anything runs. A bad input goes back to the model as an error result instead of executing. The loop is capped at 6 tool rounds per question.

Reply text streams from the model into a sentence chunker. Each complete sentence is synthesized and sent to the robot while the model is still writing the rest, so the robot starts talking before the answer is finished. A new question, or the Quiet button, cancels the answer in flight and the audio already queued on the robot.

One question, start to finish. A question arrives by push-to-talk or typed. Whisper transcribes it on the laptop. A router picks Haiku or Sonnet. Claude streams a turn, and if it calls a tool the input is validated, the tool runs and the result goes back, for up to 6 rounds. Reply text goes through a sentence chunker, each sentence is synthesized by Piper, and the audio plays on the speaker on the Pi.
  1. Question

    Hold T on the dashboard to talk, or type it.

  2. Then, microphone audio from the Pi:

    1Transcribe

    faster-whisper (small.en), local on the laptop, primed with shop vocabulary.

  3. Then, text:

    2Route

    Haiku at low effort, or Sonnet at medium effort for diagnosis.

  4. 3Claude, streaming

    System prompt, tool definitions and the growing conversation are all cached.

    Tool call? Validate the input, run it, send the result back. Up to 6 rounds.

  5. Then, reply text, as it streams:

    4Sentence chunker

    Waits for a whole sentence, then hands it on.

  6. Then, one sentence at a time:

    5Speak

    Piper text-to-speech on the laptop, played on the speaker on the Pi.

    A new question or Quiet cancels everything queued.

brain/claude.py: the tool loop, trimmed of logging
for _round in range(self.cfg.max_tool_rounds):
    final = await self._stream_turn(model, effort, emit)
    self.messages.append({"role": "assistant", "content": final.content})

    if final.stop_reason == "refusal":
        await emit(" Sorry, I can't help with that one.")
        return "".join(reply_parts)

    tool_uses = [b for b in final.content if b.type == "tool_use"]
    if not tool_uses:
        return "".join(reply_parts)
    if final.stop_reason == "max_tokens":
        # A truncated tool input can parse as a valid partial object; don't run it.
        raise ClaudeUnavailable("My answer got cut off. Try asking a shorter question.")

    results = []
    for block in tool_uses:
        content, is_error = await run_tool(block.name, block.input, self.tools_ctx)
        results.append({"type": "tool_result", "tool_use_id": block.id, "content": content, "is_error": is_error})
    # All results for one assistant turn go back in a single user message.
    self.messages.append({"role": "user", "content": results})

raise ClaudeUnavailable("I got stuck going back and forth with my tools. Try asking again.")
  1. 1The loop is capped at 6 rounds per question, so the model cannot go back and forth with its tools forever.
  2. 2Each round streams. Text reaches emit as it arrives, which is what feeds the speech pipeline.
  3. 3A refusal becomes a sentence TorQ can say, not silence.
  4. 4A tool call that was cut off mid-input is never run, even if the partial input happens to parse.
  5. 5run_tool validates the input first. A bad input comes back as an error result for the model to read.
  6. 6Every way out of the loop is either an answer or a short spoken explanation.

The system prompt is written for speech: no markdown, units spelled out ("eighty foot-pounds"), answer first. It tells the model to say so plainly when it is not confident in a number, and to point to the service manual.

Failure handling is written for a voice interface. Every API failure, whether a bad key, a rate limit, no network, a refusal or a truncated tool call, maps to a short sentence TorQ can say aloud. The user is never left with silence.

Prompt caching covers the system prompt, the tool definitions and the growing conversation. The system prompt is frozen and the tool order is fixed, so the cached prefix stays valid.

06

Speech

Talking before it has finished thinking

Speech-to-text and text-to-speech both run locally on the laptop: faster-whisper for listening and Piper for speaking. Whisper is primed with shop vocabulary so "MAF sensor" and "foot-pounds" transcribe correctly.

The piece that makes it feel fast is small. Reply text streams from Claude into a chunker that hands on one whole sentence at a time. Each sentence is synthesized and sent to the robot's speaker while the model is still writing the next one.

brain/speech.py: SentenceChunker.feed
_SENTENCE_END = re.compile(r"(?<=[.!?])\s+|\n+")

def feed(self, text: str) -> list[str]:
    self._buf += text
    out = []
    while True:
        m = None
        for cand in _SENTENCE_END.finditer(self._buf):
            if cand.start() >= self._min:
                m = cand
                break
        if m is None:
            return out
        sentence, self._buf = self._buf[: m.start()].strip(), self._buf[m.end():]
        if sentence:
            out.append(sentence)
  1. 1A sentence ends at a full stop, question mark or exclamation mark followed by a space, or at a line break.
  2. 2A break in the first 12 characters is skipped, so a very short opener is spoken together with what follows it.
  3. 3No whole sentence yet: keep the text and wait for more from the model.
  4. 4The finished sentence leaves for Piper. Whatever follows it stays in the buffer.

07

Session

One real conversation, and what happened behind it

Three questions in a row: a spec, a diagnosis and a request to save a note. Under each answer is what the brain did to produce it, taken from its own log. The first question goes to Haiku, which records the vehicle and saves a note before it finishes answering. The second contains "why", so it goes to Sonnet.

A three-question conversation with TorQ. For each answer the trace lists which Claude model was chosen, which tools it called, and how long it took.
  1. You

    I'm working on a 2015 Honda Civic with the 1.8. What's the lug nut torque?

  2. TorQ

    On a 2015 Civic, the lug nuts should be tightened to about eighty foot-pounds. Check the owner's manual to confirm, and tighten in a star pattern. Saving that now. The lug nut torque for your 2015 Civic is about eighty foot-pounds, tightened in a star pattern. I've saved that to the job notes. Confirm it in the owner's manual before you finish.

    Route
    Claude Haiku 5.5, low effort
    Tool
    set_vehicle: 2015 Honda Civic, 1.8 liter
    Tool
    save_note: 1 note on the job
    Cache
    1,225 then 1,407 input tokens read from the prompt cache
    Time
    4.1 s, three Claude calls
  3. You

    It squeals for a few seconds on a cold start, then goes quiet. Why?

  4. TorQ

    Most likely it's the serpentine belt. A belt that's worn, glazed, or loose will slip and squeal when cold, then quiet down as it warms up. Damp mornings make it worse.

    Look at the belt for cracks, shiny glazing, or fraying. Your Civic has an automatic tensioner, so a weak tensioner or a noisy pulley bearing can cause the same squeal. With the engine off, you can check the belt by hand. Don't touch it while the engine is running.

    Route
    Claude Sonnet 5.5, medium effort, because the question asks "why"
    Tool
    none
    Time
    2.0 s, one Claude call
  5. You

    Save a note that the serpentine belt needs replacing.

  6. TorQ

    I've saved the note that the serpentine belt needs replacing. I worded it as likely, since we haven't inspected the belt or tensioner yet.

    Route
    Claude Haiku 5.5, low effort
    Tool
    save_note: 2 notes on the job
    Cache
    1,682 then 1,960 input tokens read from the prompt cache
    Time
    2.4 s, two Claude calls

A real session from 13 November 2026, typed into the dashboard. Times are from the brain log, question to finished text.

The brain log for the first two questions
2026-11-13 14:26:49,621 INFO torq.claude: asking claude-haiku-5-5 (effort low): "I'm working on a 2015 Honda Civic with the 1.8. What's the lug nut torque?"
2026-11-13 14:26:51,163 INFO torq.claude: claude-haiku-5-5 done: stop=tool_use in=4 cache_read=1225 cache_write=0 out=124
2026-11-13 14:26:51,163 INFO torq.claude: tool set_vehicle -> {"ok": true, "vehicle": {"year": 2015, "make": "Honda", "model": "Civic", "engine": "1.8 liter"}}
2026-11-13 14:26:52,897 INFO torq.claude: claude-haiku-5-5 done: stop=tool_use in=2 cache_read=1225 cache_write=182 out=256
2026-11-13 14:26:52,898 INFO torq.claude: tool save_note -> {"ok": true, "notes": 1}
2026-11-13 14:26:53,762 INFO torq.claude: claude-haiku-5-5 done: stop=end_turn in=2 cache_read=1407 cache_write=275 out=68
2026-11-13 14:26:54,051 INFO torq.claude: asking claude-sonnet-5-5 (effort medium): 'It squeals for a few seconds on a cold start, then goes quiet. Why?'
2026-11-13 14:26:56,070 INFO torq.claude: claude-sonnet-5-5 done: stop=end_turn in=4 cache_read=0 cache_write=1778 out=160
Prompt cache6 of the 7 Claude calls in this session read their prefix from the cache: 1,225 to 1,960 cached input tokens per call
The exceptionThe one Sonnet call, which wrote a new cache because caches are per model
How to read the timesA measured sample from one session. Not a benchmark.

08

Safety

Safety does not depend on the model

A runaway robot breaks ankles, so stopping is handled in three independent layers. The language model sits at the top of the stack and the lower layers do not trust it. The model's only motor tool is stop.

The model can stop the robot. It cannot drive it.

LayerWhere it runsWhat it enforces
FirmwareArduinoStops the motors if a drive command is not repeated within 300 ms. Latched E-stop. Current-sense cutoff at 1.9 A sustained for 300 ms. Speed ramping and active braking.
BodyRaspberry PiSpeed clamps and a command timeout, so a bad command from anywhere upstream cannot exceed them.
Brain and dashboardLaptop and browserDriving is hold-to-drive. Closing the dashboard tab stops the robot. An E-stop locks out all driving until it is explicitly reset.
Manual drive with W and D held, on the simulated drive controller the tests use.
After an E-stop: motors at zero and a reset button, on the simulated drive controller.
firmware/torq_drive/torq_drive.ino: the main loop's watchdog
void loop() {
  wdt_reset();

  readSerial();

  // Read the clock after handling commands: a D command stamps lastDriveMs
  // with millis(), and a 'now' taken earlier would make now - lastDriveMs
  // underflow and trip the watchdog falsely.
  unsigned long now = millis();

  if (!watchdogTripped && now - lastDriveMs > WATCHDOG_MS) {
    stopNow();
    watchdogTripped = true;
    Serial.println(F("WDT"));
  }
  1. 1A second, hardware watchdog. If this loop ever hangs, the Uno resets and the motor pins fall back to stopped.
  2. 2A bug I hit on the bench: reading the clock before the serial commands made the subtraction underflow and stopped the motors for no reason.
  3. 3No fresh drive command for 300 ms means stop. A dropped Wi-Fi link, a crashed Pi and a closed laptop all look the same from here.

09

Enclosure

The body Zach built

Zach designed and built the enclosure, printed in PLA. It turned a deck of exposed boards and wiring into something you can put on a garage floor. The front panel comes off to reach the Raspberry Pi and the Arduino, the webcam sits on a hinged arm above the lid, and the battery lead comes out at the back.

Front. The speaker sits behind the grille panel.
Front panel off: the Raspberry Pi 5 and the Arduino with its motor shield.
Rear left. The battery lead comes out at the back for charging.
Rear right.

10

Numbers

Why the model is not trusted with numbers

A wrong torque spec strips a thread or loses a wheel. TorQ answers from the model's own knowledge, so it handles that risk with prompting: hedge, and point to the manual. You can see it in the conversation above, where the lug nut answer ends with "Confirm it in the owner's manual before you finish."

That is a prompt, not a guarantee, and I do not claim the problem is solved. The structural fix is retrieval with citations. It is described under "What is next".

11

Pivot

The project I dropped first

The project began as a robot that collects and composts trash. I dropped it for reasons I could state. Hot composting needs roughly a cubic yard of material to sustain its own heat, which a small robot cannot carry. One compost cycle takes 4 to 8 weeks, which leaves almost no room to iterate. And collection depends on grasping, which is where hobby robots usually fail.

TorQ inverts each of these. The hard part is knowing things, the feedback loop is one second, and a half-finished TorQ is still a useful rolling screen.

The line from my notes: "Don't build a robot that solves a problem you'd have to research. Build one that solves a problem you have."

12

Bench

What went wrong on the bench

On the first bench test the left track ran slower than the right. The motor shield's current-sense pins showed the left motor drawing about 1.5 to 2 times the current of the right at the same PWM, and stalling at 30% power. That pointed at mechanical drag and away from software. The cause turned out to be a stripped gearbox in the left motor.

Loud replies made the USB speaker brown out and reset on battery power, which showed up in the kernel log as USB disconnects. The fix is a software volume cap that is re-applied before every reply.

13

Next

What is next

None of this section is in the current software yet. Two parts of it, the wake word and manual lookup with page numbers, worked in the first version and need to be brought across. TorQ now answers from the model's own knowledge and is prompted to hedge. Cited service-manual lookup is what will replace that hedge with a page you can read.

The design: service-manual PDFs will be ingested on the laptop into per-page images and embeddings. Pages will be retrieved locally on the robot, and the page itself will be shown next to any answer. Online, Claude will answer from the retrieved pages using the API's native citations, which return the page number as a structured field. Offline, the robot will fall back to a spec table extracted at ingest time.

The governing rule will be that TorQ never shows a number without showing where it came from, so a wrong answer is visible instead of silent. The design docs are docs/CONCEPT.md and docs/LLM.md in the repo.

  • Cited manual lookup

    In the first version, not yet in the rewrite

    Retrieval over ingested service manuals, with the cited page shown beside every answer.

  • Vision

    Designed, not built

    A take_photo tool, so you will be able to ask "is this belt cracked?"

  • Drive tools for Claude

    Designed, not built

    drive and turn tools, which will be clamped on the Pi and locked out during manual override.

  • Wake word

    In the first version, not yet in the rewrite

    "Hey TorQ" will replace push-to-talk.

  • Status LEDs

    Designed, not built

    LEDs that will be driven from the brain's state machine.

14

Tests

Tests, and where the code is

There are 20 integration tests and all of them pass. They run the real brain server and the real body code over real sockets, against a simulated Arduino that speaks the firmware's serial protocol, plus stand-ins for Claude, Whisper and Piper.

They cover the behaviors that matter. The watchdog stops the motors when the brain disappears. E-stop locks out driving. Invalid tool input is reported and not run. A new question interrupts the current answer. A missing API key produces a spoken explanation instead of a crash.

pytest output, the voice half of the run
tests/test_voice.py::test_sentence_chunker_waits_for_whole_sentences PASSED [ 50%]
tests/test_voice.py::test_diagnostic_questions_route_to_smart_model PASSED [ 55%]
tests/test_voice.py::test_typed_question_is_answered_and_spoken_on_the_pi PASSED [ 60%]
tests/test_voice.py::test_smart_model_gets_server_side_fallback PASSED   [ 65%]
tests/test_voice.py::test_tool_call_sets_vehicle_then_answers PASSED     [ 70%]
tests/test_voice.py::test_invalid_tool_input_is_reported_not_run PASSED  [ 75%]
tests/test_voice.py::test_stop_tool_stops_the_motors PASSED              [ 80%]
tests/test_voice.py::test_push_to_talk_transcribes_and_answers PASSED    [ 85%]
tests/test_voice.py::test_empty_transcript_does_not_call_claude PASSED   [ 90%]
tests/test_voice.py::test_new_question_interrupts_the_current_answer PASSED [ 95%]
tests/test_voice.py::test_missing_api_key_is_explained_not_crashed PASSED [100%]

============================== 20 passed in 7.35s ==============================
Tests20 integration tests, all passing
CodeAbout 3,200 lines across Python, firmware and the dashboard
DeployThe body service and camera stream start on boot under systemd, and one script deploys from the laptop
Repogithub.com/atreyusutton/TorQ