feat(costmap_2d): background reference graph, shared keys under root:
- ReferenceGraph / ReferenceGraphWorker: Voronoi ridges and one-way lanes are computed on a low-priority thread when the map changes (reference_graph_* keys, off with rolling_window), with unit tests. - Shared costmap keys can live in a root: map or flat at the top of the YAML; costmap_common_root_test covers both layouts. - Static and directional layers report map changes to the layered costmap.
This commit is contained in:
@@ -39,9 +39,13 @@
|
||||
#define ROBOT_COSTMAP_2D_LAYERED_COSTMAP_H_
|
||||
|
||||
#include <robot_costmap_2d/direction_field.h>
|
||||
#include <robot_costmap_2d/reference_graph.h>
|
||||
#include <robot_costmap_2d/cost_values.h>
|
||||
#include <robot_costmap_2d/layer.h>
|
||||
#include <robot_costmap_2d/costmap_2d.h>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
@@ -50,6 +54,8 @@
|
||||
namespace robot_costmap_2d
|
||||
{
|
||||
class Layer;
|
||||
class ReferenceGraphWorker;
|
||||
enum class LayerType; // layer.h includes this header before it defines the enum.
|
||||
|
||||
/**
|
||||
* @class LayeredCostmap
|
||||
@@ -103,6 +109,23 @@ public:
|
||||
/** Consistent snapshot; plugin list must be fixed before concurrent reads. */
|
||||
DirectionFieldSnapshot getDirectionFieldSnapshot() const;
|
||||
|
||||
/** @brief Start computing the coarse graph in the background. Call once, after the plugins are loaded.
|
||||
* The first computation starts by itself, so a map that arrived earlier still counts.
|
||||
* @return False, with an error logged, on a rolling costmap, bad parameters or a second call. */
|
||||
bool enableReferenceGraph(const ReferenceGraphParams& params);
|
||||
|
||||
/** @brief Consistent snapshot, safe to retain on a planner thread. Never takes the master mutex. */
|
||||
ReferenceGraphSnapshot getReferenceGraphSnapshot() const;
|
||||
|
||||
/** @brief Counts map changes per layer type, e.g. PREFERRED_LAYER, so a planner knows when to rebuild what it derives. */
|
||||
uint64_t getStaticMapRevision(LayerType type) const;
|
||||
|
||||
/** @brief Called by the StaticLayer family under the master mutex. Only STATIC_LAYER reruns steps 1 and 2. */
|
||||
void notifyStaticMapChanged(LayerType type);
|
||||
|
||||
/** @brief Called by DirectionalLayer whenever it publishes. Reruns step 2 only. */
|
||||
void notifyDirectionFieldChanged();
|
||||
|
||||
Costmap2D* getCostmap()
|
||||
{
|
||||
return &costmap_;
|
||||
@@ -218,6 +241,10 @@ private:
|
||||
std::uint64_t window_cells_sum_ = 0;
|
||||
std::uint64_t window_cells_max_ = 0;
|
||||
std::uint64_t performance_empty_cycles_ = 0;
|
||||
|
||||
static constexpr std::size_t kMaxLayerTypes = 16; ///< Checked against LayerType in layered_costmap.cpp.
|
||||
std::array<std::atomic<std::uint64_t>, kMaxLayerTypes> static_map_revisions_{};
|
||||
std::unique_ptr<ReferenceGraphWorker> reference_graph_worker_; ///< Null when reference_graph_enabled is false: no thread at all.
|
||||
};
|
||||
|
||||
} // namespace robot_costmap_2d
|
||||
|
||||
Reference in New Issue
Block a user