Files
agv-control-slam/docs/custom_path/SMOOTH_PATH_QUICKSTART.md
CaiXiang af65c2425d initial
2025-11-14 16:09:58 +08:00

126 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 快速开始:平滑路径生成器 🚀
## 一键生成所有路径
```bash
# 从项目根目录运行
./build/Debug/generate_smooth_path.exe
```
✅ 自动生成 6 个平滑路径 CSV 文件!
## 三步使用流程
### 第1步编译只需一次
```bash
cd build
cmake --build . --target generate_smooth_path --config Debug
```
### 第2步生成路径
```bash
cd ..
./build/Debug/generate_smooth_path.exe
```
### 第3步在Qt GUI中查看
```bash
# 启动Qt GUI
./build/Debug/agv_qt_gui.exe
# 在界面中:
# 1. Path Type 选择 "Load from CSV"
# 2. 选择任意生成的 CSV 文件
# 3. 点击 "Generate Control"
```
## 生成的文件
| 文件名 | 描述 | 用途 |
|--------|------|------|
| `smooth_path.csv` | 默认平滑路径 | 基础测试 |
| `smooth_path_arc.csv` | 圆弧路径 | 转弯场景 |
| `smooth_path_scurve.csv` | S型曲线 | 避障场景 |
| `smooth_path_complex.csv` | 复杂路径 | 仓库导航 |
| `smooth_path_loop.csv` | 环形路径 | 循环巡逻 |
| `smooth_path_figure8.csv` | 8字形路径 | 复杂测试 |
## 代码调用示例
### 最简单的用法
```cpp
#include "path_curve.h"
int main() {
// 创建路径
PathCurve path;
// 定义关键点
std::vector<PathPoint> points = {
PathPoint(0, 0),
PathPoint(5, 2),
PathPoint(10, 0)
};
// 生成样条曲线
path.generateSpline(points, 200, 0.5);
// 保存
path.saveToCSV("my_path.csv");
return 0;
}
```
### 使用封装类
```cpp
// 方法1: 生成S型曲线
SmoothPathGenerator::generateSCurve("scurve.csv", 0, 0, 10, 0);
// 方法2: 生成圆弧
SmoothPathGenerator::generateCircleArc("arc.csv", 5, 0, 5, 0, M_PI);
// 方法3: 生成自定义样条
std::vector<PathPoint> my_points = {
PathPoint(0, 0), PathPoint(5, 3), PathPoint(10, 0)
};
SmoothPathGenerator::generateSpline("custom.csv", my_points, 200);
```
## 常用参数说明
| 参数 | 说明 | 推荐值 |
|------|------|--------|
| `num_points` | 路径点数量 | 200-300 |
| `tension` | 张力参数 | 0.3-0.5 |
| `radius` | 圆弧半径 | 3-10 米 |
| `control_offset` | S曲线控制点偏移 | 2-4 米 |
## 完整文档
📖 详细使用说明请查看:`SMOOTH_PATH_GENERATOR_README.md`
## 项目结构
```
examples/
├── generate_smooth_path.cpp # 平滑路径生成器源码
├── qt_gui_demo.cpp # Qt GUI支持加载CSV
└── ...
build/Debug/
├── generate_smooth_path.exe # 路径生成程序
└── agv_qt_gui.exe # Qt GUI程序
smooth_path*.csv # 生成的路径文件(项目根目录)
```
---
**提示**: 如果想只生成特定路径,可以直接调用对应的类方法,或修改 `main()` 函数。