基于树莓派实现的AI智能机器人--PiSlothRaspberry Pi-Based AI Smart Robot -- PiSloth


AI free token/AI免费积分

项目背景

随着近年来生成式 AI 技术的快速发展,传统机器人行业迎来了新的机遇与挑战。传统机器人通常依赖遥控操作,或按照预设程序机械地执行固定动作,缺乏自主理解、智能交互与灵活决策能力,因而在复杂场景中的适应性和智能化水平受到较大限制。

项目介绍

本项目旨在将 AI 小智接入PiSloth 机器人平台,为机器人赋予“AI 大脑”。通过融合生成式 AI 的自然语言理解、任务推理与智能决策能力,机器人不仅能够完成基础动作控制,还能够根据用户指令进行更自然的人机交互。可为传统机器人从“机械执行”向“智能交互”升级,提供一个低成本、可落地的解决方案。

硬件介绍

  • 树莓派4B(核心主控板):

    • CPU:Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.8GHz
    • RAM: 1GB
  • Pisloth机器人套件:

    • sunfounder在2021年左右发布一款Raspberry Pi 机器人开发套件
    • 金属驱体+ 4个舵机
    • robot hat 控制板,用于舵机、IO等控制
  • 自行设计的前脸PCB:

    • 无UI交互下,AI状态LED显示(联网状态、聆听状态、说话状态等)
    • 仿真眼睛:PCB丝印眼镜+凸透镜+LED
  • 电池、麦克风、喇叭等基础外围

Py-Xiaozhi介绍

py-xiaozhi 是一个使用 Python 实现的小智语音客户端,是基于xiaozhi-esp32移植的。

官方仓库:https://github.com/huangjunsen0406/py-xiaozhi

方案框图

框图简介:

本项目使用树莓派4B作为核心主控,麦克风、扬声器作为机器的语音输入和输出;主控通过websocket与云端大模型进行交互,实现语音识别、逻辑推理、意图识别等;主控通过I2C接口与Robot Hat控制板交互,实现机器人关节的舵机控制;AI机器人的当前实时状态则通过前脸的LED进行指示。

设计思路:

在终端与云端AI的语音交互方面,AI小智是近两年来很热门的一个项目方案,并且是开源的,对于个人开发而言,服务端也完全免费,没有大模型Token消耗成本。对于树莓派这种Linux终端,本文选择Python版本的py-xiaozhi项目作为基础代码进行二次开发。

py-xiaozhi实现了终端与云端AI的语音交互,那如何让机器人与云端AI实现硬件交互呢?答案是:目前主流的MCP(即模型上下文协议)。将机器人的动作、功能抽象为一个MCP工具,云端AI在获取到MCP的描述后,即可获得控制机器人的技能。当识别出控制机器人意图时,会下发对应的工具调用指令,从而实现机器人的硬件控制。

原理图及PCB

本项目对PiSloth机器人的前脸电路进行了重新布局规划,使用KiCad设计了一个低成本的LED状态显示逻辑及一双灵动的双眸:

在PCB设计方面,充分利用黑色油墨与白色丝印,绘制了机器人的眼部轮廓,同时配上微光LED及凸透镜,使得机器人双眸栩栩如生,实际效果展示:

软件关键实现

py-xiaozhi部署:

  • 克隆项目仓库
git clone https://github.com/huangjunsen0406/py-xiaozhi
  • 修改项目requirement.txt

由于本项目使用的是仅1GB RAM的树莓派,所以只能使用命令行模式,因此QT相关的组件需要注释掉。

...pygame==2.6.1#PyQt5==5.15.11opencv-python-headless==4.11.0.86...
  • 安装requirement.txt即完成部署

robot_hat组件安装:

  • pip直接安装
pip install robot-hat

robot_hat组件包含一套robot_hat控制板的硬件控制函数,通过这些函数实现舵机的驱动。

机器人MCP实现:

  • 在src/mcp/tools目录下创建pisloth文件夹,实现下面四个关键文件

