28 #include <nav_msgs/Path.h> 30 #include <visualization_msgs/Marker.h> 32 #include <boost/pointer_cast.hpp> 33 #include <boost/shared_ptr.hpp> 45 if (
_initialized)
ROS_WARN(
"mpc_local_planner: Publisher already initialized. Reinitalizing...");
69 ROS_ERROR(
"Publisher::publishLocalPlan(): cannot publish since the system class is not provided.");
73 std::vector<geometry_msgs::PoseStamped> local_plan;
86 const std_msgs::ColorRGBA& color)
90 std::vector<visualization_msgs::Marker> markers;
92 if (markers.empty())
return;
95 for (visualization_msgs::Marker& marker : markers)
99 marker.action = visualization_msgs::Marker::ADD;
113 visualization_msgs::Marker marker;
116 marker.ns =
"PointObstacles";
118 marker.type = visualization_msgs::Marker::POINTS;
119 marker.action = visualization_msgs::Marker::ADD;
127 if (!pobst)
continue;
129 geometry_msgs::Point
point;
130 point.x = pobst->x();
131 point.y = pobst->y();
133 marker.points.push_back(point);
136 marker.scale.x = 0.1;
137 marker.scale.y = 0.1;
138 marker.color.a = 1.0;
139 marker.color.r = 1.0;
140 marker.color.g = 0.0;
141 marker.color.b = 0.0;
153 if (!pobst)
continue;
155 visualization_msgs::Marker marker;
158 marker.ns =
"LineObstacles";
160 marker.type = visualization_msgs::Marker::LINE_STRIP;
161 marker.action = visualization_msgs::Marker::ADD;
163 geometry_msgs::Point
start;
164 start.x = pobst->start().x();
165 start.y = pobst->start().y();
167 marker.points.push_back(start);
168 geometry_msgs::Point end;
169 end.x = pobst->end().x();
170 end.y = pobst->end().y();
172 marker.points.push_back(end);
174 marker.scale.x = 0.1;
175 marker.scale.y = 0.1;
176 marker.color.a = 1.0;
177 marker.color.r = 0.0;
178 marker.color.g = 1.0;
179 marker.color.b = 0.0;
192 if (!pobst)
continue;
194 visualization_msgs::Marker marker;
197 marker.ns =
"PolyObstacles";
199 marker.type = visualization_msgs::Marker::LINE_STRIP;
200 marker.action = visualization_msgs::Marker::ADD;
203 for (Point2dContainer::const_iterator vertex = pobst->vertices().begin(); vertex != pobst->vertices().end(); ++vertex)
205 geometry_msgs::Point
point;
206 point.x = vertex->x();
207 point.y = vertex->y();
209 marker.points.push_back(point);
214 if (pobst->vertices().size() > 2)
216 geometry_msgs::Point
point;
217 point.x = pobst->vertices().front().x();
218 point.y = pobst->vertices().front().y();
220 marker.points.push_back(point);
222 marker.scale.x = 0.1;
223 marker.scale.y = 0.1;
224 marker.color.a = 1.0;
225 marker.color.r = 1.0;
226 marker.color.g = 0.0;
227 marker.color.b = 0.0;
238 visualization_msgs::Marker marker;
243 marker.type = visualization_msgs::Marker::POINTS;
244 marker.action = visualization_msgs::Marker::ADD;
249 geometry_msgs::Point
point;
250 point.x = via_point.x();
251 point.y = via_point.y();
253 marker.points.push_back(point);
256 marker.scale.x = 0.1;
257 marker.scale.y = 0.1;
258 marker.color.a = 1.0;
259 marker.color.r = 0.0;
260 marker.color.g = 0.0;
261 marker.color.b = 1.0;
268 std_msgs::ColorRGBA color;
void publishObstacles(const teb_local_planner::ObstContainer &obstacles) const
Publish obstacle positions to the ros topic ../../mpc_markers.
void publishViaPoints(const std::vector< teb_local_planner::PoseSE2 > &via_points, const std::string &ns="ViaPoints") const
Publish via-points to the ros topic ../../teb_markers.
void publishLocalPlan(const std::vector< geometry_msgs::PoseStamped > &local_plan) const
Publish a given local plan to the ros topic ../../local_plan.
void publishRobotFootprintModel(const teb_local_planner::PoseSE2 ¤t_pose, const teb_local_planner::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 convert(const corbo::TimeSeries &time_series, const RobotDynamicsInterface &dynamics, std::vector< geometry_msgs::PoseStamped > &poses_stamped, const std::string &frame_id)
Convert TimeSeries to pose array.
void publishGlobalPlan(const std::vector< geometry_msgs::PoseStamped > &global_plan) const
Publish a given global plan to the ros topic ../../global_plan.
static std_msgs::ColorRGBA toColorMsg(float a, float r, float g, float b)
Helper function to generate a color message from single values.
Publisher()=default
Default constructor.
ros::Publisher _local_plan_pub
std::shared_ptr< RobotDynamicsInterface > Ptr
RobotDynamicsInterface::Ptr _system
void initialize(ros::NodeHandle &nh, RobotDynamicsInterface::Ptr system, const std::string &map_frame)
Initializes the class and registers topics.
void publish(const boost::shared_ptr< M > &message) const
std::vector< ObstaclePtr > ObstContainer
ros::Publisher _mpc_marker_pub
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void publishPlan(const std::vector< geometry_msgs::PoseStamped > &path, const ros::Publisher &pub)
ros::Publisher _global_plan_pub