AStarPlanner.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <optional>
5#include <vector>
6
7#include <VirtualRobot/VirtualRobot.h>
8
12
13#include "Node.h"
14
16{
17
18 class Grid
19 {
20 public:
21 Grid(int rows, int cols, int orientations, const Costmap3D& costmap, float clearance);
22 void clear();
23 Node& getNode(int row, int col, int orientation);
24 static bool fulfillsConstraints(const Node& n, const Costmap3D& costmap, float clearance = 0.0f);
25
26 private:
27 void initialize(int rows, int cols, int orientations, const Costmap3D& costmap);
28 std::unique_ptr<Node[]> data_ = nullptr;
29 int rows;
30 int cols;
31 int orientations;
32 float clearance;
33 };
34
35 /**
36 * The A* planner (3D version including orientation dimension)
37 */
39 {
40 public:
41 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42
44
46
47 std::vector<core::Pose2D> plan(const core::Pose2D& start,
48 const core::Pose2D& goal) /* override */;
49
50 /// Number of nodes expanded during the last `plan()` call. Reported by the offline
51 /// planner evaluation; not used by the navigation stack itself.
52 std::size_t
53 lastExpandedNodes() const noexcept
54 {
55 return expandedNodes;
56 }
57
58 private:
59 float heuristic(const Node& n1, const Node& n2);
60 Node& closestNode(const core::Pose2D& pose);
61
62 Costs costs(const Node& n1, const Node& n2) const;
63
64 float computeObstacleDistance(const Eigen::Vector2f& pos,
65 VirtualRobot::RobotPtr& robot) const;
66
67 private:
68 const Costmap3D costmap3d;
69
70 std::optional<Grid> grid;
71
73
74 std::size_t expandedNodes{0};
75 };
76} // namespace armarx::navigation::algorithms::orientation_aware
AStarPlanner(const Costmap3D &costmap, io::AStarWithOrientationParams params)
std::size_t lastExpandedNodes() const noexcept
Number of nodes expanded during the last plan() call.
std::vector< core::Pose2D > plan(const core::Pose2D &start, const core::Pose2D &goal)
Grid(int rows, int cols, int orientations, const Costmap3D &costmap, float clearance)
static bool fulfillsConstraints(const Node &n, const Costmap3D &costmap, float clearance=0.0f)
Node & getNode(int row, int col, int orientation)
A Node can store data to all valid neighbors (successors) and a precessor.
Definition Node.h:55
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
Eigen::Isometry2f Pose2D
Definition basic_types.h:34