git commit -m "first commit"

This commit is contained in:
2026-05-28 10:29:58 +07:00
commit 167c52aeb6
2048 changed files with 740251 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
# nav_2d_utils Conversions
(note: exact syntax differs from below for conciseness, leaving out `const` and `&`)
## Twist Transformations
| to `nav_2d_msgs` | from `nav_2d_msgs` |
| -- | -- |
| `Twist2D twist3Dto2D(geometry_msgs::Twist)` | `geometry_msgs::Twist twist2Dto3D(Twist2D cmd_vel_2d)`
## Point Transformations
| to `nav_2d_msgs` | from `nav_2d_msgs` |
| -- | -- |
| `Point2D pointToPoint2D(geometry_msgs::Point)` | `geometry_msgs::Point pointToPoint3D(Point2D)`
| `Point2D pointToPoint2D(geometry_msgs::Point32)` | `geometry_msgs::Point32 pointToPoint32(Point2D)`
## Pose Transformations
| to `nav_2d_msgs` | from `nav_2d_msgs` |
| -- | -- |
| `Pose2DStamped poseStampedToPose2D(geometry_msgs::PoseStamped)` | `geometry_msgs::PoseStamped pose2DToPoseStamped(Pose2DStamped)`
||`geometry_msgs::PoseStamped pose2DToPoseStamped(geometry_msgs::Pose2D, std::string, ros::Time)`|
||`geometry_msgs::Pose pose2DToPose(geometry_msgs::Pose2D)`|
| `Pose2DStamped stampedPoseToPose2D(tf::Stamped<tf::Pose>)` | |
## Path Transformations
| to `nav_2d_msgs` | from `nav_2d_msgs` |
| -- | -- |
| `Path2D pathToPath(nav_msgs::Path)` |`nav_msgs::Path pathToPath(Path2D)`
| `Path2D posesToPath2D(std::vector<geometry_msgs::PoseStamped>)` | `nav_msgs::Path poses2DToPath(std::vector<geometry_msgs::Pose2D>, std::string, ros::Time)`
Also, `nav_msgs::Path posesToPath(std::vector<geometry_msgs::PoseStamped>)`
## Polygon Transformations
| to `nav_2d_msgs` | from `nav_2d_msgs` |
| -- | -- |
| `Polygon2D polygon3Dto2D(geometry_msgs::Polygon)` |`geometry_msgs::Polygon polygon2Dto3D(Polygon2D)`
| `Polygon2DStamped polygon3Dto2D(geometry_msgs::PolygonStamped)` | `geometry_msgs::PolygonStamped polygon2Dto3D(Polygon2DStamped)`
## Info Transformations
| to `nav_2d_msgs` | from `nav_2d_msgs` |
| -- | -- |
|`nav_2d_msgs::NavGridInfo toMsg(nav_grid::NavGridInfo)`|`nav_grid::NavGridInfo fromMsg(nav_2d_msgs::NavGridInfo)`|
| to `nav_grid` info | from `nav_grid` info |
| -- | -- |
|`nav_grid::NavGridInfo infoToInfo(nav_msgs::MapMetaData, std::string)` | `nav_msgs::MapMetaData infoToInfo(nav_grid::NavGridInfo)`
| to two dimensional pose | to three dimensional pose |
| -- | -- |
| `Pose2D getOrigin2D(nav_grid::NavGridInfo)` | `geometry_msgs::Pose getOrigin3D(nav_grid::NavGridInfo)`|
## Bounds Transformations
| to `nav_2d_msgs` | from `nav_2d_msgs` |
| -- | -- |
|`nav_2d_msgs::UIntBounds toMsg(nav_core2::UIntBounds)`|`nav_core2::UIntBounds fromMsg(nav_2d_msgs::UIntBounds)`|

View File

