Skip to content

Commit eaf3268

Browse files
author
richardson
committed
修改readme中的流程图等内容
1 parent 96fe91d commit eaf3268

File tree

1 file changed

+109
-59
lines changed

1 file changed

+109
-59
lines changed

README.md

+109-59
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,117 @@ Desky 主要包含以下几个核心组件:
4545

4646
2. **语音合成**:使用 OpenAI 的文本转语音(TTS)API 将机器人的文本回复转换为语音输出,提供更自然的交互体验。
4747

48-
3. **计算机视觉**:通过摄像头和 OpenCV 库实现实时人脸检测。这使得机器人能够"看到"用户,为进一步的交互奠定基础。
48+
3. **计算机视觉**:使用 face-api.js 实现实时人脸检测和追踪。具体实现包括:
49+
- 使用 TinyFaceDetector 模型进行轻量级人脸检测,支持实时检测
50+
- 通过 WebRTC 获取摄像头画面,每帧进行人脸位置、大小和置信度分析
51+
- 采用帧跳过机制(skipFrames)优化性能,只在必要时进行检测
52+
- 实现 FPS 计算和性能监控,确保流畅的视觉交互体验
53+
- 支持 WebGL 加速,提升检测性能
54+
这些技术让机器人能够"看到"并实时跟随用户,实现自然的视觉交互。
55+
56+
4. **舵机控制**:通过串口通信(SerialPort)与 Arduino 控制板连接,实现舵机的精确控制。具体实现包括:
57+
- 使用 9600 波特率建立串口连接,设置 1000ms 超时
58+
- 通过格式化命令字符串 "X,Y\n" 发送舵机位置指令
59+
- X、Y 值范围为 0-180 度,默认值为 90 度(居中位置)
60+
- 每次发送指令后等待 100ms 让 Arduino 处理
61+
- 支持读取 Arduino 的响应数据进行双向通信
62+
- 使用日志系统记录所有舵机控制操作
63+
这些机制确保了舵机控制的精确性和可靠性,使机器人能做出流畅的头部运动响应。
64+
65+
5. **Tauri 框架**:采用 Rust 和 Web 技术构建跨平台桌面应用,确保性能和易用性的平衡。通过 Tauri 的安全权限系统,实现对本地硬件和文件系统的可控访问。
4966

50-
4. **舵机控制**:使用 Raspberry Pi 的 PWM 接口控制舵机,实现机器人头部的物理运动,使交互更加生动。
5167

52-
5. **Tauri 框架**:采用 Rust 和 Web 技术构建跨平台桌面应用,确保性能和易用性的平衡。
68+
## 项目结构
69+
70+
```mermaid
71+
graph TB
72+
classDef frontend fill:#e6f3ff,stroke:#4a90e2,stroke-width:2px
73+
classDef backend fill:#f5f0ff,stroke:#9b6dff,stroke-width:2px
74+
classDef hardware fill:#fff0f4,stroke:#ff6b81,stroke-width:2px
75+
classDef service fill:#f0fff4,stroke:#2ed573,stroke-width:2px
76+
77+
UI[前端界面层]
78+
Backend[Tauri后端]
79+
Hardware[硬件控制]
80+
Vision[计算机视觉]
81+
Audio[音频处理]
82+
83+
UI --> Backend
84+
Backend --> Hardware
85+
Backend --> Vision
86+
Backend --> Audio
87+
88+
subgraph 前端模块
89+
UI --> VideoFeed[视频流显示]
90+
UI --> Controls[舵机控制面板]
91+
UI --> Chat[对话交互界面]
92+
end
93+
94+
subgraph 核心服务
95+
Backend --> DeviceManager[设备管理器]
96+
Backend --> ServoController[舵机控制器]
97+
Backend --> WebSocket[WebSocket客户端]
98+
end
99+
100+
class UI,VideoFeed,Controls,Chat frontend
101+
class Backend,Vision,Audio backend
102+
class Hardware,ServoController hardware
103+
class DeviceManager,WebSocket service
104+
```
105+
106+
107+
## 交互流程
108+
109+
```mermaid
110+
sequenceDiagram
111+
participant User as 用户
112+
participant Client as 客户端程序
113+
participant LLM as 大语言模型
114+
participant TTS as 语音合成服务
115+
participant Server as Web服务
116+
participant Queue as 消息队列
117+
participant Mobile as 手机客户端
118+
119+
User->>Client: 输入文字内容
120+
121+
%% LLM处理阶段
122+
Client->>LLM: 发送文字+提示词
123+
LLM-->>Client: 返回文字内容和表情
124+
125+
%% 语音合成阶段
126+
Client->>TTS: 发送处理后的文字
127+
TTS-->>Client: 返回合成的语音文件
128+
129+
%% 服务器处理阶段
130+
Client->>Server: 发送语音文件和内容
131+
activate Server
132+
Server->>Server: 存储语音文件
133+
Server->>Queue: 将消息放入队列
134+
deactivate Server
135+
136+
%% 手机端处理阶段
137+
loop 轮询检查
138+
Mobile->>Server: 请求新消息
139+
alt 有新消息
140+
Server-->>Mobile: 返回新消息内容
141+
Mobile->>Mobile: 显示内容
142+
Mobile->>Server: 请求语音文件
143+
Server-->>Mobile: 返回语音文件
144+
Mobile->>Mobile: 播放语音
145+
else 无新消息
146+
Server-->>Mobile: 返回空结果
147+
end
148+
end
149+
```
150+
151+
## 开发环境要求
152+
153+
- Node.js >= 18
154+
- Rust >= 1.75
155+
- pnpm >= 8.0
156+
- 操作系统:
157+
- macOS 10.15+
158+
- Windows 10+
53159

54160
## 使用方法
55161

@@ -88,62 +194,6 @@ Desky 主要包含以下几个核心组件:
88194

89195

90196

91-
## 项目结构
92-
93-
```mermaid
94-
graph TB
95-
UI[React UI Layer]
96-
Backend[Tauri Backend]
97-
Hardware[Hardware Control]
98-
Vision[Computer Vision]
99-
Audio[Audio Processing]
100-
101-
UI --> Backend
102-
Backend --> Hardware
103-
Backend --> Vision
104-
Backend --> Audio
105-
106-
subgraph Frontend
107-
UI --> VideoFeed[Video Feed]
108-
UI --> Controls[Servo Controls]
109-
UI --> Chat[Chat Interface]
110-
end
111-
112-
subgraph Core Services
113-
Backend --> DeviceManager[Device Manager]
114-
Backend --> ServoController[Servo Controller]
115-
Backend --> WebSocket[WebSocket Client]
116-
end
117-
```
118-
119-
120-
121-
## 交互流程
122-
123-
```mermaid
124-
sequenceDiagram
125-
participant U as User
126-
participant UI as Frontend
127-
participant B as Backend
128-
participant H as Hardware
129-
participant S as Server
130-
131-
U->>UI: Input Text/Voice
132-
UI->>B: Send Request
133-
B->>S: API Call
134-
S-->>B: Response
135-
B->>UI: Update UI
136-
B->>H: Control Servo
137-
138-
## 开发环境要求
139-
140-
- Node.js >= 18
141-
- Rust >= 1.75
142-
- pnpm >= 8.0
143-
- 操作系统:
144-
- macOS 10.15+
145-
- Windows 10+
146-
147197
## 许可证
148198

149199
本项目采用 MIT 许可证。详情请见 [LICENSE](LICENSE) 文件。

0 commit comments

Comments
 (0)