add new file nav_c_api2 and function

This commit is contained in:
2026-08-06 19:50:46 +07:00
parent 565e18bfb8
commit ad28a413cc
34 changed files with 2439 additions and 216 deletions

View File

@@ -14,6 +14,7 @@
#include <robot_nav_msgs/Odometry.h>
#include <robot_nav_msgs/OccupancyGrid.h>
#include <robot_map_msgs/OccupancyGridUpdate.h>
#include <robot_sensor_msgs/DepthCameraData.h>
#include <robot_sensor_msgs/LaserScan.h>
#include <robot_sensor_msgs/PointCloud.h>
#include <robot_sensor_msgs/PointCloud2.h>
@@ -184,6 +185,19 @@ namespace robot
*/
virtual void initialize(TFListenerPtr tf) = 0;
/**
* @brief Stop internal activity (control loop, planner...) before destruction.
*
* The host MUST be able to quiesce the navigation core at a chosen point in its
* own shutdown sequence, while the process is still fully alive — destroying the
* object from a static-destruction context after main() has returned is exactly
* the race that produced boost::lock_error crashes. Default is a no-op so legacy
* implementations remain source-compatible; after this call the object must stop
* producing velocity commands, and queries (getFeedback, getTwist...) must remain
* safe to call. Safe to call multiple times.
*/
virtual void shutdown() {}
/**
* @brief Set the robot's footprint (outline shape) in the global frame.
* This can be used for planning or collision checking.
@@ -245,6 +259,14 @@ namespace robot
*/
virtual void addPointCloud2(const std::string &point_cloud2_name, robot_sensor_msgs::PointCloud2 point_cloud2) = 0;
/**
* @brief Add one coherent depth-camera sample to the navigation system.
* @param topic The logical topic of the combined depth-camera stream.
* @param data Depth image and matching camera intrinsics.
*/
virtual void addDepthCameraData(const std::string &topic,
robot_sensor_msgs::DepthCameraData::ConstPtr data) = 0;
/**
* @brief Get a static map from the navigation system.
* @param map_name The name of the map.

View File

@@ -36,6 +36,7 @@
#include <robot_nav_core2/common.h>
#include <robot_nav_core2/costmap.h>
#include <robot_nav_core2/exceptions.h>
#include <robot_nav_2d_msgs/Path2D.h>
#include <robot_nav_2d_msgs/Pose2DStamped.h>
#include <string>

View File

@@ -36,6 +36,7 @@
#include <robot_nav_core2/common.h>
#include <robot_nav_core2/costmap.h>
#include <robot_nav_core2/exceptions.h>
#include <robot_nav_2d_msgs/Path2D.h>
#include <robot_nav_2d_msgs/Pose2DStamped.h>
#include <robot_nav_2d_msgs/Twist2D.h>

View File

@@ -46,6 +46,7 @@ if (NOT BUILDING_WITH_CATKIN)
robot_cpp
robot_move_base_msgs
laser_filter
mission_adapters
)
find_library(TF3_LIBRARY NAMES tf3 PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu)
else()
@@ -65,12 +66,13 @@ else()
robot_nav_2d_utils
robot_cpp
robot_move_base_msgs
mission_adapters
)
find_library(TF3_LIBRARY NAMES tf3 PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu)
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS geometry_msgs robot_std_msgs move_base_core robot_nav_core robot_costmap_2d robot_tf3_sensor_msgs robot_tf3_geometry_msgs data_convert robot_nav_2d_utils robot_cpp robot_move_base_msgs
CATKIN_DEPENDS mission_adapters geometry_msgs robot_std_msgs move_base_core robot_nav_core robot_costmap_2d robot_tf3_sensor_msgs robot_tf3_geometry_msgs data_convert robot_nav_2d_utils robot_cpp robot_move_base_msgs
DEPENDS Boost yaml-cpp
)

View File

@@ -18,6 +18,7 @@
#include <robot_nav_core/base_global_planner.h>
#include <robot_nav_core/base_local_planner.h>
#include <robot_nav_core/recovery_behavior.h>
#include <mission_adapters/mission_adapters.h>
// boost headers
#include <boost/thread.hpp>
@@ -140,6 +141,14 @@ namespace move_base
* @param point_cloud2 The point cloud2 to add.
*/
virtual void addPointCloud2(const std::string &point_cloud2_name, robot_sensor_msgs::PointCloud2 point_cloud2) override;
/**
* @brief Add one coherent depth-camera sample to the navigation system.
* @param topic The logical topic of the combined depth-camera stream.
* @param data Depth image and matching camera intrinsics.
*/
virtual void addDepthCameraData(const std::string &topic,
robot_sensor_msgs::DepthCameraData::ConstPtr data) override;
/**
* @brief Get a static map from the navigation system.
@@ -705,4 +714,4 @@ namespace move_base
} // namespace move_base
#endif // NAV_MOVE_BASE_ACTION_H_
#endif // NAV_MOVE_BASE_ACTION_H_

View File

@@ -49,6 +49,9 @@
<build_depend>robot_cpp</build_depend>
<run_depend>robot_cpp</run_depend>
<build_depend>mission_adapters</build_depend>
<run_depend>mission_adapters</run_depend>
<build_depend>robot_move_base_msgs</build_depend>
<run_depend>robot_move_base_msgs</run_depend>

View File

@@ -613,6 +613,20 @@ void move_base::MoveBase::addPointCloud2(const std::string &point_cloud2_name, r
updateGlobalCostmap<robot_sensor_msgs::PointCloud2>(point_cloud2, robot_costmap_2d::LayerType::VOXEL_LAYER, point_cloud2_name);
}
void move_base::MoveBase::addDepthCameraData(const std::string &topic,
robot_sensor_msgs::DepthCameraData::ConstPtr data)
{
if (!data)
return;
// robot::log_error("DEBUG");
updateLocalCostmap<robot_sensor_msgs::DepthCameraData::ConstPtr>(
data, robot_costmap_2d::LayerType::VOXEL_LAYER, topic);
updateGlobalCostmap<robot_sensor_msgs::DepthCameraData::ConstPtr>(
data, robot_costmap_2d::LayerType::VOXEL_LAYER, topic);
}
robot_sensor_msgs::PointCloud2 move_base::MoveBase::getPointCloud2(const std::string &point_cloud2_name)
{
auto it = point_cloud2s_.find(point_cloud2_name);
@@ -3249,4 +3263,4 @@ robot::move_base_core::BaseNavigation::Ptr move_base::MoveBase::create()
return std::make_shared<move_base::MoveBase>();
}
BOOST_DLL_ALIAS(move_base::MoveBase::create, MoveBase)
BOOST_DLL_ALIAS(move_base::MoveBase::create, MoveBase)