This commit is contained in:
2026-08-06 15:17:59 +07:00
parent 701d25f952
commit 5375a9da9e
33 changed files with 3199 additions and 137 deletions

View File

@@ -14,9 +14,11 @@
#include <boost/dll/import.hpp>
#include <boost/system/system_error.hpp>
#include <boost/thread/locks.hpp>
#include <robot/plugin_loader_helper.h>
#include <robot/robot.h>
#include <robot_costmap_2d/costmap_2d_robot.h>
namespace move_base2
{
@@ -364,6 +366,17 @@ void PlannerRunner::threadBody()
try
{
ScopedSection timer(stats_, section_make_plan_);
// Khoá lưới costmap suốt makePlan — cùng giao thức với gen-1 (move_base.cpp:1921,1959):
// LayeredCostmap::updateMap ghi lưới, và resizeMap REALLOC cả mảng, dưới đúng mutex này.
// Không khoá thì planner đọc cost đang bị ghi dở, hoặc tệ hơn là đọc vào vùng nhớ vừa bị
// resize giải phóng khi static map được nhận lại. Lấy getCostmap() mỗi lượt, không cache —
// con trỏ đó có thể bị thay (bài học double-free của workspace).
boost::unique_lock<robot_costmap_2d::Costmap2D::mutex_t> costmap_lock;
if (costmap_lock_enabled_)
{
costmap_lock = boost::unique_lock<robot_costmap_2d::Costmap2D::mutex_t>(
*(costmap_->getCostmap()->getMutex()));
}
// Hai overload của interface gốc gộp lại: "có Order hay không" là một nhánh, không phải hai
// contract. Plugin nào không hiểu Order thì overload mặc định của nó tự lo.
ok = (order != nullptr) ? planner->makePlan(*order, start, goal, planning_)