Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <swri_route_util/visualization.h>
00030
00031 #include <swri_route_util/util.h>
00032
00033 namespace vm = visualization_msgs;
00034 namespace mnm = marti_nav_msgs;
00035
00036 namespace swri_route_util
00037 {
00038 static geometry_msgs::Point makePoint(const double x, const double y)
00039 {
00040 geometry_msgs::Point pt;
00041 pt.x = x;
00042 pt.y = y;
00043 pt.z = 0.0;
00044 return pt;
00045 }
00046
00047 void markerForRouteSpeeds(
00048 vm::Marker &m,
00049 const Route &route,
00050 const mnm::RouteSpeedArray &speeds,
00051 double scale)
00052 {
00053 m.header.frame_id = route.header.frame_id;
00054 m.header.stamp = ros::Time::now();
00055
00056
00057 m.type = vm::Marker::LINE_LIST;
00058 m.action = vm::Marker::ADD;
00059 m.pose.position.x = 0.0;
00060 m.pose.position.y = 0.0;
00061 m.pose.position.z = 0.0;
00062 m.pose.orientation.x = 0.0;
00063 m.pose.orientation.y = 0.0;
00064 m.pose.orientation.z = 0.0;
00065 m.pose.orientation.w = 1.0;
00066 m.scale.x = 1.0;
00067 m.scale.y = 1.0;
00068 m.scale.z = 1.0;
00069 m.color.r = 0.0;
00070 m.color.g = 0.0;
00071 m.color.b = 0.0;
00072 m.color.a = 1.0;
00073 m.lifetime = ros::Duration(0);
00074 m.frame_locked = false;
00075
00076 m.points.reserve(speeds.speeds.size()*2);
00077
00078 for (auto const &speed : speeds.speeds) {
00079 mnm::RoutePosition position;
00080 position.id = speed.id;
00081 position.distance = speed.distance;
00082
00083 RoutePoint p;
00084 if (!interpolateRoutePosition(p, route, position, true)) {
00085 continue;
00086 }
00087
00088 tf::Vector3 p1 = p.position();
00089 tf::Vector3 v = tf::Transform(p.orientation()) * tf::Vector3(0.0, 1.0, 0.0);
00090 tf::Vector3 p2 = p1 + scale*speed.speed*v;
00091
00092 m.points.push_back(makePoint(p1.x(), p1.y()));
00093 m.points.push_back(makePoint(p2.x(), p2.y()));
00094 }
00095 }
00096 }