@@ -0,0 +1,39 @@
# 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.
```
global_planner_namespaces:
- boring_nav_fn
- wacky_global_planner
boring_nav_fn:
allow_unknown: true
plugin_class: navfn/NavfnROS
wacky_global_planner:
allow_unknown: false
# default value commented out
# plugin_class: global_planner/GlobalPlanner
```
The namespaces are arbitrary strings, and need not reflect the name of the planner. The package and class name for the plugin will be specified by the `plugin_class` parameter. By default, the first namespace will be loaded as the current plugin.
To advertise which plugin is active, we publish the namespace on a latched topic and set a parameter with the same name (`~/current_global_planner`). We can then switch among them with a `SetString` ROS service call, or the `usePlugin` C++ method.
This configuration is all created by creating a plugin mux with the following parameters (parameter names shown for convenience):
```
PluginMux(plugin_package = "nav_core",
plugin_class = "BaseGlobalPlanner",
parameter_name = "global_planner_namespaces",
default_value = "global_planner/GlobalPlanner",
ros_name = "current_global_planner",
switch_service_name = "switch_global_planner");
```
If the parameter is not set or is an empty list, a namespace will be derived from the `default_value` and be loaded as the only plugin available.
```
global_planner_namespaces: []
GlobalPlanner:
allow_unknown: true
```

View File

@@ -0,0 +1,52 @@
# nav_2d_utils Polygons and Footprints
This library represents a replacement for [costmap_2d/footprint.h](https://github.com/ros-planning/navigation/blob/a2837b5a9dc6dd4b4da176fca7d899d6a3722bf8/costmap_2d/include/costmap_2d/footprint.h) and deals with manipulating polygons. Note that implicitly all polygons here are assumed to be [simple polygons](https://en.wikipedia.org/wiki/Simple_polygon) without "holes."
## Polygons and the Parameter Server
There have historically been three primary ways to specify a polygon/footprint on the parameter server. The first is to simply specify a radius which is converted to a hexadecagon, i.e. polygon with sixteen sides. This can be read with
```
nav_2d_msgs::Polygon2D polygonFromRadius(const double radius, const unsigned int num_points = 16);
```
The second two ways involve specifying the points of the polygon individually. This can be done with either a string representing a bracketed array of arrays of doubles, `"[[1.0, 2.2], [3.3, 4.2], ...]"`. This can be read with
```
nav_2d_msgs::Polygon2D polygonFromString(const std::string& polygon_string);
```
Alternatively, with ROS, you can read the points directly from the parameter server in the form of an `XmlRpcValue`, which should be an array of arrays of doubles, which is read with
```
nav_2d_msgs::Polygon2D polygonFromXMLRPC(XmlRpc::XmlRpcValue& polygon_xmlrpc);
```
If the `XmlRpcValue` is a string, it will call the `polygonFromString` method.
The above are the traditional methods that were supported by the original `costmap_2d` code. However, we add a fourth method that requires two parallel arrays of x and y coordinates.
```
nav_2d_msgs::Polygon2D polygonFromParallelArrays(const std::vector<double>& xs, const std::vector<double>& ys);
```
All of the above methods (except the radius one) can be loaded as appropriate from the parameter server with
```
nav_2d_msgs::Polygon2D polygonFromParams(const ros::NodeHandle& nh, const std::string parameter_name,
bool search = true);
```
to include the radius, use the logic in `footprint.h` which either uses "footprint" or "robot_radius"
```
nav_2d_msgs::Polygon2D footprintFromParams(ros::NodeHandle& nh, bool write = true);
```
Polygons can be written to parameters with
```
void polygontoParams(const nav_2d_msgs::Polygon2D& polygon, const ros::NodeHandle& nh, const std::string parameter_name,
bool array_of_arrays = true);
```
## Polygon Operations
There are also a handful of methods for examining/manipulating polygons
* `equals` - check if two polygons are equal
* `movePolygonToPose` - translate and rotate a polygon
* `isInside` - check if a point is inside a polygon
* `calculateMinAndMaxDistances` - Calculate the minimum and maximum distance from the origin of a polygon
* `triangulate` - Decompose a polygon into a set of non-overlapping triangles using an open source implementation of the [earcut algorithm](https://github.com/mapbox/earcut.hpp)