其中,sloth.py是机器人控制的直接操作函数,manager.py则主要是对该工具的prompt描述:

        add_tool(            (                "control_pisloth",                "【机器人动作控制】这是你的身体,当用户要求你前进、后退、跳舞或站立时调用此工具。\n"                "功能:控制 Pisloth 机器人执行物理动作,如前进、后退、跳舞或站立。\n"                "支持的动作:\n"                "- 'forward': 机器人前进\n"                "- 'backward': 机器人后退\n"                "- 'dance': 执行跳舞动作(机器人会进行舵机运动模拟跳舞)\n"                "- 'stand': 站立不动(默认动作)\n"                "使用场景:用户说'前进'、'后退'、'跳个舞'、'跳舞'、'站好'等时调用。\n"                "参数说明:action_type - 动作类型,字符串类型,默认 'stand'\n"                "注意:这是物理机器人控制,确保硬件连接正常。",                control_props,                control_pisloth,            )

交互状态LED指示实现:

  • 修改src下cli_display的update_status,根据不同状态对LED进行控制。如当机器人连接服务器后,双眸的微光LED点亮,当机器人在聆听状态时,额头绿色LED点亮。

云端大模型配置:

  • 打开小智AI服务器官网,配置机器人的昵称,并选择使用的大模型。

本项目选用Qwen3.5大模型,该模型具有极强的指令遵循及工具调用能力,本公众号曾验证其上一代Qwen3-1.7B小参数模型即可正常进行工具调用。

机器人整体展示

效果演示

已关注
关注
重播 分享 赞
ETRD

0/0

00:00/00:51
进度条,百分之0
00:00
/
00:51
00:51
全屏

倍速播放中

继续观看

基于树莓派实现的AI智能机器人--PiSloth

原创
,
基于树莓派实现的AI智能机器人--PiSloth
ETRD
已同步到看一看写下你的评论

小结

本项目在树莓派4B上,将AI小智接入PiSloth机器人平台,实现了一个AI智能机器人。该思路及方法可以应用到其它传统机器人或者智能硬件中,可为传统机器人/智能硬件从“机械执行”向“智能交互”升级,提供一个低成本、可落地的解决方案。

本项目完整源码,可关注“ETRD”公众号,回复 “AI小派” 获取。

Project Background

In recent years, with the rapid development of generative AI technology, the traditional robotics industry has encountered new opportunities and challenges. Conventional robots typically rely on remote control or execute pre-programmed fixed motions mechanically, lacking autonomous understanding, intelligent interaction, and flexible decision-making capabilities. Consequently, their adaptability and level of intelligence in complex scenarios are significantly constrained.

Project Introduction

This project aims to integrate AI Xiaozhi into the PiSloth robot platform, endowing the robot with an "AI brain." By combining the natural language understanding, task reasoning, and intelligent decision-making abilities of generative AI, the robot can not only perform basic motion control but also engage in more natural human-machine interaction based on user commands. It provides a low-cost, implementable solution for upgrading traditional robots from "mechanical execution" to "intelligent interaction."

Hardware Introduction

Raspberry Pi 4B (Core Controller Board):

CPU: Quad-core Cortex-A72 (ARM v8) 64-bit SoC @ 1.8GHz

RAM: 1GB

PiSloth Robot Kit:

SunFounder released a Raspberry Pi robot development kit around 2021

Metal chassis + 4 servos

Robot HAT controller board, used for servo and IO control

Custom-designed front face PCB:

AI status LED display without UI interaction (network status, listening status, speaking status, etc.)

Simulated eyes: PCB silk-screened glasses + convex lens + LED

Battery, microphone, speaker and other basic peripherals

Py-Xiaozhi Introduction

py-xiaozhi is a Python-based Xiaozhi voice client, ported from xiaozhi-esp32.

Official repository: https://github.com/huangjunsen0406/py-xiaozhi

Architecture Diagram

Diagram Description:

This project uses the Raspberry Pi 4B as the core controller, with microphone and speaker serving as the robot's voice input and output. The controller interacts with the cloud AI model via WebSocket, enabling voice recognition, logical reasoning, and intent identification. The controller communicates with the Robot HAT board through the I2C interface to control the robot joint servos. The AI robot's current real-time status is indicated through LEDs on the front face.

Design Approach:

For terminal-to-cloud AI voice interaction, AI Xiaozhi is a popular open-source project in recent years. For individual developers, the server-side is completely free with no large model token consumption costs. For Linux terminals like the Raspberry Pi, this project selects the Python version of the py-xiaozhi project as the foundational code for secondary development.

Since py-xiaozhi achieves terminal-to-cloud AI voice interaction, how can the robot achieve hardware interaction with cloud AI? The answer lies in the currently mainstream MCP (Model Context Protocol). By abstracting the robot's actions and functions as MCP tools, the cloud AI can acquire robot control capabilities after obtaining the MCP descriptions. When the system identifies intent to control the robot, it issues corresponding tool invocation commands, thereby achieving hardware control of the robot.

Schematic and PCB

This project re-layouted the PiSloth robot's front face circuit and used KiCad to design a low-cost LED status display logic and a pair of lively eyes:

In terms of PCB design, we fully utilized black ink and white silk-screening to draw the robot's eye contours, paired with subtle LED illumination and convex lenses, making the robot's eyes come vividly alive. The actual effect is demonstrated as follows:

Key Software Implementations

py-xiaozhi Deployment:

Clone the project repository

Modify the project's requirements.txt

Since this project uses a Raspberry Pi with only 1GB RAM, it must run in command-line mode, so Qt-related components need to be commented out.

Install requirements.txt to complete deployment

pip install directly

The robot_hat component contains a set of hardware control functions for the robot_hat controller board, enabling servo driver implementation through these functions.

Robot MCP Implementation:

Create a pisloth folder under src/mcp/tools to implement the following four key files

Modify src/cli_display's update_status to control LEDs based on different statuses. For example, when the robot connects to the server, the subtle LED in its eyes illuminates; when the robot is in listening mode, the green LED on its forehead lights up.

Open the Xiaozhi AI server official website to configure the robot's nickname and select the target large model.

This project selected the Qwen3.5 model, which has strong instruction-following and tool-calling capabilities. Our official WeChat account previously verified that the earlier Qwen3-1.7B smaller-parameter model could perform tool invocation normally.

Robot Overview

Demo Effects

Already Following

Follow

Replay | Share | Like

Close

Watch More

More

Exit Full Screen

ETRD | Already Following

Share Video

| Duration: 00:51

0/0

00:00 / 00:51

Switch to Landscape Mode

Continue Playing

Progress Bar, 0%

Play

00:00

00:51

00:51

Playback Speed

Full Screen

Playing at Speed

0.5x 0.75x 1.0x 1.5x 2.0x

HD | Smooth

Continue Watching

AI Smart Robot Based on Raspberry Pi -- PiSloth

Watch More

Original

,

AI Smart Robot Based on Raspberry Pi -- PiSloth

ETRD | Already Following

Share | Like | Watch

Synced to LookLook | Write Your Comment

Video Details

Summary

This project integrated AI Xiaozhi into the PiSloth robot platform on a Raspberry Pi 4B, creating an AI smart robot. This approach and methodology can be applied to other traditional robots or smart hardware, providing a low-cost, implementable solution for upgrading traditional robots/smart hardware from "mechanical execution" to "intelligent interaction."

暂无评论,快来发表第一条评论吧!No comments yet. Be the first!

📮 需求咨询📮 Inquiry