8#include <boost/none.hpp>
9#include <boost/optional/optional.hpp>
10#include <boost/smart_ptr/make_shared_object.hpp>
25#include <geometry_msgs/Twist.h>
26#include <range/v3/view/drop.hpp>
27#include <range/v3/view/zip.hpp>
28#include <stuff/misc.h>
29#include <teb_local_planner/costmap.h>
30#include <teb_local_planner/penalty_models.h>
31#include <teb_local_planner/pose_se2.h>
32#include <teb_local_planner/timed_elastic_band.h>
39 return vec.cast<
double>() / 1000;
43 toRos(
const Eigen::Vector3f& vec)
54 teb_local_planner::PoseSE2
61 teb_local_planner::PoseSE2
64 Eigen::Vector2d pos = pose.translation().cast<
double>();
65 double theta = Eigen::Rotation2Df(pose.linear()).angle();
71 theta = g2o::normalize_theta(theta);
73 return {pos / 1000., theta};
77 fromRos(
const teb_local_planner::PoseSE2& pose)
79 Eigen::Vector2d pos = pose.position() * 1000;
80 double theta = pose.theta();
88 ret.translation() = pos.cast<
float>();
89 ret.linear() = Eigen::Rotation2Df(theta).toRotationMatrix();
97 geometry_msgs::Twist ret;
102 ret.linear.x = velocity.
linear.y() / 1000;
103 ret.linear.y = -velocity.
linear.x() / 1000;
104 ret.angular.z = velocity.
angular.z();
109 teb_local_planner::TimedElasticBand
112 teb_local_planner::TimedElasticBand teb;
115 teb_local_planner::PoseSE2 lastPose;
118 teb_local_planner::PoseSE2 pose =
toRos(point.waypoint.pose);
123 Eigen::Vector2d
distance = pose.position() - lastPose.position();
124 double timeDiff =
distance.norm() / (point.velocity / 1000);
125 teb.addTimeDiff(timeDiff);
139 const auto& tebPoses = teb.poses();
141 if (tebPoses.empty())
159 for (
const auto& [poseVertex, timediff] :
160 ranges::views::zip(tebPoses | ranges::views::drop(1), teb.timediffs()))
181 return {.a = ellipse.
b / 1000, .b = ellipse.
a / 1000};
184 teb_local_planner::Costmap
188 const teb_local_planner::Costmap::Parameters teb_params = {
192 const teb_local_planner::Costmap::SceneBounds teb_bounds = {
195 const std::optional<algorithms::Costmap::Mask>& mask = costmap.
getMask();
196 boost::optional<teb_local_planner::Costmap::Mask> teb_mask = boost::none;
199 teb_mask = mask.value();
202 teb_local_planner::Costmap::Pose2D teb_origin = costmap.
origin();
203 teb_origin.translation() /= 1000;
208 return teb_local_planner::Costmap{teb_grid, teb_params, teb_bounds, teb_mask, teb_origin};
211 teb_local_planner::PenaltyModelPtr
214 return boost::make_shared<teb_local_planner::LinearPenaltyModel>(
218 teb_local_planner::PenaltyModelPtr
221 return boost::make_shared<teb_local_planner::ExponentialPenaltyModel>(
static Duration SecondsDouble(double seconds)
Constructs a duration in seconds.
Represents a point in time.
const Grid & getGrid() const
const core::Pose2D & origin() const
const SceneBounds & getLocalSceneBounds() const noexcept
const Parameters & params() const noexcept
const std::optional< Mask > & getMask() const noexcept
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
This file is part of ArmarX.
Eigen::Vector2d toRos(const Eigen::Vector3f &vec)
std::vector< Eigen::Vector2f > to2D(const std::vector< Eigen::Vector3f > &v)
std::vector< Eigen::Vector3f > to3D(const std::vector< Eigen::Vector2f > &v)
Eigen::Vector3f fromRos(const Eigen::Vector2d &vec)
Eigen::Vector2d toRos2D(const Eigen::Vector2f &vec)
std::vector< LocalTrajectoryPoint > LocalTrajectoryPoints
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
double distance(const Point &a, const Point &b)
float cellSize
How big each cell is in the uniform grid.
An axis oriented ellipse with half-axes a and b along the x- and y-axis respectively.