3 · Your first pick-and-place
Goal: from a Python script, make Bajie find a toy in front of it, pick it up and put it on its carry tray.
Set the scene
- Bajie stands in an open area, relocalised. If it was just moved by hand, let it relocalise from the dock first.
- Put one small toy (under 1 kg, smaller than 10 cm across) on the floor about 0.6–1 m in front of the robot.
- Stay beside the robot. Ctrl-C stops it at any time.
Step 1: Try it in the simulator (on your laptop)
Create first_pick.py:
from hnbot.robot import make_robot
robot = make_robot() # "sim" by default; "bajie" on the real robot (see below)
print(robot.status())
found = robot.find("toy car")
print(f"found {len(found)}")
if not found:
raise SystemExit("nothing found: put a toy in front of the robot")
robot.pick(found[0]) # grasp
robot.place_in("tray") # drop it on the carry tray
print("done:", robot.status())
Run it:
python3 first_pick.py
The simulator prints its status, finds the toy car, "picks" it, and reports holding: None at the end.
Step 2: Run it on Bajie
Copy the script to the robot and switch to the real backend. You can do that with an environment variable, so the code stays the same:
scp first_pick.py Agi@<robot-ip>:~/
ssh Agi@<robot-ip>
HN_ROBOT=bajie python3 first_pick.py
What happens, step by step:
findcalls/searching_manager_actionwith name 玩具汽车 and gets 6D grasp poses back.picksends the first pose to/arm/adaptive(TASK_ARM_ADAPTIVE, gripper close). The arm reaches, grasps and lifts.place_in("tray")runsTASK_PALLET_ADAPTIVE. The arm moves over the tray and opens the gripper.
Step 3: Loop over everything it sees
from hnbot.robot import make_robot, RobotError
robot = make_robot()
for obj in robot.find("toys"):
try:
robot.pick(obj)
robot.place_in("tray")
print("put away:", obj.name)
except RobotError as e:
print("skipped:", e) # e.g. "out of arm workspace (36868)"
This is almost exactly hnbot's built-in tidy skill (hnbot do tidy), which also drives to the room first.
Step 4: Add navigation
robot.navigate("living room") # uses the semantic map; room names in English or Chinese
toys = robot.find("toys", "living room")
...
robot.dock() # back to charge
If the room is not in the map, the error lists the rooms the robot does know.
Common errors
| Message | Meaning | Fix |
|---|---|---|
28677 … not relocalised |
the robot doesn't know where it is | send it to the dock or relocalise in the ECOVACS app |
36868 … out of arm workspace |
the object is too far or too close | move it 0.6–1 m in front of the robot |
found 0 |
vision did not recognise it | try a common object (toy car, cup, bottle, shoes) with good lighting |
/arm/adaptive is not running |
the arm service is down | run hnbot --robot bajie doctor; reboot the robot if it stays red |
✅ Done. You have a working manipulation loop. Next: Telegram butler → or jump to Write your own skill →