This commit is contained in:
CaiXiang
2025-11-14 16:09:58 +08:00
commit af65c2425d
74 changed files with 14650 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
--- include/path_curve.h.original
+++ include/path_curve.h
@@ -4,6 +4,7 @@
#include <vector>
+#include <string>
#define _USE_MATH_DEFINES
#include <cmath>
@@ -77,6 +78,34 @@
void setPathPoints(const std::vector<PathPoint>& 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<PathPoint>& key_points,
+ int num_points = 100,
+ double tension = 0.5);
+
+ /**
* @brief 获取路径点
*/
const std::vector<PathPoint>& getPathPoints() const { return path_points_; }