Add recovery and mission manager structure
This commit is contained in:
@@ -174,7 +174,8 @@ namespace robot
|
||||
{
|
||||
public:
|
||||
using Ptr = std::shared_ptr<BaseNavigation>;
|
||||
|
||||
robot_nav_msgs::OccupancyGrid map_save_;
|
||||
std::string map_name_save_;
|
||||
virtual ~BaseNavigation() {}
|
||||
|
||||
/**
|
||||
|
||||
@@ -125,6 +125,7 @@ namespace move_base
|
||||
* @param laser_scan The laser scan to add.
|
||||
*/
|
||||
virtual void addLaserScan(const std::string &laser_scan_name, robot_sensor_msgs::LaserScan laser_scan) override;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add a point cloud to the navigation system.
|
||||
|
||||
@@ -266,6 +266,26 @@ void move_base::MoveBase::initialize(robot::TFListenerPtr tf)
|
||||
robot::log_error("[%s:%d]\n EXCEPTION: %s", __FILE__, __LINE__, ex.what());
|
||||
throw std::runtime_error("Failed to create the planner_costmap_robot_");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
controller_costmap_robot_ = new robot_costmap_2d::Costmap2DROBOT("local_costmap", *tf_);
|
||||
if(controller_costmap_robot_ == nullptr)
|
||||
{
|
||||
robot::log_error("[%s:%d]\n ERROR: controller_costmap_robot_ is nullptr", __FILE__, __LINE__);
|
||||
throw std::runtime_error("Failed to create the controller_costmap_robot_");
|
||||
}
|
||||
controller_costmap_robot_->pause();
|
||||
robot_costmap_2d::LayeredCostmap *layered_costmap_ = controller_costmap_robot_->getLayeredCostmap();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
robot::log_error("[%s:%d]\n EXCEPTION: %s", __FILE__, __LINE__, ex.what());
|
||||
throw std::runtime_error("Failed to create the controller_costmap_robot_");
|
||||
}
|
||||
|
||||
addStaticMap(map_name_save_, map_save_);
|
||||
|
||||
// initialize the global planner
|
||||
try
|
||||
{
|
||||
@@ -294,22 +314,6 @@ void move_base::MoveBase::initialize(robot::TFListenerPtr tf)
|
||||
throw std::runtime_error("Failed to create the " + global_planner + " planner");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
controller_costmap_robot_ = new robot_costmap_2d::Costmap2DROBOT("local_costmap", *tf_);
|
||||
if(controller_costmap_robot_ == nullptr)
|
||||
{
|
||||
robot::log_error("[%s:%d]\n ERROR: controller_costmap_robot_ is nullptr", __FILE__, __LINE__);
|
||||
throw std::runtime_error("Failed to create the controller_costmap_robot_");
|
||||
}
|
||||
controller_costmap_robot_->pause();
|
||||
robot_costmap_2d::LayeredCostmap *layered_costmap_ = controller_costmap_robot_->getLayeredCostmap();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
robot::log_error("[%s:%d]\n EXCEPTION: %s", __FILE__, __LINE__, ex.what());
|
||||
throw std::runtime_error("Failed to create the controller_costmap_robot_");
|
||||
}
|
||||
// create a local planner
|
||||
try
|
||||
{
|
||||
@@ -487,7 +491,7 @@ void move_base::MoveBase::addStaticMap(const std::string &map_name, robot_nav_ms
|
||||
// for(size_t i = 0; i < map.data.size(); i++) {
|
||||
// robot::log_info("map data[%zu]: %d", i, map.data[i]);
|
||||
// }
|
||||
// robot::log_info("--------------------------------");
|
||||
robot::log_info("--------------------------------");
|
||||
updateGlobalCostmap<robot_nav_msgs::OccupancyGrid>(map, robot_costmap_2d::LayerType::STATIC_LAYER, map_name);
|
||||
updateLocalCostmap<robot_nav_msgs::OccupancyGrid>(map, robot_costmap_2d::LayerType::STATIC_LAYER, map_name);
|
||||
}
|
||||
@@ -729,8 +733,15 @@ void move_base::MoveBase::updateGlobalCostmap(const T& value, robot_costmap_2d::
|
||||
{
|
||||
// Kiểm tra layer có đúng type và name không
|
||||
// Nếu layer type khớp HOẶC name khớp thì update
|
||||
// if(layer->getType() == robot_costmap_2d::LayerType::STATIC_LAYER)
|
||||
// robot::log_warning ("[%s:%d] Update GlobalCostmap: layer type: %d, name: %s, layer->getType(): %d, layer->getName(): %s", __FILE__, __LINE__, layer_type, name.c_str(), layer->getType(), layer->getName().c_str());
|
||||
if (layer->getType() == layer_type || layer->getName() == name)
|
||||
{
|
||||
if(layer->getType() == robot_costmap_2d::LayerType::STATIC_LAYER)
|
||||
{
|
||||
robot::log_warning("[%s:%d] Update GlobalCostmap: layer type is STATIC_LAYER, name: %s", __FILE__, __LINE__, name.c_str());
|
||||
}
|
||||
|
||||
// Update costmap với data
|
||||
layer->dataCallBack<T>(value, name);
|
||||
}
|
||||
@@ -2864,7 +2875,7 @@ bool move_base::MoveBase::executeCycle(robot_geometry_msgs::PoseStamped &goal)
|
||||
{
|
||||
if (tc_->isGoalReached())
|
||||
{
|
||||
robot::log_debug("Goal reached!");
|
||||
robot::log_debug("[MoveBase] Goal reached!");
|
||||
resetState();
|
||||
// swapPlanner(default_config_.base_global_planner);
|
||||
// disable the planner thread
|
||||
|
||||
Reference in New Issue
Block a user