给下列程序添加注释namespace nav_core { /** * @class BaseGlobalPlanner * @brief Provides an interface for global planners used in navigation. All global planners written as plugins for the navigation stack must adhere to this interface. */ class BaseGlobalPlanner{ public: /** * @brief Given a goal pose in the world, compute a plan * @param start The start pose * @param goal The goal pose * @param plan The plan... filled by the planner * @return True if a valid plan was found, false otherwise */ virtual bool makePlan(const geometry_msgs::PoseStamped& start, const geometry_msgs::PoseStamped& goal, std::vector<geometry_msgs::PoseStamped>& plan) = 0; /** * @brief Given a goal pose in the world, compute a plan * @param start The start pose * @param goal The goal pose * @param plan The plan... filled by the planner * @param cost The plans calculated cost * @return True if a valid plan was found, false otherwise */ virtual bool makePlan(const geometry_msgs::PoseStamped& start, const geometry_msgs::PoseStamped& goal, std::vector<geometry_msgs::PoseStamped>& plan, double& cost) { cost = 0; return makePlan(start, goal, plan); } /** * @brief Initialization function for the BaseGlobalPlanner * @param name The name of this planner * @param costmap_ros A pointer to the ROS wrapper of the costmap to use for planning */ virtual void initialize(std::string name, costmap_2d::Costmap2DROS* costmap_ros) = 0; /** * @brief Virtual destructor for the interface */ virtual ~BaseGlobalPlanner(){} protected: BaseGlobalPlanner(){} }; }; // namespace nav_core #endif // NAV_CORE_BASE_GLOBAL_PLANNER_H
时间: 2024-02-14 16:17:22 浏览: 150
C++ 程序文档生成器介绍(doxygen)
```cpp
namespace nav_core {
/**
* @class BaseGlobalPlanner
* @brief Provides an interface for global planners used in navigation. All global planners written as plugins for the navigation stack must adhere to this interface.
*/
class BaseGlobalPlanner{
public:
/**
* @brief Given a goal pose in the world, compute a plan
* @param start The start pose
* @param goal The goal pose
* @param plan The plan... filled by the planner
* @return True if a valid plan was found, false otherwise
*/
virtual bool makePlan(const geometry_msgs::PoseStamped& start,
const geometry_msgs::PoseStamped& goal, std::vector<geometry_msgs::PoseStamped>& plan) = 0;
/**
* @brief Given a goal pose in the world, compute a plan
* @param start The start pose
* @param goal The goal pose
* @param plan The plan... filled by the planner
* @param cost The plans calculated cost
* @return True if a valid plan was found, false otherwise
*/
virtual bool makePlan(const geometry_msgs::PoseStamped& start,
const geometry_msgs::PoseStamped& goal, std::vector<geometry_msgs::PoseStamped>& plan,
double& cost)
{
cost = 0;
return makePlan(start, goal, plan);
}
/**
* @brief Initialization function for the BaseGlobalPlanner
* @param name The name of this planner
* @param costmap_ros A pointer to the ROS wrapper of the costmap to use for planning
*/
virtual void initialize(std::string name, costmap_2d::Costmap2DROS* costmap_ros) = 0;
/**
* @brief Virtual destructor for the interface
*/
virtual ~BaseGlobalPlanner(){}
protected:
BaseGlobalPlanner(){}
};
}; // namespace nav_core
#endif // NAV_CORE_BASE_GLOBAL_PLANNER_H
```
这是一个名称空间为`nav_core`的C++程序。它定义了一个名为`BaseGlobalPlanner`的类,这个类是一个抽象类,提供用于导航中使用的全局计划器的接口。所有针对导航堆栈编写的全局计划器插件都必须遵循这个接口。
这个类有三个公共函数:
- `makePlan`:给定世界中的目标姿态,计算一个计划。
- `initialize`:初始化函数,用于设置计划器的名称和代价地图。
- 析构函数:用于销毁实例。
其中,`makePlan`函数有两个版本,其中一个版本还返回计划的代价。这个类还提供了一个保护构造函数,用于派生类的构造。
阅读全文