--- include/path_curve.h.original +++ include/path_curve.h @@ -4,6 +4,7 @@ #include +#include #define _USE_MATH_DEFINES #include @@ -77,6 +78,34 @@ void setPathPoints(const std::vector& points); /** + * @brief 从CSV文件加载路径点 + * @param filename CSV文件路径 + * @param has_header 是否包含表头(默认true) + * @return 是否加载成功 + * + * CSV格式支持以下两种: + * 1. 完整格式:x, y, theta, kappa + * 2. 简化格式:x, y (theta和kappa将自动计算) + */ + 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 关键路径点(只需指定x和y) + * @param num_points 生成的路径点总数 + * @param tension 张力参数(0.0-1.0,控制曲线平滑度,默认0.5) + */ + void generateSpline(const std::vector& key_points, + int num_points = 100, + double tension = 0.5); + + /** * @brief 获取路径点 */ const std::vector& getPathPoints() const { return path_points_; }