Compare commits

..

3 Commits

Author SHA1 Message Date
49ea9fe7f5 update v 2026-04-24 15:50:34 +07:00
d5ef0b1075 Hiep sửa bản kính R 2026-04-24 14:50:27 +07:00
62a493a892 update 2026-04-15 07:30:04 +00:00
2 changed files with 20 additions and 8 deletions

View File

@@ -51,6 +51,7 @@ namespace custom_planner
plan.clear(); plan.clear();
// Check for reinitialization needs // Check for reinitialization needs
robot::log_error("yaw goal: %f", data_convert::getYaw(goal.pose.orientation));
bool do_init = false; bool do_init = false;
if(!makePlanWithOrder(msg, start, goal)) return false; if(!makePlanWithOrder(msg, start, goal)) return false;
if (current_env_width_ != costmap_robot_->getCostmap()->getSizeInCellsX() || if (current_env_width_ != costmap_robot_->getCostmap()->getSizeInCellsX() ||
@@ -1157,14 +1158,23 @@ namespace custom_planner
double yaw_goal = data_convert::getYaw(goal.pose.orientation); double yaw_goal = data_convert::getYaw(goal.pose.orientation);
// printf("[custom_planner] DEBUG: angle: %f; yaw_goal: %f",angle, yaw_goal); // printf("[custom_planner] DEBUG: angle: %f; yaw_goal: %f",angle, yaw_goal);
// nomalize angle to [-pi, pi] // nomalize angle [-pi, pi] to [0, 2*pi]
auto normalizeAngle = [](double a) { auto normalizeAngle = [](double a) -> double
while (a > M_PI) a -= 2 * M_PI; {
while (a < -M_PI) a += 2 * M_PI; while (a > 2 * M_PI) a -= 2 * M_PI;
while (a < 0) a += 2 * M_PI;
return a; return a;
}; };
double delta_angle = std::fabs(normalizeAngle(yaw_goal) - normalizeAngle(angle)); auto wrapToPi = [](double a) -> double
{
while (a > M_PI) a -= 2.0 * M_PI;
while (a < -M_PI) a += 2.0 * M_PI;
return a;
};
double delta_angle = std::fabs(wrapToPi(normalizeAngle(yaw_goal) - normalizeAngle(angle)));
robot::log_warning("DEBUG 3: yaw_goal: %f, angle: %f, delta_angle: %f", yaw_goal, angle, delta_angle); robot::log_warning("DEBUG 3: yaw_goal: %f, angle: %f, delta_angle: %f", yaw_goal, angle, delta_angle);
return (delta_angle > (0.5 * M_PI)); return (delta_angle > (0.5 * M_PI));
} }

View File

@@ -177,9 +177,11 @@ namespace custom_planner {
// Các hằng số chung cho cả START và GOAL // Các hằng số chung cho cả START và GOAL
static const double MAX_DISTANCE = 1.0; // Ngưỡng khoảng cách tối đa (m) static const double MAX_DISTANCE = 1.0; // Ngưỡng khoảng cách tối đa (m)
static const double MIN_DISTANCE = 0.1; // Khoảng cách tối thiểu (m) static const double MIN_DISTANCE = 0.1; // Khoảng cách tối thiểu (m)
static const double MIN_SCALE = 0.2; // Giá trị tối thiểu của hệ số static const double MIN_SCALE = 0.5; // Giá trị tối thiểu của hệ số
static const double MAX_SCALE = 1.0; // Giá trị tối đa của hệ số static const double MAX_SCALE = 1.0; // Giá trị tối đa của hệ số
static const double MAX_ANGLE_THRESHOLD = 0.77 * M_PI; // Ngưỡng góc tối đa static const double MAX_ANGLE_THRESHOLD = 0.9 * M_PI; // Ngưỡng góc tối đa
static const double TURNING_GAIN = 0.8;
static const double CALIB_VAL = 0.5;
int nearest_idx = 0; int nearest_idx = 0;
@@ -218,7 +220,7 @@ namespace custom_planner {
(MAX_DISTANCE - MIN_DISTANCE); (MAX_DISTANCE - MIN_DISTANCE);
// === BƯỚC 3: TÍNH TOÁN NGƯỠNG GÓC === // === BƯỚC 3: TÍNH TOÁN NGƯỠNG GÓC ===
double angle_threshold = (0.5 + std::abs(scale)) * 0.5 * M_PI; double angle_threshold = (CALIB_VAL + std::abs(scale)) * TURNING_GAIN * M_PI;
if(angle_threshold >= MAX_ANGLE_THRESHOLD) if(angle_threshold >= MAX_ANGLE_THRESHOLD)
angle_threshold = MAX_ANGLE_THRESHOLD; angle_threshold = MAX_ANGLE_THRESHOLD;