Files
RCS-3000/docs/custom_path/install_custom_path.sh
CaiXiang af65c2425d initial
2025-11-14 16:09:58 +08:00

74 lines
2.1 KiB
Bash
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.

#!/bin/bash
# 安装自定义路径功能脚本
echo "=========================================="
echo " AGV 自定义路径功能安装脚本"
echo "=========================================="
# 1. 检查必要文件
if [ ! -f "src/path_curve_custom.cpp" ]; then
echo "错误: 找不到 src/path_curve_custom.cpp"
exit 1
fi
# 2. 备份原始头文件
echo "备份原始头文件..."
cp include/path_curve.h include/path_curve.h.backup
# 3. 修改头文件
echo "更新头文件..."
# 添加 string 头文件
sed -i '5 a #include <string>' include/path_curve.h
# 在 setPathPoints 方法后添加新方法声明
sed -i '/void setPathPoints/a \
\
/**\
* @brief 从CSV文件加载路径点\
* @param filename CSV文件路径\
* @param has_header 是否包含表头默认true\
* @return 是否加载成功\
*/\
bool loadFromCSV(const std::string& filename, bool has_header = true);\
\
/**\
* @brief 将路径点保存到CSV文件\
* @param filename CSV文件路径\
* @return 是否保存成功\
*/\
bool saveToCSV(const std::string& filename) const;\
\
/**\
* @brief 使用样条插值生成路径\
* @param key_points 关键路径点\
* @param num_points 生成的路径点总数\
* @param tension 张力参数\
*/\
void generateSpline(const std::vector<PathPoint>& key_points,\
int num_points = 100,\
double tension = 0.5);' include/path_curve.h
# 4. 修改 CMakeLists.txt
echo "更新 CMakeLists.txt..."
cp CMakeLists.txt CMakeLists.txt.backup
sed -i '/src\/path_curve.cpp/a \ src/path_curve_custom.cpp' CMakeLists.txt
# 5. 重新编译
echo "重新编译项目..."
mkdir -p build
cd build
cmake ..
cmake --build .
echo "=========================================="
echo " 安装完成!"
echo "=========================================="
echo "备份文件:"
echo " - include/path_curve.h.backup"
echo " - CMakeLists.txt.backup"
echo ""
echo "使用指南: CUSTOM_PATH_GUIDE.md"
echo "示例文件: examples/custom_path.csv"