7 const std::string& color,
float scale,
const std::string& frame_id,
const std::string& shape,
11 auto marker = visualization_msgs::msg::Marker();
13 marker.header.frame_id = frame_id;
14 marker.header.stamp = rclcpp::Clock().now();
15 marker.ns = name_space;
18 marker.action = action;
20 marker.pose.orientation.x = 0.0;
21 marker.pose.orientation.y = 0.0;
22 marker.pose.orientation.z = 0.0;
23 marker.pose.orientation.w = 1.0;
25 marker.pose.position.x = position.
x;
26 marker.pose.position.y = position.
y;
27 marker.pose.position.z = 0.1;
29 marker.scale.x = scale;
30 marker.scale.y = scale;
31 marker.scale.z = scale;
33 marker.color.r = color_array[0];
34 marker.color.g = color_array[1];
35 marker.color.b = color_array[2];
36 marker.color.a = color_array[3];
42 const std::vector<std::pair<Point, Point>>& triangulations,
const std::string& name_space,
43 const std::string& frame_id,
int id,
const std::string& color,
float scale,
int action) {
46 visualization_msgs::msg::Marker marker;
47 marker.header.frame_id = frame_id;
48 marker.header.stamp = rclcpp::Clock().now();
49 marker.ns = name_space;
51 marker.type = visualization_msgs::msg::Marker::LINE_LIST;
52 marker.action = action;
54 marker.pose.orientation.w = 1.0;
55 marker.scale.x = scale;
57 marker.color.r = color_array[0];
58 marker.color.g = color_array[1];
59 marker.color.b = color_array[2];
60 marker.color.a = color_array[3];
62 for (
const auto& [point1, point2] : triangulations) {
63 geometry_msgs::msg::Point p1, p2;
72 marker.points.push_back(p1);
73 marker.points.push_back(p2);
80 const std::vector<common_lib::structures::PathPoint>& path_array,
const std::string& name_space,
81 const std::string& frame_id,
float scale,
int every_nth) {
82 visualization_msgs::msg::MarkerArray marker_array;
84 std::array<float, 4> color_array = {1.0f, 1.0f, 1.0f, 0.8f};
86 for (
size_t i = 0; i < path_array.size(); i += every_nth) {
87 visualization_msgs::msg::Marker sphere_marker;
88 sphere_marker.header.frame_id = frame_id;
89 sphere_marker.header.stamp = rclcpp::Clock().now();
90 sphere_marker.ns = name_space +
"_sphere";
91 sphere_marker.id =
static_cast<int>(i);
92 sphere_marker.type = visualization_msgs::msg::Marker::SPHERE;
93 sphere_marker.action = visualization_msgs::msg::Marker::ADD;
95 sphere_marker.pose.position.x = path_array[i].position.x;
96 sphere_marker.pose.position.y = path_array[i].position.y;
97 sphere_marker.pose.position.z = 0.1;
98 sphere_marker.pose.orientation.w = 1.0;
100 sphere_marker.scale.x = scale;
101 sphere_marker.scale.y = scale;
102 sphere_marker.scale.z = scale;
104 sphere_marker.color.r = color_array[0];
105 sphere_marker.color.g = color_array[1];
106 sphere_marker.color.b = color_array[2];
107 sphere_marker.color.a = color_array[3];
109 marker_array.markers.push_back(sphere_marker);
111 visualization_msgs::msg::Marker text_marker;
112 text_marker.header.frame_id = frame_id;
113 text_marker.header.stamp = rclcpp::Clock().now();
114 text_marker.ns = name_space +
"_text";
115 text_marker.id =
static_cast<int>(i);
116 text_marker.type = visualization_msgs::msg::Marker::TEXT_VIEW_FACING;
117 text_marker.action = visualization_msgs::msg::Marker::ADD;
119 text_marker.pose.position.x = path_array[i].position.x;
120 text_marker.pose.position.y = path_array[i].position.y;
121 text_marker.pose.position.z = 0.5;
122 text_marker.pose.orientation.w = 1.0;
124 std::ostringstream velocity_text;
125 velocity_text << std::fixed << std::setprecision(1) << path_array[i].ideal_velocity <<
" m/s";
127 text_marker.text = velocity_text.str();
128 text_marker.scale.z = 0.3;
130 text_marker.color.r = 1.0f;
131 text_marker.color.g = 1.0f;
132 text_marker.color.b = 1.0f;
133 text_marker.color.a = 1.0f;
135 marker_array.markers.push_back(text_marker);
visualization_msgs::msg::MarkerArray velocity_hover_markers(const std::vector< common_lib::structures::PathPoint > &path_array, const std::string &name_space, const std::string &frame_id, float scale=0.2f, int every_nth=1)
Creates sphere markers at each path point with velocity in the marker namespace When you hover over t...
visualization_msgs::msg::Marker marker_from_position(const common_lib::structures::Position &position, const std::string &name_space, const int id, const std::string &color="red", float scale=0.5, const std::string &frame_id="map", const std::string &shape="sphere", int action=visualization_msgs::msg::Marker::ADD)
Converts a position to a marker.
visualization_msgs::msg::Marker lines_marker_from_triangulations(const std::vector< std::pair< Point, Point > > &triangulations, const std::string &name_space, const std::string &frame_id, int id, const std::string &color, float scale, int action)
Converts a vector of triangulation edges to a marker.