5 · Write your own skill
Goal: add a new ability, a patrol that visits rooms and reports what it finds. Test it in the simulator, then run it on the robot, in Telegram and from OpenClaw, without touching hnbot's own code.
The idea
A skill is a short Python generator that combines the robot's building blocks:
| Building block | Does |
|---|---|
robot.navigate(room) |
drive to a room in the semantic map |
robot.find(what, area=None) |
list objects it can see (with grasp poses) |
robot.pick(obj) / robot.place_in("tray") |
grasp / put on the tray |
robot.hand_over() |
deliver what it holds |
robot.say(text) |
speak |
robot.photo() |
JPEG from the head camera |
robot.status() |
battery, room, what it's holding |
robot.dock() |
go charge |
In a skill, these lines mean:
yield "text"sends a progress message (to Telegram, the terminal or the BCI screen)return "text"is the final resultraise RobotError("why")fails cleanly
/stop cancels the running robot action, and your skill ends there.
Step 1: Write it
Create my_skills.py:
from hnbot.robot import RobotError
from hnbot.skills import register
@register("patrol")
def patrol(robot, rooms="living room,kitchen,bedroom", look_for="toys", dock="yes"):
"""Visit each room, count what it finds, then go charge."""
report = []
for room in [r.strip() for r in rooms.split(",") if r.strip()]:
yield f"Checking the {room}…"
robot.navigate(room)
seen = robot.find(look_for, room)
report.append(f"{room}: {len(seen)} {look_for}")
yield report[-1]
if dock.lower() in ("yes", "true", "1"):
yield "Patrol finished, going back to charge."
robot.dock()
return "Patrol report: " + "; ".join(report)
Rules for your function:
- the first argument is always
robot - every other argument comes in as a string, so give it a default
- the docstring's first line becomes the description in Telegram's command menu
Step 2: Test it in the simulator
hnbot --skills my_skills.py skills # your skill is listed
hnbot --skills my_skills.py do patrol
hnbot --skills my_skills.py do patrol rooms=kitchen,bedroom look_for=shoes dock=no
Arguments are given as name=value. Any plain words are passed as text=.
Step 3: Run it on Bajie
scp my_skills.py Agi@<robot-ip>:~/
hnbot --robot bajie --skills ~/my_skills.py do patrol rooms=客厅,厨房
Step 4: Use it from Telegram
Load the file when you start the butler:
HN_SKILLS=~/my_skills.py hnbot --robot bajie telegram
Your skill now appears in the bot's command menu. Send:
/patrol
/patrol rooms=kitchen look_for=shoes
/stop works as always.
Step 5: Use it from OpenClaw
OpenClaw's humannode-bajie skill already knows the hnbot command. Tell the agent about your new skill by adding a row to openclaw-skill/humannode-bajie/SKILL.md, then copy that folder into OpenClaw's skills directory on the robot:
| check the rooms for something | `hnbot --skills ~/my_skills.py do patrol look_for="<thing>"` |
Ideas to build next
| Skill | Sketch |
|---|---|
| Morning medicine | at 8:00 (cron), find("pill box") → pick → navigate(HN_USER_ROOM) → hand_over() → say("Time for your medicine") |
| Where are my keys? | patrol, find a list of objects per room, save the results to a JSON file, answer "where is X" from it |
| Leaving-home check | patrol, then photo() in each room and send the photos to Telegram |
| Shoe tidy | find("shoes") in the hallway → pick → place on the tray → navigate to the shoe rack |
Two examples ship with hnbot, in ~/hnbot/examples/my_skills.py: patrol and bring_to. Built something useful? Pull requests are welcome on GitHub.
Going further
- Lower level. The
BajieRosclass (hnbot/bajie_ros.py) shows how to call any action directly. Add your own method there, for example/robot/controlfor head pitch and lift. - Your own models. Bajie has two RK3588 processors (with an optional 20 TOPS co-processor) and RKNN tools for on-device AI models. Run your detector or policy on the robot and wrap it in a skill.
- Training data. Record ROS 2 bags of the camera and arm topics during demonstrations (
ros2 bag record …). LeRobot dataset export is on the hnbot roadmap.
✅ Done. You can now teach Bajie anything its building blocks allow.