7#include <Eigen/Geometry>
9#include <range/v3/algorithm/transform.hpp>
10#include <range/v3/range/conversion.hpp>
11#include <range/v3/view/transform.hpp>
13#include <VirtualRobot/Nodes/RobotNode.h>
14#include <VirtualRobot/Robot.h>
15#include <VirtualRobot/XML/RobotIO.h>
21#include <ArmarXCore/interface/serialization/Eigen/Eigen_fdi.h>
32#include <armarx/navigation/core/aron/Trajectory.aron.generated.h>
36#include <armarx/navigation/global_planning/aron/AStarWithOrientationParams.aron.generated.h>
53 arondto::AStarWithOrientationParams dto;
66 arondto::AStarWithOrientationParams dto;
89 impl(params, ctx.staticScene->orientationAwareCostmap.value(), ctx.robot)
93 std::optional<GlobalPlannerResult>
97 return plan(start, goal);
100 std::optional<GlobalPlannerResult>
103 if (
scene.staticScene.has_value() &&
scene.staticScene->orientationAwareCostmap.has_value())
105 impl.updateCostmap(
scene.staticScene->orientationAwareCostmap.value());
107 return impl.plan(startRobotRoot, goalRobotRoot);
112 const std::string& vizLayerNamePrefix)
114 impl.visualizeDebugInfo(vizClient, vizLayerNamePrefix);
122 const std::optional<navigation::algorithms::orientation_aware::Costmap3D>&
costmap,
130 const std::optional<navigation::algorithms::orientation_aware::Costmap3D>&
costmap)
134 this->costmap.emplace(
costmap.value());
138 this->costmap.reset();
142 std::optional<GlobalPlannerResult>
147 <<
"AStarWithOrientation cannot be executed because there is no 3D costmap available";
148 const auto aStarParams =
153 const Eigen::Isometry3f root_T_used_root =
157 const core::Pose start = startRobotRoot * root_T_used_root;
158 const core::Pose goal = goalRobotRoot * root_T_used_root;
164 ARMARX_WARNING <<
"Could not calculate a path with orientation_aware A*";
168 std::vector<core::GlobalTrajectoryPoint>
trajectory;
170 std::vector<core::GlobalTrajectoryPoint> trajBeforeTransform;
171 trajBeforeTransform.reserve(
plan.size() + 2);
173 const Eigen::Isometry3f root_used_T_root = root_T_used_root.inverse();
175 trajectory.push_back({.waypoint = {start * root_used_T_root}, .velocity = 300.F});
176 trajBeforeTransform.push_back({.waypoint = {start}, .velocity = 300.F});
178 for (std::size_t i = 1; i <
plan.size(); ++i)
180 const auto& pose2d =
plan[i];
183 .waypoint = {
conv::to3D(pose2d) * root_used_T_root},
193 trajBeforeTransform.back().velocity = 0;
205 const auto optimizationResult = smoother.
optimize();
206 auto traj_smoothed = optimizationResult.
trajectory.value();
207 auto traj_smoothed_converted = traj_smoothed.mutablePoints() |
208 ranges::views::transform(
213 pt2.waypoint.pose * root_used_T_root;
220 if (lastPointsInCollision.empty())
222 ARMARX_INFO <<
"Smoothed trajectory is collision-free.";
224 .helperTrajectory = traj_smoothed};
230 <<
"Smoothed trajectory is NOT collision-free. Using original trajectory instead";
232 .helperTrajectory = trajBeforeTransform};
237 const std::string& vizLayerNamePrefix)
240 auto layer = vizClient.
layer(vizLayerNamePrefix +
"_points_in_collision");
242 for (std::size_t i = 0; i < lastPointsInCollision.size(); ++i)
244 const auto& p = lastPointsInCollision[i];
245 std::stringstream ss;
246 ss <<
"point_in_collision_" << i;
249 .
pose(Eigen::Isometry3f{Eigen::Translation3f{p.waypoint.pose.translation()}}
251 .
axisLengths(Eigen::Vector3f{100.0F, 100.0F, 100.0F})
252 .color(simox::Color::red());
253 layer.add(ellipsoid);
The A* planner (3D version including orientation dimension)
std::vector< core::GlobalTrajectoryPoint > checkCenterTrajectory(core::GlobalTrajectory ¢erTrajectory) const
OptimizationResult optimize()
VirtualRobot::RobotPtr robot
std::optional< GlobalPlannerResult > plan(const core::Pose &start, const core::Pose &goal)
void updateCostmap(const std::optional< navigation::algorithms::orientation_aware::Costmap3D > &costmap)
std::optional< navigation::algorithms::orientation_aware::Costmap3D > costmap
AStarWithOrientationImpl(const Params ¶ms, const std::optional< navigation::algorithms::orientation_aware::Costmap3D > &costmap, VirtualRobot::RobotPtr robot)
void visualizeDebugInfo(viz::Client &vizClient, const std::string &vizLayerNamePrefix="global_planner_debug")
AStarWithOrientationParams Params
void visualizeDebugInfo(viz::Client &vizClient, const std::string &vizLayerNamePrefix="global_planner_debug") override
std::optional< GlobalPlannerResult > plan(const core::Pose &goal) override
AStarWithOrientation(const Params ¶ms, const core::GeneralConfig &generalConfig, const core::Scene &ctx)
AStarWithOrientationParams Params
AStarWithOrientationImpl impl
core::GeneralConfig generalConfig
GlobalPlanner(const core::GeneralConfig &generalConfig, const core::Scene &scene)
const core::Scene & scene
virtual Layer layer(std::string const &name) const
CommitResult commit(StagedCommit const &commit)
DerivedT & pose(Eigen::Matrix4f const &pose)
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
std::shared_ptr< class Robot > RobotPtr
std::shared_ptr< Dict > DictPtr
AStarWithOrientationParams loadAStarWithOrientationParams(const std::string &filePath="algorithms/astarwithorientation.cfg")
SmoothingParams loadSmoothingParams(const std::string &filePath="algorithms/orientation-aware-smoothing.cfg")
Eigen::Isometry3f get_root_T_used_root(const armarx::navigation::algorithms::orientation_aware::Costmap3D &costmap, const VirtualRobot::RobotPtr &robot_in)
std::vector< Eigen::Vector2f > to2D(const std::vector< Eigen::Vector3f > &v)
std::vector< Eigen::Vector3f > to3D(const std::vector< Eigen::Vector2f > &v)
void toAron(arondto::GlobalPlannerParams &dto, const GlobalPlannerParams &bo)
void fromAron(const arondto::GlobalPlannerParams &dto, GlobalPlannerParams &bo)
This file is part of ArmarX.
std::optional< core::GlobalTrajectory > trajectory
Parameters for AStarWithOrientation.
aron::data::DictPtr toAron() const override
static AStarWithOrientationParams FromAron(const aron::data::DictPtr &dict)
Algorithms algorithm() const override
Ellipsoid & axisLengths(const Eigen::Vector3f &axisLengths)