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

45 lines
1.4 KiB
Diff
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.

--- 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_; }