Add recovery and mission manager structure
This commit is contained in:
0
src/APIs/c_api/include/nav_c_api_io_structure.md
Normal file
0
src/APIs/c_api/include/nav_c_api_io_structure.md
Normal file
Submodule src/Algorithms/Packages/global_planners/custom_planner updated: 49ea9fe7f5...7c84705ce7
@@ -45,6 +45,8 @@ namespace two_points_planner
|
||||
|
||||
name_ = name;
|
||||
costmap_robot_ = costmap_robot;
|
||||
|
||||
|
||||
|
||||
if(!costmap_robot_ || !costmap_robot_->getCostmap())
|
||||
{
|
||||
@@ -55,6 +57,8 @@ namespace two_points_planner
|
||||
current_env_height_ = costmap_robot_->getCostmap()->getSizeInCellsY();
|
||||
footprint_ = costmap_robot_->getRobotFootprint();
|
||||
|
||||
robot::log_info("size x: %d, size y: %d, resolution: %f", costmap_robot_->getCostmap()->getSizeInCellsX(), costmap_robot_->getCostmap()->getSizeInCellsY(), costmap_robot_->getCostmap()->getResolution());
|
||||
|
||||
robot::log_info("TwoPointsPlanner Initialized successfully");
|
||||
initialized_ = true;
|
||||
return true;
|
||||
@@ -119,6 +123,18 @@ namespace two_points_planner
|
||||
robot::log_error("[%s:%d]\n TwoPointsPlanner: Global planner is not initialized", __FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
robot::Time start_time = robot::Time::now();
|
||||
robot::Rate rate(1.0);
|
||||
while(costmap_robot_->getCostmap()->getSizeInCellsX() == 0 || costmap_robot_->getCostmap()->getSizeInCellsY() == 0){
|
||||
robot::log_warning("Waiting for costmap to be initialized...");
|
||||
rate.sleep();
|
||||
if((robot::Time::now() - start_time).toSec() > 5.0){
|
||||
robot::log_error("Costmap not initialized after 10 seconds, exiting...");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
robot::log_warning("abc testttttt!, SizeInCellsX = %d, SizeInCellsY = %d", costmap_robot_->getCostmap()->getSizeInCellsX(), costmap_robot_->getCostmap()->getSizeInCellsY());
|
||||
|
||||
robot_nav_2d_msgs::Pose2DStamped start_2d = robot_nav_2d_utils::poseStampedToPose2D(start);
|
||||
robot_nav_2d_msgs::Pose2DStamped goal_2d = robot_nav_2d_utils::poseStampedToPose2D(goal);
|
||||
|
||||
@@ -366,6 +366,7 @@ robot_nav_2d_msgs::Twist2DStamped pnkx_local_planner::PNKXDockingLocalPlanner::c
|
||||
const robot_nav_2d_msgs::Twist2D &velocity)
|
||||
{
|
||||
// boost::recursive_mutex::scoped_lock l(configuration_mutex_);
|
||||
robot::log_error("DEBUG 300");
|
||||
robot_nav_2d_msgs::Twist2DStamped cmd_vel;
|
||||
try
|
||||
{
|
||||
@@ -424,9 +425,9 @@ bool pnkx_local_planner::PNKXDockingLocalPlanner::isGoalReached(const robot_nav_
|
||||
robot::log_warning_at(__FILE__, __LINE__, "Cannot check if the goal is reached without the goal being set!");
|
||||
return false;
|
||||
}
|
||||
|
||||
robot::log_error("DEBUG 400.1");
|
||||
bool dock_ok = dockingHanlde(pose, velocity);
|
||||
|
||||
robot::log_error("DEBUG 400.2");
|
||||
// Update time stamp of goal pose
|
||||
// goal_pose_.header.stamp = pose.header.stamp;
|
||||
robot_nav_2d_msgs::Pose2DStamped local_pose = this->transformPoseToLocal(pose);
|
||||
@@ -503,6 +504,7 @@ bool pnkx_local_planner::PNKXDockingLocalPlanner::dockingHanlde(const robot_nav_
|
||||
{
|
||||
if (dkpl_.front()->geLocalGoal(local_goal))
|
||||
{
|
||||
robot::log_error("DEBUG 100");
|
||||
dkpl_.front()->is_detected_ = true;
|
||||
start_docking_ = true;
|
||||
robot_nav_msgs::Path path;
|
||||
@@ -524,6 +526,7 @@ bool pnkx_local_planner::PNKXDockingLocalPlanner::dockingHanlde(const robot_nav_
|
||||
{
|
||||
if (dkpl_.front()->geLocalGoal(local_goal))
|
||||
{
|
||||
robot::log_error("DEBUG 200");
|
||||
dkpl_.front()->is_detected_ = true;
|
||||
start_docking_ = true;
|
||||
robot_nav_2d_msgs::Path2D path;
|
||||
|
||||
@@ -208,12 +208,14 @@ void pnkx_local_planner::PNKXLocalPlanner::reset()
|
||||
void pnkx_local_planner::PNKXLocalPlanner::setGoalPose(const robot_nav_2d_msgs::Pose2DStamped &goal_pose)
|
||||
{
|
||||
// boost::recursive_mutex::scoped_lock l(configuration_mutex_);
|
||||
robot::log_error("[PNKXLocalPlanner] Receive new goal(%f, %f)!", goal_pose.pose.x, goal_pose.pose.y);
|
||||
reset();
|
||||
goal_pose_ = goal_pose;
|
||||
}
|
||||
|
||||
void pnkx_local_planner::PNKXLocalPlanner::setPlan(const robot_nav_2d_msgs::Path2D &path)
|
||||
{
|
||||
robot::log_error("[PNKXLocalPlanner] size path: %d", (int)path.poses.size());
|
||||
// boost::recursive_mutex::scoped_lock l(configuration_mutex_);
|
||||
costmap_robot_->resetLayers();
|
||||
global_plan_ = path;
|
||||
|
||||
BIN
src/Libraries/costmap_2d.zip
Normal file
BIN
src/Libraries/costmap_2d.zip
Normal file
Binary file not shown.
Submodule src/Libraries/data_convert updated: 004dd7f0ff...1cf62c0856
Submodule src/Libraries/robot_time updated: 75075a3498...0c007fdab3
@@ -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