12 #include <range/v3/view/drop.hpp>
13 #include <range/v3/view/zip.hpp>
20 return vec.cast<
double>() / 1000;
24 toRos(
const Eigen::Vector3f& vec)
36 teb_local_planner::PoseSE2
43 teb_local_planner::PoseSE2
46 Eigen::Vector2d pos = pose.translation().cast<
double>();
47 double theta = Eigen::Rotation2Df(pose.linear()).angle();
53 theta = g2o::normalize_theta(theta);
55 return {pos / 1000., theta};
60 fromRos(
const teb_local_planner::PoseSE2& pose)
62 Eigen::Vector2d pos = pose.position() * 1000;
63 double theta = pose.theta();
71 ret.translation() = pos.cast<
float>();
72 ret.linear() = Eigen::Rotation2Df(theta).toRotationMatrix();
80 geometry_msgs::Twist
ret;
85 ret.linear.x = velocity.
linear.y() / 1000;
86 ret.linear.y = -velocity.
linear.x() / 1000;
92 teb_local_planner::TimedElasticBand
95 teb_local_planner::TimedElasticBand teb;
98 teb_local_planner::PoseSE2 lastPose;
101 teb_local_planner::PoseSE2 pose =
toRos(point.waypoint.pose);
106 Eigen::Vector2d
distance = pose.position() - lastPose.position();
107 double timeDiff =
distance.norm() / (point.velocity / 1000);
108 teb.addTimeDiff(timeDiff);
120 fromRos(
const teb_local_planner::TimedElasticBand& teb)
122 const auto& tebPoses = teb.poses();
124 if (tebPoses.empty())
130 trajectory.reserve(tebPoses.size());
142 for (
const auto& [poseVertex, timediff] :
143 ranges::views::zip(tebPoses | ranges::views::drop(1), teb.timediffs()))
149 trajectory.push_back(
164 return {.a = ellipse.
b / 1000, .b = ellipse.
a / 1000};
167 teb_local_planner::Costmap
171 const teb_local_planner::Costmap::Parameters teb_params = {
175 const teb_local_planner::Costmap::SceneBounds teb_bounds = {
178 const std::optional<algorithms::Costmap::Mask>& mask = costmap.
getMask();
179 boost::optional<teb_local_planner::Costmap::Mask> teb_mask = boost::none;
182 teb_mask = mask.value();
186 teb_origin.translation() /= 1000;
191 return teb_local_planner::Costmap{teb_grid, teb_params, teb_bounds, teb_mask, teb_origin};
194 teb_local_planner::PenaltyModelPtr
197 return boost::make_shared<teb_local_planner::LinearPenaltyModel>(
201 teb_local_planner::PenaltyModelPtr
204 return boost::make_shared<teb_local_planner::ExponentialPenaltyModel>(