Cắt bỏ (~2400 dòng):
- plan_for_retry.cpp: file ROS1 legacy (ros/ros.h, tf/tf.h), không nằm trong
CMakeLists, không compile được trong stack này.
- pathway.{h,cc}, pose.cc, color.h, conversion.h: class Pathway/Edge/Point,
Pose file-IO, agv_visualization::Color, Eigen conversion — 0 nơi dùng.
- Curve_common tỉa còn đúng API đang dùng (ReadSplineInf x2,
CalculateCurvePoint); bỏ Generate_*/ShowDiscreatePoint*/Curvature* chết —
nhờ đó bỏ dependency robot_visualization_msgs, robot_nav_msgs,
robot_std_msgs khỏi CMakeLists + package.xml.
- Xoá 7 method declare-only/định nghĩa không ai gọi trong CustomPlanner
(publishStats, loadPathwayData, findNearestPoseOfPath, computeDeltaAngle,
divideSegment x2, transformFootprintToEdges, isThetaValid), member mutex_,
khối gui_path build xong không publish.
Config (trước đây planner không đọc bất kỳ param nào — toàn bộ yaml là key
SBPL copy nhầm, mọi tunable hard-code):
- CustomPlannerConfig: 11 param có default = giá trị hard-code cũ (giữ nguyên
hành vi khi yaml thiếu key), validate range + log giá trị chốt.
- Viết lại config/custom_global_params.yaml đủ key kèm đơn vị.
- FIX: NodeHandle("~/" + name) không resolve segment "~", âm thầm rơi về
root nên getParam luôn trả default. Đổi sang NodeHandle(name).
Sửa đúng đắn:
- checkYawEdgeEnd: fabs(|a|-|b|) xoá dấu — cặp góc trái dấu cùng độ lớn
(vd ±pi/2, lệch thật pi) cho delta=0, planner chọn nhầm đi tiến và robot
quay đầu thay vì lùi. Thay bằng fabs(wrapToPi(yaw_goal - angle)), ngưỡng
thành param backward_decision_angle (đồng bộ công thức với bản rb_ws).
- Bỏ new/delete thô: Spline_Inf/Curve_common thành member by-value ở cả
CustomPlanner lẫn MergePathCalc.
- Bỏ using namespace std khỏi header; EPSILON toàn cục -> kEpsilon trong
namespace; makePlan(start,goal) log qua robot::log_warning.
- package.xml viết lại (bản cũ copy nguyên metadata của tf2).
Verify:
- catkin_make --pkg custom_planner: PASS, symbol BOOST_DLL_ALIAS
CustomPlanner còn trong libcustom_planner.so.
- Smoke test nạp config: đọc đúng 11 key từ cây pnkx_nav_core/config và
Test/move_base2/config/runtime; override ăn; giá trị ngoài range bị kẹp
kèm warning.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
44 lines
1.1 KiB
C++
Executable File
44 lines
1.1 KiB
C++
Executable File
#ifndef CUSTOM_PLANNER_CUSTOM_PLANNER_POSE_H
|
|
#define CUSTOM_PLANNER_CUSTOM_PLANNER_POSE_H
|
|
|
|
#include <cmath>
|
|
|
|
namespace custom_planner{
|
|
|
|
class Pose {
|
|
private:
|
|
double x_, y_, yaw_; // [m], [m], [rad] — yaw giữ trong [-pi, pi] qua modifyYaw()
|
|
|
|
void modifyYaw(void) {
|
|
while (yaw_ < -M_PI)
|
|
yaw_ += 2.0 * M_PI;
|
|
while (yaw_ > M_PI)
|
|
yaw_ -= 2.0 * M_PI;
|
|
}
|
|
|
|
public:
|
|
Pose():
|
|
x_(0.0), y_(0.0), yaw_(0.0) {};
|
|
|
|
Pose(double x, double y, double yaw):
|
|
x_(x), y_(y), yaw_(yaw) {};
|
|
|
|
~Pose() = default;
|
|
|
|
inline void setX(double x) { x_ = x; }
|
|
inline void setY(double y) { y_ = y; }
|
|
inline void setYaw(double yaw) { yaw_ = yaw, modifyYaw(); }
|
|
inline void setPose(double x, double y, double yaw) { x_ = x, y_ = y, yaw_ = yaw, modifyYaw(); }
|
|
inline void setPose(Pose p) { x_ = p.x_, y_ = p.y_, yaw_ = p.yaw_, modifyYaw(); }
|
|
|
|
inline double getX(void) { return x_; }
|
|
inline double getY(void) { return y_; }
|
|
inline double getYaw(void) { return yaw_; }
|
|
inline Pose getPose(void) { return Pose(x_, y_, yaw_); }
|
|
|
|
}; // class Pose
|
|
|
|
}
|
|
|
|
#endif
|