41 #include <teb_local_planner/FeedbackMsg.h> 58 ROS_WARN(
"TebVisualization already initialized. Reinitalizing...");
94 nav_msgs::Path teb_path;
99 geometry_msgs::PoseArray teb_poses;
100 teb_poses.header.frame_id = teb_path.header.frame_id;
101 teb_poses.header.stamp = teb_path.header.stamp;
106 geometry_msgs::PoseStamped pose;
107 pose.header.frame_id = teb_path.header.frame_id;
108 pose.header.stamp = teb_path.header.stamp;
109 pose.pose.position.x = teb.
Pose(i).
x();
110 pose.pose.position.y = teb.
Pose(i).
y();
113 teb_path.poses.push_back(pose);
114 teb_poses.poses.push_back(pose.pose);
123 const std_msgs::ColorRGBA &color)
128 std::vector<visualization_msgs::Marker> markers;
134 for (std::vector<visualization_msgs::Marker>::iterator marker_it = markers.begin(); marker_it != markers.end(); ++marker_it, ++idx)
138 marker_it->action = visualization_msgs::Marker::ADD;
160 visualization_msgs::Marker marker;
163 marker.ns =
"PointObstacles";
165 marker.type = visualization_msgs::Marker::POINTS;
166 marker.action = visualization_msgs::Marker::ADD;
169 for (ObstContainer::const_iterator obst = obstacles.begin(); obst != obstacles.end(); ++obst)
177 geometry_msgs::Point
point;
178 point.x = pobst->x();
179 point.y = pobst->y();
181 marker.points.push_back(point);
185 marker.type = visualization_msgs::Marker::LINE_LIST;
186 geometry_msgs::Point start;
187 start.x = pobst->x();
188 start.y = pobst->y();
190 marker.points.push_back(start);
192 geometry_msgs::Point end;
194 Eigen::Vector2d pred;
195 pobst->predictCentroidConstantVelocity(t, pred);
199 marker.points.push_back(end);
203 marker.scale.x = 0.1;
204 marker.scale.y = 0.1;
205 marker.color.a = 1.0;
206 marker.color.r = 1.0;
207 marker.color.g = 0.0;
208 marker.color.b = 0.0;
216 for (ObstContainer::const_iterator obst = obstacles.begin(); obst != obstacles.end(); ++obst)
222 visualization_msgs::Marker marker;
225 marker.ns =
"LineObstacles";
227 marker.type = visualization_msgs::Marker::LINE_STRIP;
228 marker.action = visualization_msgs::Marker::ADD;
230 geometry_msgs::Point start;
231 start.x = pobst->start().x();
232 start.y = pobst->start().y();
234 marker.points.push_back(start);
235 geometry_msgs::Point end;
236 end.x = pobst->end().x();
237 end.y = pobst->end().y();
239 marker.points.push_back(end);
241 marker.scale.x = 0.1;
242 marker.scale.y = 0.1;
243 marker.color.a = 1.0;
244 marker.color.r = 0.0;
245 marker.color.g = 1.0;
246 marker.color.b = 0.0;
256 for (ObstContainer::const_iterator obst = obstacles.begin(); obst != obstacles.end(); ++obst)
262 visualization_msgs::Marker marker;
265 marker.ns =
"PolyObstacles";
267 marker.type = visualization_msgs::Marker::LINE_STRIP;
268 marker.action = visualization_msgs::Marker::ADD;
271 for (Point2dContainer::const_iterator vertex = pobst->vertices().begin(); vertex != pobst->vertices().end(); ++vertex)
273 geometry_msgs::Point
point;
274 point.x = vertex->x();
275 point.y = vertex->y();
277 marker.points.push_back(point);
282 if (pobst->vertices().size() > 2)
284 geometry_msgs::Point
point;
285 point.x = pobst->vertices().front().x();
286 point.y = pobst->vertices().front().y();
288 marker.points.push_back(point);
290 marker.scale.x = 0.1;
291 marker.scale.y = 0.1;
292 marker.color.a = 1.0;
293 marker.color.r = 1.0;
294 marker.color.g = 0.0;
295 marker.color.b = 0.0;
308 visualization_msgs::Marker marker;
313 marker.type = visualization_msgs::Marker::POINTS;
314 marker.action = visualization_msgs::Marker::ADD;
317 for (std::size_t i=0; i <
via_points.size(); ++i)
319 geometry_msgs::Point
point;
323 marker.points.push_back(point);
326 marker.scale.x = 0.1;
327 marker.scale.y = 0.1;
328 marker.color.a = 1.0;
329 marker.color.r = 0.0;
330 marker.color.g = 0.0;
331 marker.color.b = 1.0;
341 visualization_msgs::Marker marker;
346 marker.type = visualization_msgs::Marker::LINE_LIST;
347 marker.action = visualization_msgs::Marker::ADD;
350 for( TebOptPlannerContainer::const_iterator it_teb = teb_planner.begin(); it_teb != teb_planner.end(); ++it_teb )
353 PoseSequence::const_iterator it_pose = it_teb->get()->teb().poses().begin();
354 TimeDiffSequence::const_iterator it_timediff = it_teb->get()->teb().timediffs().begin();
355 PoseSequence::const_iterator it_pose_end = it_teb->get()->teb().poses().end();
356 std::advance(it_pose_end, -1);
359 while (it_pose != it_pose_end)
361 geometry_msgs::Point point_start;
362 point_start.x = (*it_pose)->x();
363 point_start.y = (*it_pose)->y();
365 marker.points.push_back(point_start);
367 time += (*it_timediff)->dt();
369 geometry_msgs::Point point_end;
370 point_end.x = (*boost::next(it_pose))->
x();
371 point_end.y = (*boost::next(it_pose))->
y();
373 marker.points.push_back(point_end);
378 marker.scale.x = 0.01;
379 marker.color.a = 1.0;
380 marker.color.r = 0.5;
381 marker.color.g = 1.0;
382 marker.color.b = 0.0;
388 unsigned int selected_trajectory_idx,
const ObstContainer& obstacles)
393 msg.selected_trajectory_idx = selected_trajectory_idx;
396 msg.trajectories.resize(teb_planners.size());
399 std::size_t idx_traj = 0;
400 for( TebOptPlannerContainer::const_iterator it_teb = teb_planners.begin(); it_teb != teb_planners.end(); ++it_teb, ++idx_traj )
402 msg.trajectories[idx_traj].header = msg.header;
403 it_teb->get()->getFullTrajectory(msg.trajectories[idx_traj].trajectory);
407 msg.obstacles_msg.obstacles.resize(obstacles.size());
408 for (std::size_t i=0; i<obstacles.size(); ++i)
410 msg.obstacles_msg.header = msg.header;
413 msg.obstacles_msg.obstacles[i].header = msg.header;
414 obstacles[i]->toPolygonMsg(msg.obstacles_msg.obstacles[i].polygon);
417 msg.obstacles_msg.obstacles[i].id = i;
423 obstacles[i]->toTwistWithCovarianceMsg(msg.obstacles_msg.obstacles[i].velocities);
434 msg.selected_trajectory_idx = 0;
436 msg.trajectories.resize(1);
437 msg.trajectories.front().header = msg.header;
441 msg.obstacles_msg.obstacles.resize(obstacles.size());
442 for (std::size_t i=0; i<obstacles.size(); ++i)
444 msg.obstacles_msg.header = msg.header;
447 msg.obstacles_msg.obstacles[i].header = msg.header;
448 obstacles[i]->toPolygonMsg(msg.obstacles_msg.obstacles[i].polygon);
451 msg.obstacles_msg.obstacles[i].id = i;
457 obstacles[i]->toTwistWithCovarianceMsg(msg.obstacles_msg.obstacles[i].velocities);
465 std_msgs::ColorRGBA color;
477 ROS_ERROR(
"TebVisualization class not initialized. You must call initialize or an appropriate constructor");
void publishViaPoints(const std::vector< Eigen::Vector2d, Eigen::aligned_allocator< Eigen::Vector2d > > &via_points, const std::string &ns="ViaPoints") const
Publish via-points to the ros topic ../../teb_markers.
std::string map_frame
Global planning frame.
const TebConfig * cfg_
Config class that stores and manages all related parameters.
void initialize(ros::NodeHandle &nh, const TebConfig &cfg)
Initializes the class and registers topics.
ros::Publisher feedback_pub_
Publisher for the feedback message for analysis and debug purposes.
void publishLocalPlan(const std::vector< geometry_msgs::PoseStamped > &local_plan) const
Publish a given local plan to the ros topic ../../local_plan.
void publish(const boost::shared_ptr< M > &message) const
ros::Publisher teb_poses_pub_
Publisher for the trajectory pose sequence.
static std_msgs::ColorRGBA toColorMsg(double a, double r, double g, double b)
Helper function to generate a color message from single values.
Config class for the teb_local_planner and its components.
Class that defines a trajectory modeled as an elastic band with augmented tempoarl information...
bool printErrorWhenNotInitialized() const
Small helper function that checks if initialize() has been called and prints an error message if not...
double & x()
Access the x-coordinate the pose.
TFSIMD_FORCE_INLINE const tfScalar & y() const
Implements a polygon obstacle with an arbitrary number of vertices.
double visualize_with_time_as_z_axis_scale
If this value is bigger than 0, the trajectory and obstacles are visualized in 3d using the time as t...
Implements a 2D line obstacle.
void publishRobotFootprintModel(const PoseSE2 ¤t_pose, const BaseRobotFootprintModel &robot_model, const std::string &ns="RobotFootprintModel", const std_msgs::ColorRGBA &color=toColorMsg(0.5, 0.0, 0.8, 0.0))
Publish the visualization of the robot model.
void publishGlobalPlan(const std::vector< geometry_msgs::PoseStamped > &global_plan) const
Publish a given global plan to the ros topic ../../global_plan.
void publishLocalPlanAndPoses(const TimedElasticBand &teb) const
Publish Timed_Elastic_Band related stuff (local plan, pose sequence).
void publishObstacles(const ObstContainer &obstacles) const
Publish obstacle positions to the ros topic ../../teb_markers.
void publishTebContainer(const std::vector< boost::shared_ptr< TebOptimalPlanner > > &teb_planner, const std::string &ns="TebContainer")
Publish multiple Tebs from a container class (publish as marker message).
struct teb_local_planner::TebConfig::HomotopyClasses hcp
Implements a 2D point obstacle.
std::vector< ObstaclePtr > ObstContainer
Abbrev. for containers storing multiple obstacles.
TFSIMD_FORCE_INLINE const tfScalar & x() const
void getFullTrajectory(std::vector< TrajectoryPointMsg > &trajectory) const
Return the complete trajectory including poses, velocity profiles and temporal information.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::Publisher teb_marker_pub_
Publisher for visualization markers.
std::vector< TebOptimalPlannerPtr > TebOptPlannerContainer
Abbrev. for containers storing multiple teb optimal planners.
PoseSE2 & Pose(int index)
Access the pose at pos index of the pose sequence.
double & y()
Access the y-coordinate the pose.
This class implements a pose in the domain SE2: The pose consist of the position x and y and an orie...
double & theta()
Access the orientation part (yaw angle) of the pose.
TebVisualization()
Default constructor.
void publishPlan(const std::vector< geometry_msgs::PoseStamped > &path, const ros::Publisher &pub)
static geometry_msgs::Quaternion createQuaternionMsgFromYaw(double yaw)
ros::Publisher global_plan_pub_
Publisher for the global plan.
This class optimizes an internal Timed Elastic Band trajectory using the g2o-framework.
void publishInfeasibleRobotPose(const PoseSE2 ¤t_pose, const BaseRobotFootprintModel &robot_model)
Publish the robot footprints related to infeasible poses.
double getSumOfTimeDiffsUpToIdx(int index) const
Calculate the estimated transition time up to the pose denoted by index.
ros::Publisher local_plan_pub_
Publisher for the local plan.
ViaPointContainer via_points
bool initialized_
Keeps track about the correct initialization of this class.
void publishFeedbackMessage(const std::vector< boost::shared_ptr< TebOptimalPlanner > > &teb_planners, unsigned int selected_trajectory_idx, const ObstContainer &obstacles)
Publish a feedback message (multiple trajectory version)
int sizePoses() const
Get the length of the internal pose sequence.