update ros

This commit is contained in:
2026-01-07 09:28:31 +07:00
parent 11b7c4a20d
commit ca9e100bd9
115 changed files with 1934 additions and 987 deletions

View File

@@ -41,7 +41,7 @@ robot::PluginLoaderHelper loader;
std::string lib_path = loader.findLibraryPath("CustomPlanner");
if (!lib_path.empty()) {
// Sử dụng với boost::dll::import_alias
auto planner_loader = boost::dll::import_alias<nav_core::BaseGlobalPlanner::Ptr()>(
auto planner_loader = boost::dll::import_alias<robot_nav_core2::BaseGlobalPlanner::Ptr()>(
lib_path, "CustomPlanner", boost::dll::load_mode::append_decorations);
planner_ = planner_loader();
}
@@ -53,14 +53,14 @@ Thay vì hardcode đường dẫn:
```cpp
// CŨ (hardcode):
std::string path_file_so = "/home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/build/libcustom_planner.so";
std::string path_file_so = "/home/robotics/AGV/Diff_Wheel_Prj/pnkx_robot_nav_core2/build/libcustom_planner.so";
// MỚI (từ config):
robot::PluginLoaderHelper loader;
std::string path_file_so = loader.findLibraryPath(global_planner);
if (path_file_so.empty()) {
// Fallback nếu không tìm thấy
path_file_so = "/home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/build/libcustom_planner.so";
path_file_so = "/home/robotics/AGV/Diff_Wheel_Prj/pnkx_robot_nav_core2/build/libcustom_planner.so";
}
```
@@ -97,7 +97,7 @@ plugin_libraries:
library_path: "/path/to/libpnkx_local_planner.so"
search_paths:
- "/home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/build"
- "/home/robotics/AGV/Diff_Wheel_Prj/pnkx_robot_nav_core2/build"
- "/path/to/other/libraries"
```
@@ -126,7 +126,7 @@ Helper sẽ tìm library theo thứ tự:
1. Đường dẫn trực tiếp (nếu absolute)
2. `$PNKX_NAV_CORE_CONFIG_DIR/boost_dll_plugins.yaml`
3. `$PNKX_NAV_CORE_DIR/config/boost_dll_plugins.yaml`
4. `/home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/config/boost_dll_plugins.yaml`
4. `/home/robotics/AGV/Diff_Wheel_Prj/pnkx_robot_nav_core2/config/boost_dll_plugins.yaml`
5. `../config/boost_dll_plugins.yaml` (relative paths)
- Symbol name có thể có namespace (ví dụ: `custom_planner::CustomPlanner`), helper sẽ tự động thử tìm cả tên đầy đủ và tên ngắn (`CustomPlanner`).

View File

@@ -877,7 +877,7 @@ namespace robot
// Try hardcoded fallback paths
std::vector<std::string> possible_paths = {
"/home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/config",
"/home/robotics/AGV/Diff_Wheel_Prj/pnkx_robot_nav_core2/config",
"../config",
"../../config",
"./config"};

View File

@@ -36,7 +36,7 @@ PluginLoaderHelper::PluginLoaderHelper(robot::NodeHandle nh, const std::string&
// Thêm các subdirectories thường dùng
search_paths_.push_back(build_dir + "/src/Algorithms/Packages/global_planners");
search_paths_.push_back(build_dir + "/src/Algorithms/Packages/local_planners");
search_paths_.push_back(build_dir + "/src/Navigations/Cores/nav_core_adapter");
search_paths_.push_back(build_dir + "/src/Navigations/Cores/robot_nav_core2_adapter");
search_paths_.push_back(build_dir + "/src/Libraries/robot_costmap_2d");
}
}
@@ -319,7 +319,7 @@ std::string PluginLoaderHelper::getBuildDirectory()
}
// Method 6: Hardcoded fallback
std::string fallback = "/home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/build";
std::string fallback = "/home/robotics/AGV/Diff_Wheel_Prj/pnkx_robot_nav_core2/build";
if (std::filesystem::exists(fallback)) {
return fallback;
}

View File

@@ -61,8 +61,8 @@ target_link_libraries(robot_nav_2d_msgs
# Add include directories from dependencies explicitly for Catkin build
if(BUILDING_WITH_CATKIN)
# Use relative paths from current source directory
# From robot_nav_2d_msgs (pnkx_nav_core/src/Libraries/robot_nav_2d_msgs)
# to robot_std_msgs (pnkx_nav_core/src/Libraries/common_msgs/robot_std_msgs) is ../common_msgs/robot_std_msgs
# From robot_nav_2d_msgs (pnkx_robot_nav_core2/src/Libraries/robot_nav_2d_msgs)
# to robot_std_msgs (pnkx_robot_nav_core2/src/Libraries/common_msgs/robot_std_msgs) is ../common_msgs/robot_std_msgs
get_filename_component(ROBOT_STD_MSGS_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../common_msgs/robot_std_msgs/include" ABSOLUTE)
get_filename_component(GEOMETRY_MSGS_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../common_msgs/robot_geometry_msgs/include" ABSOLUTE)
target_include_directories(robot_nav_2d_msgs INTERFACE

View File

@@ -19,8 +19,4 @@
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
<build_depend>libconsole-bridge-dev</build_depend>
<run_depend>libconsole-bridge-dev</run_depend>
</package>

View File

@@ -27,11 +27,20 @@ else()
endif()
if(BUILDING_WITH_CATKIN)
find_package(catkin REQUIRED COMPONENTS robot_xmlrpcpp)
find_package(catkin REQUIRED COMPONENTS
robot_nav_2d_msgs
robot_geometry_msgs
robot_nav_msgs
nav_grid
robot_nav_core2
tf3
robot_tf3_geometry_msgs
robot_cpp
)
catkin_package(
INCLUDE_DIRS include
LIBRARIES conversions path_ops polygons bounds tf_help robot_nav_2d_utils
LIBRARIES ${PROJECT_NAME}_conversions ${PROJECT_NAME}_path_ops ${PROJECT_NAME}_polygons ${PROJECT_NAME}_bounds ${PROJECT_NAME}_tf_help ${PROJECT_NAME}
# CATKIN_DEPENDS không cần vì dependencies không phải Catkin packages
DEPENDS console_bridge Boost
)
@@ -42,19 +51,19 @@ find_package(console_bridge REQUIRED)
find_package(Boost REQUIRED COMPONENTS system thread)
# Libraries
add_library(conversions src/conversions.cpp)
target_include_directories(conversions
add_library(${PROJECT_NAME}_conversions src/conversions.cpp)
target_include_directories(${PROJECT_NAME}_conversions
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(conversions
target_link_libraries(${PROJECT_NAME}_conversions
PUBLIC
robot_nav_2d_msgs
robot_geometry_msgs
robot_nav_msgs
nav_grid
nav_core2
robot_nav_core2
robot_cpp
PRIVATE
console_bridge::console_bridge
@@ -62,121 +71,123 @@ target_link_libraries(conversions
Boost::thread
)
set_target_properties(conversions PROPERTIES
set_target_properties(${PROJECT_NAME}_conversions PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
BUILD_RPATH "${CMAKE_BINARY_DIR}"
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
)
add_library(path_ops src/path_ops.cpp)
target_include_directories(path_ops
add_library(${PROJECT_NAME}_path_ops src/path_ops.cpp)
target_include_directories(${PROJECT_NAME}_path_ops
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(path_ops
target_link_libraries(${PROJECT_NAME}_path_ops
PUBLIC
robot_nav_2d_msgs
robot_geometry_msgs
robot_cpp
)
set_target_properties(path_ops PROPERTIES
set_target_properties(${PROJECT_NAME}_path_ops PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
BUILD_RPATH "${CMAKE_BINARY_DIR}"
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
)
add_library(polygons src/polygons.cpp src/footprint.cpp)
target_include_directories(polygons
add_library(${PROJECT_NAME}_polygons src/polygons.cpp src/footprint.cpp)
target_include_directories(${PROJECT_NAME}_polygons
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
if(robot_xmlrpcpp_FOUND)
target_include_directories(polygons PRIVATE ${robot_xmlrpcpp_INCLUDE_DIRS})
target_link_libraries(polygons
target_include_directories(${PROJECT_NAME}_polygons PRIVATE ${robot_xmlrpcpp_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME}_polygons
PUBLIC robot_nav_2d_msgs robot_geometry_msgs robot_cpp
PRIVATE ${robot_xmlrpcpp_LIBRARIES})
elseif(XmlRpcCpp_FOUND)
target_include_directories(polygons PRIVATE ${XmlRpcCpp_INCLUDE_DIRS})
target_link_libraries(polygons
target_include_directories(${PROJECT_NAME}_polygons PRIVATE ${XmlRpcCpp_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME}_polygons
PUBLIC robot_nav_2d_msgs robot_geometry_msgs robot_cpp
PRIVATE ${XmlRpcCpp_LIBRARIES})
else()
target_include_directories(polygons PRIVATE ${robot_xmlrpcpp_INCLUDE_DIRS})
target_link_libraries(polygons
target_include_directories(${PROJECT_NAME}_polygons PRIVATE ${robot_xmlrpcpp_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME}_polygons
PUBLIC robot_nav_2d_msgs robot_geometry_msgs robot_cpp
PRIVATE ${robot_xmlrpcpp_LIBRARIES})
endif()
set_target_properties(polygons PROPERTIES
set_target_properties(${PROJECT_NAME}_polygons PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
BUILD_RPATH "${CMAKE_BINARY_DIR}"
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
)
add_library(bounds src/bounds.cpp)
target_include_directories(bounds
add_library(${PROJECT_NAME}_bounds src/bounds.cpp)
target_include_directories(${PROJECT_NAME}_bounds
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(bounds
target_link_libraries(${PROJECT_NAME}_bounds
PUBLIC
nav_grid
nav_core2
robot_nav_core2
robot_cpp
)
set_target_properties(bounds PROPERTIES
set_target_properties(${PROJECT_NAME}_bounds PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
BUILD_RPATH "${CMAKE_BINARY_DIR}"
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
)
add_library(tf_help src/tf_help.cpp)
target_include_directories(tf_help
add_library(${PROJECT_NAME}_tf_help src/tf_help.cpp)
target_include_directories(${PROJECT_NAME}_tf_help
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(tf_help
PUBLIC
robot_nav_2d_msgs
robot_geometry_msgs
nav_core2
tf3
robot_cpp
target_link_libraries(${PROJECT_NAME}_tf_help
PUBLIC
robot_nav_2d_msgs
robot_geometry_msgs
robot_nav_msgs
robot_nav_core2
tf3
robot_tf3_geometry_msgs
robot_cpp
)
set_target_properties(tf_help PROPERTIES
set_target_properties(${PROJECT_NAME}_tf_help PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
BUILD_RPATH "${CMAKE_BINARY_DIR}"
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
)
# Create an INTERFACE library that represents all robot_nav_2d_utils libraries
add_library(robot_nav_2d_utils INTERFACE)
target_include_directories(robot_nav_2d_utils
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME}
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(robot_nav_2d_utils
target_link_libraries(${PROJECT_NAME}
INTERFACE
conversions
path_ops
polygons
bounds
tf_help
${PROJECT_NAME}_conversions
${PROJECT_NAME}_path_ops
${PROJECT_NAME}_polygons
${PROJECT_NAME}_bounds
${PROJECT_NAME}_tf_help
robot_cpp
)
# Install header files
if(NOT BUILDING_WITH_CATKIN)
install(DIRECTORY include/robot_nav_2d_utils
install(DIRECTORY include/${PROJECT_NAME}
DESTINATION include
FILES_MATCHING PATTERN "*.h")
@@ -187,23 +198,23 @@ if(NOT BUILDING_WITH_CATKIN)
endif()
# Install targets
install(TARGETS robot_nav_2d_utils conversions path_ops polygons bounds tf_help
EXPORT robot_nav_2d_utils-targets
install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_conversions ${PROJECT_NAME}_path_ops ${PROJECT_NAME}_polygons ${PROJECT_NAME}_bounds ${PROJECT_NAME}_tf_help
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
# Export targets
install(EXPORT robot_nav_2d_utils-targets
FILE robot_nav_2d_utils-targets.cmake
NAMESPACE robot_nav_2d_utils::
DESTINATION lib/cmake/robot_nav_2d_utils)
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION lib/cmake/${PROJECT_NAME})
# Print configuration info
message(STATUS "=================================")
message(STATUS "Project: ${PROJECT_NAME}")
message(STATUS "Version: ${PROJECT_VERSION}")
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
message(STATUS "Libraries: conversions, path_ops, polygons, bounds, tf_help")
message(STATUS "Dependencies: robot_nav_2d_msgs, robot_geometry_msgs, robot_nav_msgs, nav_grid, nav_core2, tf3, console_bridge, Boost")
message(STATUS "Libraries: ${PROJECT_NAME}_conversions, ${PROJECT_NAME}_path_ops, ${PROJECT_NAME}_polygons, ${PROJECT_NAME}_bounds, ${PROJECT_NAME}_tf_help")
message(STATUS "Dependencies: robot_nav_2d_msgs, robot_geometry_msgs, robot_nav_msgs, nav_grid, robot_nav_core2, tf3, console_bridge, Boost")
message(STATUS "=================================")

View File

@@ -1,6 +1,6 @@
# robot_nav_2d_utils
A handful of useful utility functions for nav_core2 packages.
* Bounds - Utilities for `nav_core2::Bounds` objects interacting with other messages/types and for dividing a `UIntBounds` into multiple smaller bounds.
A handful of useful utility functions for robot_nav_core2 packages.
* Bounds - Utilities for `robot_nav_core2::Bounds` objects interacting with other messages/types and for dividing a `UIntBounds` into multiple smaller bounds.
* [Conversions](doc/Conversions.md) - Tools for converting between `robot_nav_2d_msgs` and other types.
* OdomSubscriber - subscribes to the standard `robot_nav_msgs::Odometry` message and provides access to the velocity component as a `robot_nav_2d_msgs::Twist`
* Parameters - a couple ROS parameter patterns

View File

@@ -51,4 +51,4 @@ Also, `robot_nav_msgs::Path posesToPath(std::vector<robot_geometry_msgs::PoseSta
## Bounds Transformations
| to `robot_nav_2d_msgs` | from `robot_nav_2d_msgs` |
| -- | -- |
|`robot_nav_2d_msgs::UIntBounds toMsg(nav_core2::UIntBounds)`|`nav_core2::UIntBounds fromMsg(robot_nav_2d_msgs::UIntBounds)`|
|`robot_nav_2d_msgs::UIntBounds toMsg(robot_nav_core2::UIntBounds)`|`robot_nav_core2::UIntBounds fromMsg(robot_nav_2d_msgs::UIntBounds)`|

View File

@@ -2,7 +2,7 @@
# Plugin Mux
`PluginMux` is an organizer for switching between multiple different plugins of the same type. It may be easiest to see how it operates through an example. Let's say we have multiple global planners we would like to use at different times, with only one being active at a given time.
This means we have multiple `pluginlib` plugins to load that extend the `BaseGlobalPlanner` interface from the `nav_core` package. We define multiple namespaces in the `global_planner_namespaces` and load each of them. Here's an example parameter config.
This means we have multiple `pluginlib` plugins to load that extend the `BaseGlobalPlanner` interface from the `robot_nav_core2` package. We define multiple namespaces in the `global_planner_namespaces` and load each of them. Here's an example parameter config.
```
global_planner_namespaces:
@@ -23,7 +23,7 @@ To advertise which plugin is active, we publish the namespace on a latched topic
This configuration is all created by creating a plugin mux with the following parameters (parameter names shown for convenience):
```
PluginMux(plugin_package = "nav_core",
PluginMux(plugin_package = "robot_nav_core2",
plugin_class = "BaseGlobalPlanner",
parameter_name = "global_planner_namespaces",
default_value = "global_planner/GlobalPlanner",

View File

@@ -36,7 +36,7 @@
#define ROBOT_NAV_2D_UTILS_BOUNDS_H
#include <nav_grid/nav_grid_info.h>
#include <nav_core2/bounds.h>
#include <robot_nav_core2/bounds.h>
#include <vector>
/**
@@ -50,14 +50,14 @@ namespace robot_nav_2d_utils
* @param info Info for the NavGrid
* @return bounds covering the entire NavGrid
*/
nav_core2::Bounds getFullBounds(const nav_grid::NavGridInfo &info);
robot_nav_core2::Bounds getFullBounds(const nav_grid::NavGridInfo &info);
/**
* @brief return an integral bounds that covers the entire NavGrid
* @param info Info for the NavGrid
* @return bounds covering the entire NavGrid
*/
nav_core2::UIntBounds getFullUIntBounds(const nav_grid::NavGridInfo &info);
robot_nav_core2::UIntBounds getFullUIntBounds(const nav_grid::NavGridInfo &info);
/**
* @brief Translate real-valued bounds to uint coordinates based on nav_grid info
@@ -65,7 +65,7 @@ namespace robot_nav_2d_utils
* @param bounds floating point bounds object
* @returns corresponding UIntBounds for parameter
*/
nav_core2::UIntBounds translateBounds(const nav_grid::NavGridInfo &info, const nav_core2::Bounds &bounds);
robot_nav_core2::UIntBounds translateBounds(const nav_grid::NavGridInfo &info, const robot_nav_core2::Bounds &bounds);
/**
* @brief Translate uint bounds to real-valued coordinates based on nav_grid info
@@ -73,7 +73,7 @@ namespace robot_nav_2d_utils
* @param bounds UIntBounds object
* @returns corresponding floating point bounds for parameter
*/
nav_core2::Bounds translateBounds(const nav_grid::NavGridInfo &info, const nav_core2::UIntBounds &bounds);
robot_nav_core2::Bounds translateBounds(const nav_grid::NavGridInfo &info, const robot_nav_core2::UIntBounds &bounds);
/**
* @brief divide the given bounds up into sub-bounds of roughly equal size
@@ -83,7 +83,7 @@ namespace robot_nav_2d_utils
* @return vector of a maximum of n_cols*n_rows nonempty bounds
* @throws std::invalid_argument when n_cols or n_rows is zero
*/
std::vector<nav_core2::UIntBounds> divideBounds(const nav_core2::UIntBounds &original_bounds,
std::vector<robot_nav_core2::UIntBounds> divideBounds(const robot_nav_core2::UIntBounds &original_bounds,
unsigned int n_cols, unsigned int n_rows);
} // namespace robot_nav_2d_utils

View File

@@ -50,7 +50,7 @@
#include <robot_nav_msgs/MapMetaData.h>
#include <robot_nav_msgs/Path.h>
#include <nav_grid/nav_grid.h>
#include <nav_core2/bounds.h>
#include <robot_nav_core2/bounds.h>
// #include <tf/tf.h>
#include <vector>
#include <string>
@@ -98,8 +98,8 @@ namespace robot_nav_2d_utils
robot_nav_msgs::MapMetaData infoToInfo(const nav_grid::NavGridInfo &info);
// Bounds Transformations
robot_nav_2d_msgs::UIntBounds toMsg(const nav_core2::UIntBounds &bounds);
nav_core2::UIntBounds fromMsg(const robot_nav_2d_msgs::UIntBounds &msg);
robot_nav_2d_msgs::UIntBounds toMsg(const robot_nav_core2::UIntBounds &bounds);
robot_nav_core2::UIntBounds fromMsg(const robot_nav_2d_msgs::UIntBounds &msg);
} // namespace robot_nav_2d_utils

View File

@@ -35,7 +35,7 @@
#ifndef ROBOT_NAV_2D_UTILS_TF_HELP_H
#define ROBOT_NAV_2D_UTILS_TF_HELP_H
#include <nav_core2/common.h>
#include <robot_nav_core2/common.h>
#include <robot_geometry_msgs/PoseStamped.h>
#include <robot_nav_2d_msgs/Pose2DStamped.h>
#include <string>

View File

@@ -19,7 +19,17 @@
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
<build_depend>robot_xmlrpcpp</build_depend>
<run_depend>robot_xmlrpcpp</run_depend>
<build_depend>robot_nav_2d_msgs</build_depend>
<build_depend>robot_geometry_msgs</build_depend>
<build_depend>robot_nav_msgs</build_depend>
<build_depend>nav_grid</build_depend>
<build_depend>robot_nav_core2</build_depend>
<build_depend>robot_cpp</build_depend>
<run_depend>robot_nav_2d_msgs</run_depend>
<run_depend>robot_geometry_msgs</run_depend>
<run_depend>robot_nav_msgs</run_depend>
<run_depend>nav_grid</run_depend>
<run_depend>robot_nav_core2</run_depend>
<run_depend>robot_cpp</run_depend>
</package>

View File

@@ -40,35 +40,35 @@
namespace robot_nav_2d_utils
{
nav_core2::Bounds getFullBounds(const nav_grid::NavGridInfo &info)
robot_nav_core2::Bounds getFullBounds(const nav_grid::NavGridInfo &info)
{
return nav_core2::Bounds(info.origin_x, info.origin_y,
return robot_nav_core2::Bounds(info.origin_x, info.origin_y,
info.origin_x + info.resolution * info.width, info.origin_y + info.resolution * info.height);
}
nav_core2::UIntBounds getFullUIntBounds(const nav_grid::NavGridInfo &info)
robot_nav_core2::UIntBounds getFullUIntBounds(const nav_grid::NavGridInfo &info)
{
// bounds are inclusive, so we subtract one
return nav_core2::UIntBounds(0, 0, info.width - 1, info.height - 1);
return robot_nav_core2::UIntBounds(0, 0, info.width - 1, info.height - 1);
}
nav_core2::UIntBounds translateBounds(const nav_grid::NavGridInfo &info, const nav_core2::Bounds &bounds)
robot_nav_core2::UIntBounds translateBounds(const nav_grid::NavGridInfo &info, const robot_nav_core2::Bounds &bounds)
{
unsigned int g_min_x, g_min_y, g_max_x, g_max_y;
worldToGridBounded(info, bounds.getMinX(), bounds.getMinY(), g_min_x, g_min_y);
worldToGridBounded(info, bounds.getMaxX(), bounds.getMaxY(), g_max_x, g_max_y);
return nav_core2::UIntBounds(g_min_x, g_min_y, g_max_x, g_max_y);
return robot_nav_core2::UIntBounds(g_min_x, g_min_y, g_max_x, g_max_y);
}
nav_core2::Bounds translateBounds(const nav_grid::NavGridInfo &info, const nav_core2::UIntBounds &bounds)
robot_nav_core2::Bounds translateBounds(const nav_grid::NavGridInfo &info, const robot_nav_core2::UIntBounds &bounds)
{
double min_x, min_y, max_x, max_y;
gridToWorld(info, bounds.getMinX(), bounds.getMinY(), min_x, min_y);
gridToWorld(info, bounds.getMaxX(), bounds.getMaxY(), max_x, max_y);
return nav_core2::Bounds(min_x, min_y, max_x, max_y);
return robot_nav_core2::Bounds(min_x, min_y, max_x, max_y);
}
std::vector<nav_core2::UIntBounds> divideBounds(const nav_core2::UIntBounds &original_bounds,
std::vector<robot_nav_core2::UIntBounds> divideBounds(const robot_nav_core2::UIntBounds &original_bounds,
unsigned int n_cols, unsigned int n_rows)
{
if (n_cols * n_rows == 0)
@@ -81,7 +81,7 @@ namespace robot_nav_2d_utils
unsigned int small_width = static_cast<unsigned int>(ceil(static_cast<double>(full_width) / n_cols)),
small_height = static_cast<unsigned int>(ceil(static_cast<double>(full_height) / n_rows));
std::vector<nav_core2::UIntBounds> divided;
std::vector<robot_nav_core2::UIntBounds> divided;
for (unsigned int row = 0; row < n_rows; row++)
{
@@ -92,7 +92,7 @@ namespace robot_nav_2d_utils
{
unsigned int min_x = original_bounds.getMinX() + small_width * col;
unsigned int max_x = std::min(min_x + small_width - 1, original_bounds.getMaxX());
nav_core2::UIntBounds sub(min_x, min_y, max_x, max_y);
robot_nav_core2::UIntBounds sub(min_x, min_y, max_x, max_y);
if (!sub.isEmpty())
divided.push_back(sub);
}

View File

@@ -126,17 +126,17 @@ namespace robot_nav_2d_utils
return pose;
}
// robot_geometry_msgs::PoseStamped pose2DToPoseStamped(const robot_geometry_msgs::Pose2D& pose2d,
// const std::string& frame, const robot::Time& stamp)
// {
// robot_geometry_msgs::PoseStamped pose;
// pose.header.frame_id = frame;
// pose.header.stamp = stamp;
// pose.pose.position.x = pose2d.x;
// pose.pose.position.y = pose2d.y;
// // pose.pose.orientation = tf::createQuaternionMsgFromYaw(pose2d.theta);
// return pose;
// }
robot_geometry_msgs::PoseStamped pose2DToPoseStamped(const robot_geometry_msgs::Pose2D& pose2d,
const std::string& frame, const robot::Time& stamp)
{
robot_geometry_msgs::PoseStamped pose;
pose.header.frame_id = frame;
pose.header.stamp = stamp;
pose.pose.position.x = pose2d.x;
pose.pose.position.y = pose2d.y;
// pose.pose.orientation = tf::createQuaternionMsgFromYaw(pose2d.theta);
return pose;
}
robot_nav_2d_msgs::Path2D pathToPath(const robot_nav_msgs::Path &path)
{
@@ -186,19 +186,19 @@ namespace robot_nav_2d_utils
return path;
}
// robot_nav_msgs::Path poses2DToPath(const std::vector<robot_geometry_msgs::Pose2D>& poses,
// const std::string& frame, const robot::Time& stamp)
// {
// robot_nav_msgs::Path path;
// path.poses.resize(poses.size());
// path.header.frame_id = frame;
// path.header.stamp = stamp;
// for (unsigned int i = 0; i < poses.size(); i++)
// {
// path.poses[i] = pose2DToPoseStamped(poses[i], frame, stamp);
// }
// return path;
// }
robot_nav_msgs::Path poses2DToPath(const std::vector<robot_geometry_msgs::Pose2D>& poses,
const std::string& frame, const robot::Time& stamp)
{
robot_nav_msgs::Path path;
path.poses.resize(poses.size());
path.header.frame_id = frame;
path.header.stamp = stamp;
for (unsigned int i = 0; i < poses.size(); i++)
{
path.poses[i] = pose2DToPoseStamped(poses[i], frame, stamp);
}
return path;
}
robot_nav_msgs::Path pathToPath(const robot_nav_2d_msgs::Path2D &path2d)
{
@@ -318,7 +318,7 @@ namespace robot_nav_2d_utils
return metadata;
}
robot_nav_2d_msgs::UIntBounds toMsg(const nav_core2::UIntBounds &bounds)
robot_nav_2d_msgs::UIntBounds toMsg(const robot_nav_core2::UIntBounds &bounds)
{
robot_nav_2d_msgs::UIntBounds msg;
msg.min_x = bounds.getMinX();
@@ -328,9 +328,9 @@ namespace robot_nav_2d_utils
return msg;
}
nav_core2::UIntBounds fromMsg(const robot_nav_2d_msgs::UIntBounds &msg)
robot_nav_core2::UIntBounds fromMsg(const robot_nav_2d_msgs::UIntBounds &msg)
{
return nav_core2::UIntBounds(msg.min_x, msg.min_y, msg.max_x, msg.max_y);
return robot_nav_core2::UIntBounds(msg.min_x, msg.min_y, msg.max_x, msg.max_y);
}
} // namespace robot_nav_2d_utils

View File

@@ -37,7 +37,7 @@
#include <vector>
using robot_nav_2d_utils::divideBounds;
using nav_core2::UIntBounds;
using robot_nav_core2::UIntBounds;
/**
* @brief Count the values in a grid.

View File

@@ -19,8 +19,5 @@
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
<build_depend>libconsole-bridge-dev</build_depend>
<run_depend>libconsole-bridge-dev</run_depend>
</package>