Until now the robot has done what you told it, one command at a time. This chapter hands it to the AI on your PC. The AI doesn't send motor commands. It writes short Python programs against a small set of body calls, such as pose(), look(), turn_head(), move_arm() and navigate_to(), and a program on your PC carries them out through the robot API from chapter 11. The same calls answer in the simulator of chapter 14, so a program written there is meant to run here without a change. How far what the AI learned there carries over is what these first real runs measure.
One rule comes before every step. The robot has its own loop, the service rosorin-mind, and it moves the arm by itself whenever it sees someone. On the real robot it stays stopped unless you start it on purpose, with the robot where you want it and nobody's hand near the arm.
The order matters, and it's the order I used. First reads only, then head movements on the charger, then naming what the camera sees, then the AI's own programs without wheels, then one arm move, and last the wheels. Stop at the first step that fails. Plan an evening for the reads and head looks, and a second one for the arm and the first drives. You need the robot API from chapter 11 with its token copied to your PC, and two models loaded in LM Studio: a vision model to name things, Gemma 4 12B, which chapter 12 downloads, and a model that writes the programs. I use gpt-oss-20b for that, but its download is not covered in this guide: chapter 12 doesn't show it, and I have no record of how I got it.
The commands on your PC run from a clone of the repo in ~/lightbot-repo. Chapter 3 clones the repo only on your laptop, and no chapter has a tested step that makes the PC's clone. Chapter 3's git clone line with ~/lightbot-repo as the folder should do it, but I haven't run it that way. The commands reach the robot over Wi-Fi as rosorin-wifi, the alias from chapter 5, so they work with the robot's cable unplugged. The repo's deploy.sh and readback.sh use that alias too unless the variable ROBOT names another.
There are two programs on this project that move the robot's head by themselves.
The first lives on the robot. It's vision/mind.py, running as the service rosorin-mind. It's a simple loop that owns the head: it watches for a person, follows them with the camera, looks around and goes back to rest. Once it runs, the arm can move at any moment, whenever it sees someone. It also publishes what it detects on the topic /rosorin_mind/seen, which one step below reads. On my robot it was already installed and running. No chapter of this guide installs it with a tested step, this one included, because I haven't re-checked its install on a fresh system. Without it, the pause call below has nothing to answer it, and the step that watches its detections has nothing to read.
The second is the AI on your PC, mind/live.py, which you start in this chapter. When it runs, it decides on its own where to look and, once you allow it, where to move the arm and drive.
Pause the robot's own loop like this, on the robot:
source /opt/ros/humble/setup.bash; timeout 15 ros2 service call /rosorin_mind/enable std_srvs/srv/SetBool "{data: false}"
I didn't keep the answer. In vision/mind.py the service replies with success and the message mind disabled, and from then on the loop leaves the arm alone. Every script in this chapter that moves the head also pauses it by itself while it works, but don't rely on that. Pause it first.
A pause doesn't survive a restart. The loop starts enabled, so when the service restarts or the robot reboots, it runs again. After every boot, pause it again and read the robot back from your laptop:
BIGBUDDY=yourpc bash ~/CCode/rosorin-pro/scripts/ops/readback.sh
The mind: line prints what the loop publishes about itself, including its mode and an enabled field. Paused, the code publishes "mode": "paused" and "enabled": false; I didn't record that line myself. If you want the loop running again, send the same service call with {data: true}.
Disabling the service in systemd should keep it off at boot, but that is untested: I never did it. Pausing it after every boot with the call above is the only way I tested.
The AI on your PC is easier. It runs only while mind/live.py runs, and it stops before its next step when the file ~/mind-live/STOP exists on your PC. More on that below.
The body the AI talks to is mind/real_body.py, a class called RealBody. It runs on your PC and calls the robot API over the network. On the robot, a file called buddy_link/body_endpoints.py loads into the robot API and adds the calls it didn't have yet: the robot's pose on the map, the LiDAR scan, the depth image with the camera's pose, the map, a navigation goal and a checked arm move.
Two keys guard every movement beyond the head, and both are off by default. REAL_ALLOW is set on your PC when you start a run. ROBOT_BODY_ALLOW is set in the robot API's service on the robot. Wheels need wheels in both, and every arm joint other than the head's pan and the wrist needs arm in both. Head looks need no key, because starting the run is your decision.
Underneath the keys, nothing changes. Neither file publishes /cmd_vel. A drive goes to the navigation stack and through the collision monitor, and the board driver's own stops from chapter 10 stay where they are. A movement is refused while an e-stop is latched, while something else has enabled the wheels, and while navigation isn't ready. A refusal is an answer, not a fault. Nothing moved, and the body counts it.
RealBody reads the token from ~/.config/rosorin/api_token, where chapter 11 put it. It reaches the robot at ROBOT_WIFI_IP:8296, my robot's Wi-Fi address and the API's port, unless the variable REAL_ROBOT names another. I never set it, so if your robot has another address, setting REAL_ROBOT to it is untested.
Several commands below start with LBGZ_TWIN=http://PC_IP:8297. That is my PC's address, and it points at the live copy of the robot that chapter 14 sets up. Use your PC's address. The AI's questions to you go to that page, and without LBGZ_TWIN they're refused. I ran those commands with it set and never without it.
The new endpoints have to be copied to the robot, and the robot API restarted to load them. From your laptop:
cd ~/CCode/rosorin-pro && bash scripts/ops/deploy.sh api
This moves nothing. If you ever want the robot API without the new calls, remove the file and restart it:
ssh rosorin-wifi 'rm ~/buddy_link/body_endpoints.py && sudo systemctl restart rosorin-api'
I never needed that, so it's untested.
Before anything moves, check that your PC can read every sense of the robot through the body. The dry run makes GET requests only, so it can't move anything, and its last line counts the POST requests it sent. On your PC:
cd ~/lightbot-repo && python3 -m mind.real_body --check; echo "exit $?"
It prints one line per check, each starting with PASS or FAIL. status should show the battery above 10.6 V, the wheels off and no e-stop. state lists the six joint positions; at rest joint 2 is 776 and joint 3 is 211. pose gives the robot's place on the map and must say navigation is ready. That needs a map of your room that navigation can place the robot on. Chapter 9 has no tested way to make one, and chapter 10's placement failed during its build; on my robot navigation read ready later, on my kept map. scan should show most of the 400 LiDAR returns. camera compares the camera's pitch from the robot's transforms with the arm model's, and the two should be within a degree. frame reads one colour frame and its depth, and fails as DARK if the picture is black. map reads the map navigation runs on. allow should say robot allows nothing beyond the head and that REAL_ALLOW is unset on your PC. The last line must be:
PASS moves 0 POST requests sent
and the exit code 0. On my robot every line passed, the scan had 301 of 400 returns with the nearest at 0.05 m, and the camera's pitch read -0.2 degrees against the arm model's -0.8.
If every line fails with HTTP 401, your PC's token isn't the robot's. HTTP 404 on the body lines means the deploy didn't land, and journalctl -u rosorin-api -n 30 on the robot says why. A connection error on the first line means the robot API isn't running or the robot is off the network. frame ... DARK usually means the camera dropped off USB for a moment; run the dry run again.
This step is optional and only reads. mind/robot_bridge.py listens to what the robot's own loop detects, places each detection on the map, and keeps a memory of what is where. It has no publisher and calls no service, so it can't move anything. It does need the loop running, because the loop is what publishes the detections. Run it with the robot on its charger and nobody near the arm, and pause the loop again when you're done.
The rest of the chapter places things the same way. The detector gives a box in the picture, and the box's centre is a direction out of the camera. The robot's transforms say where the camera is in the room at that moment. The depth image inside the box says how far along that direction the thing is, and where depth has holes, the LiDAR's distance on the same bearing fills in. Direction plus distance from a known camera pose is a point on the map.
Copy the files from your laptop:
ssh rosorin-wifi 'mkdir -p ~/mind-room/mind/state'
cd ~/CCode/rosorin-pro && scp mind/__init__.py mind/room_memory.py mind/world_sim.py mind/robot_bridge.py rosorin-wifi:mind-room/mind/
Then check on the robot that what it listens to is there:
source /opt/ros/humble/setup.bash
systemctl is-active rosorin-mind rosorin-camera rosorin-nav
timeout 5 ros2 topic echo --once /nav/status --field data
timeout 8 ros2 topic hz /rosorin_mind/seen
The three services print active, the status contains "state": "ready", and the detections arrive about twice a second. Start the bridge in an interactive SSH session, because a background job ignores Ctrl-C:
source /opt/ros/humble/setup.bash
cd ~/mind-room && python3 -m mind.robot_bridge --seconds 1800
From a second session, read its memory:
cd ~/mind-room && python3 -m mind.robot_bridge --summary
I ran it for ten minutes, with --seconds 600, with the robot on its charger. It took 1129 frames, placed 2614 detections by depth and 772 by the LiDAR, and its summary listed three guitars that hang on my wall, each within 0.2 to 0.3 m of where the camera pictures, the depth image and the LiDAR map put them.
The robot's own detector knows a few dozen kinds of thing. The vision model on your PC can name almost anything. mind/look_capture.py turns the head through six angles on the charger and keeps, at each stop, the colour frame, the depth image, the nearest LiDAR scan and the camera's place. Then mind/look_label.py on your PC asks the vision model what's in each frame and places each thing on the map.
The look moves the head's pan joint and the wrist, through the robot API's guarded look. It pauses the robot's own loop, refuses while the wheels are enabled or an e-stop is latched, and waits for each move to arrive. The default stops are the centre, 30 and 60 degrees to each side, and back to the centre. Put the robot on its charger and keep your hands away from the arm.
Copy the two files the look needs into the robot's RAM disk. The copy of the robot API there needs a stand-in for its say module, so an empty say.py goes beside it. /dev/shm is emptied at every reboot, so repeat this after one. From your laptop:
ssh rosorin-wifi 'mkdir -p /dev/shm/lblook && touch /dev/shm/lblook/say.py'
cd ~/CCode/rosorin-pro && scp buddy_link/robot_api.py mind/look_capture.py rosorin-wifi:/dev/shm/lblook/
Run the look on the robot:
cd /dev/shm/lblook && export ROS_DOMAIN_ID=0 ROS_LOG_DIR=/dev/shm/lb-ros
source /opt/ros/humble/setup.bash && source ~/ros2_ws/install/setup.bash
python3 look_capture.py
It saves six stops into cap, from 00_pan500 to 05_pan500, and ends with done; estop: None enabled: False. Copy the capture to your PC. This replaces the last capture in ~/mind-room/cap, so rename that folder first if you want to keep it:
ssh rosorin-wifi 'cd /dev/shm/lblook && tar czf - cap' | ssh yourpc 'mkdir -p ~/mind-room && cd ~/mind-room && rm -rf cap && tar xzf -'
Check on your PC that the vision model is loaded with ~/.lmstudio/bin/lms ps, then label the capture. Run it from your PC's clone of the repo, not from a copy of a few files, because look_label.py imports mind/config.py:
cd ~/lightbot-repo && python3 -m mind.look_label ~/mind-room/cap
I ran it on a capture folder named for the day instead of cap. An earlier form of this step also passed --memory ~/mind-room/mind/state/real_room_depth.json. I left that out, so the places went to the default memory file, mind/state/real_room.json.
On my robot in evening light, all six frames were usable, the model named 70 things, 67 were placed (59 of them by depth), and they merged into 9 distinct things. The three wall guitars landed 0.1 to 0.3 m from where my measured room model has them. With more light in the room, the same look named 104 and placed 99, which merged into 13 things. Light makes a big difference, so do this with the room lights on.
Three things went wrong on my first try, and the two scripts now handle all three. One stop came back black, one second after the camera dropped off USB and reconnected during the arm move. look_capture now retries a dark stop three times and never saves a black frame, and look_label checks every frame (mean brightness under 25, or less than 10 % valid depth) before sending it to the model. Second, Gemma 4 spent almost all of its 6000-token answer budget thinking and returned nothing. look_label asks it not to reason. Third, Gemma gives boxes as [y0, x0, y1, x1] on a 0 to 1000 grid, not in pixels, so boxes ran off the bottom of the picture until look_label asked for that form and scaled it.
One more detail took a fix in the code. A see-through thing such as a bar stool has the wall behind it in the middle of its box, and its seat shows up as a group of close readings off to one side. The placement now uses the nearest group holding at least a quarter of the box's readings when it is more than 0.5 m in front of the median. Before that, my bar stool was placed 3.16 m away, at the wall behind it. After it, the stool came out 0.75 m from the camera, at its seat.
look_capture is a fixed script. Now do the same through RealBody, which is what the AI's programs use. Pause the robot's own loop first, as above, so it doesn't turn the head between the program's looks. Then, on your PC:
cd ~/lightbot-repo && LBGZ_TWIN=http://PC_IP:8297 python3 -c "
from mind.real_body import RealBody
b = RealBody()
for deg in (0, 30, -30):
b.turn_head(deg); print(deg, [(d['label'], d['x'], d['y']) for d in b.look()])
b.turn_head(0); print('refused:', b.safety()['refusals'])"
You should get three lines of named things with their places on the map, and refused: []. If you see refused: wheels enabled or e-stop, something has enabled the wheels or an e-stop is latched. Clear the e-stop as chapter 10 describes, but don't enable the wheels: the body enables them itself when it needs them, and refuses when someone else has. Empty lists with dark frames mean the camera dropped off USB after the move. No answer at all usually means the vision model isn't loaded.
The first time I ran this, things were placed about 0.9 m off, and their places swung by about a metre from one look to the next. The robot's heading jumped between 25.6 and 38.9 degrees while it stood still on the charger. The cause was the gyro. At boot the base driver measures the gyro's bias while the robot is supposed to be still, and on that boot it wasn't, so the driver logged robot not stationary during gyro calibration and ran with no correction for a bias of about 2 degrees per second. At rest, the heading from odometry turned 2.1 degrees in 43 seconds by itself. The driver now repeats the calibration until it gets a still window, and logs the bias it found, on my robot gyro bias (deg/s) [-2.211, -2.685, 0.064]. After that the heading held at 27.1 to 27.2 degrees across three looks (at 0, 30 and 0 degrees), and the guitars came out 0.11 to 0.31 m from the room model. If your placements swing like mine did, look for that calibration line in the base driver's journal before anything else.
mind/live.py is the runner for the real robot. In simulation every result is scored against the simulator's truth, but the real robot has no truth to score against, so live.py runs the same steps and scores nothing. It has two modes. With --task it runs one task: the model writes one program, it runs once, and the answer is printed. Without --task it runs the free mind, which sets its own goal at every step, writes a program for it, writes a lesson and keeps programs that worked as skills.
The programs come from the model named by --model. The names are the keys in mind/machines.json, the list of your machines and what each one serves. My default, mac-oss, is gpt-oss-20b in LM Studio on my laptop. As the repo has it, the file lists my machines, with my laptop reached through an SSH tunnel. For yours you'd change it to name your own machines, and I haven't run these commands with any other file.
With no keys set, the AI can read and move the head, and nothing else. Start with one task. The first time, add --survey so it looks around before the task and fills its memory:
cd ~/lightbot-repo
LBGZ_TWIN=http://PC_IP:8297 python3 -m mind.live --survey \
--task "Is there a mug by the dresser? Go to the dresser, look, and return yes or no with the mug's x, y if you saw it."
Write a task about something that's really in your room. I asked mine to find the guitars. The look-around took 22 minutes for 17 head moves, because the vision model was busy with other work on my PC, so give it the PC to itself. On that first run the 10-minute limit then ended the run before the task's step; live.py now always runs a task's step. The run keeps its memory in mind/state/live_memory-RealBody.json, and the next run starts from it, so the same task again without --survey answered in 5.2 seconds from memory: four guitars found, three of them within 0.1 to 0.37 m of the real ones, and the fourth 1.3 m from any guitar, a false one.
Then ten minutes of the free mind, still without wheels:
LBGZ_TWIN=http://PC_IP:8297 python3 -m mind.live --minutes 10 --no-survey
The older form of this step had no --no-survey. I added it because the task run had already filled the memory; without it the free mind starts with a look-around.
Each step prints its result and, under it, the reason for any refusal. With no REAL_ALLOW, a drive is refused with the wheels need the owner's yes (REAL_ALLOW=wheels; now: unset). My first ten-minute run made 10 steps; 9 programs ran, and 9 things were refused: 4 drives and 5 questions the AI asked me that nobody answered within 120 seconds. The questions go to a page that chapter 14 sets up. The drive calls are no longer offered to the model when the wheels aren't allowed, and a 20-minute run after that change had no refusals, moved the head 28 times, and grew its memory from 32 to 40 things. Two of its five programs failed, one calling a function that doesn't exist and one spending its whole 900-second limit on looks. In the simulator 46 to 71 % of its programs failed, so expect failures here too.
The run stops before its next step on the first of these: the file ~/mind-live/STOP exists on your PC, an e-stop, low battery off the charger, five failed steps in a row, or the time or step limit. To stop it from any shell on your PC:
touch ~/mind-live/STOP
A program that's already running finishes first, up to 900 seconds. Remove the file with rm ~/mind-live/STOP before the next run. Every step goes to one line in mind/logs/live-RealBody-<time>.jsonl: the prompt and reply, the program, the result, the pose before and after, the battery and every refusal with its reason. Read it after a run.
The first movement of a joint other than the head's pan and the wrist is yours to watch, standing by the robot with the power switch within reach. A gamepad button other than MODE is meant to latch a stop, but chapter 10 never tested that on this build, so count on the power switch. Pause the robot's own loop.
I did this once, and I didn't keep the exact commands, so there are no steps to copy here. What follows describes what I did; none of it has been run as written. I turned the arm key on in both places: on the robot with a drop-in for the robot API, like the wheels key in the next section but naming arm, and on my PC with REAL_ALLOW=arm. Then I moved the shoulder and elbow (joints 2 and 3) from rest at 776 and 211 to 700 and 240 and back, then the claw from 499 to 380 and back, with move_arm and gripper on RealBody. Every arm move is checked against the joint limits, the floor and the arm model on the way. The four moves took 1.5 to 4.2 seconds, every joint reached its goal, nothing was refused and no e-stop was latched. I took both keys off straight after, and the robot then answered that it allowed nothing.
The wheels need both keys. Put the robot on open floor, off the charger, with the room cleared around it. Nothing in the body drives onto or off the charger, so start on the floor. Every goal also moves the arm: it goes to the drive pose first and back to rest at the end. Chapter 10's stand and floor proofs passed in the end, but its floor proof covered only 0.1 and 0.2 m/s, and no stop was timed during a sideways move. Keep the goals short and stay next to the robot, within reach of its power switch.
Turn the robot's key on, this time for the wheels. These lines run on the robot, over ssh rosorin-wifi:
sudo mkdir -p /etc/systemd/system/rosorin-api.service.d
printf '[Service]\nEnvironment=ROBOT_BODY_ALLOW=wheels\n' | sudo tee /etc/systemd/system/rosorin-api.service.d/20-body-allow.conf
sudo systemctl daemon-reload && sudo systemctl restart rosorin-api
Check both keys from your PC:
cd ~/lightbot-repo && REAL_ALLOW=wheels python3 -m mind.real_body --check | grep -E "allow|pose|status"
You want the allow line to name wheels on the robot and on your PC, the pose line saying navigation is ready, and the battery above 10.6 V. Then send one goal half a metre straight ahead:
cd ~/lightbot-repo && REAL_ALLOW=wheels LBGZ_TWIN=http://PC_IP:8297 python3 -c "
import math; from mind.real_body import RealBody
b = RealBody(); x, y, yaw = b.pose(); a = math.radians(yaw)
print('from', (x, y, yaw)); print(b.navigate_to(x + 0.5 * math.cos(a), y + 0.5 * math.sin(a))); print('now', b.pose(), b.safety()['refusals'])"
On my robot it answered:
{'reached': True, 'metres': 0.32, 'seconds': 3.5}
The pose printed right after lagged behind. A few seconds later navigation put the robot 0.06 m from the goal and 0.53 m from where it started. It slid sideways a little on the way, because the navigation stack is set up for the mecanum wheels and uses them. Then I sent it back to where it started with navigate_to and the starting x and y, and it got there: 0.63 m in 11.3 seconds, turning rather than reversing.
If the answer is a refusal, the reason says where it came from. the wheels need the owner's yes never left your PC. wheels not allowed on this robot (ROBOT_BODY_ALLOW) came from the robot. e-stop latched means a gamepad button, the contact reflex or a stop call; clear it as chapter 10 says. navigation is not ready means the robot is lost or still placing itself. A refusal about the battery means charge first. A refusal about the map's 0.2 m wall margin means the goal is too close to a wall on the map.
Know how to stop a drive before you send one. The power switch is the stop to count on, and the only one if the board's USB link is gone. A gamepad button is meant to latch an e-stop in the board driver with no network in between, but chapter 10 never tested it on this build, and I never needed it during these drives. The robot API's stop call, POST /body/stop, is meant to cancel the goal and disable the wheels, but it has never been tried during a goal on the robot. Ctrl-C on your PC is not a stop: by the code, a goal already sent runs on until it arrives, an e-stop or its timeout. I read that from the code and haven't tried it.
After the last goal, take the key off on the robot:
sudo rm /etc/systemd/system/rosorin-api.service.d/20-body-allow.conf && sudo systemctl daemon-reload && sudo systemctl restart rosorin-api
Put the robot back on its charger and read it back from your laptop with readback.sh as above. The driver line should say "enabled": false "estop": null and navigation should be ready.
The AI hasn't finished a real job with the wheels. I gave it one task with the wheels allowed: drive to the guitars and stop about a metre away. The first run started with an empty memory and found nothing. The second aimed for the guitars' own spot against the wall, and the body refused it for the wall margin. After a change that lets a task try again with the body's complaints, the third run drove the robot by itself to 0.67 m from the guitars. Then its look failed: the close look needed the arm key, which wasn't set, and the vision model was unreachable because a training job on my PC had stopped LM Studio. I stopped the run with the stop file.
After the drive back, with the wheels already off, the robot's pose on the map jumped 0.48 m. When I turned the robot by hand with the gamepad, it settled again. The cause is unknown. The navigation fit also dropped from 0.88 to 0.59 during the first drive, and the map save after it reported that the map image failed to save.
No stop has been tried during one of the body's drives. Neither the stop file nor Ctrl-C stops a drive already sent, the robot API's stop call during a goal has not been tried, and the gamepad e-stop wasn't tested on this build. While the AI has the wheels, stay within reach of the power switch.
When the AI asks you a question and nobody answers within 120 seconds, it gets "I don't know" and the body counts a refusal. There's no voice path for these questions yet.
You're ready for the next chapter when, if your robot runs its own loop, you can pause it after a boot and see "enabled": false on the mind: line, the dry run ends with 0 POST requests sent and exits 0, a look-around has been named and placed by the vision model with no dark frames, the three looks through RealBody printed refused: [] with places that don't swing between looks, a mind.live task answered from memory, and one half-metre goal answered 'reached': True with both keys on. The drop-in 20-body-allow.conf must be gone again. You should know that the stop file ends an AI run, and that for wheels under way only the power switch is a stop you can count on until you have tested the gamepad yourself.