40 #include <mbf_msgs/GetPathResult.h>
57 double tolerance, std::vector<geometry_msgs::PoseStamped>& plan,
double& cost,
61 std::list<lvr2::VertexHandle> path;
62 ROS_INFO(
"start dijkstra mesh planner.");
68 uint32_t outcome =
dijkstra(goal_vec, start_vec, path);
80 const auto& vertex_normals =
mesh_map->vertexNormals();
84 geometry_msgs::PoseStamped pose;
96 normal = vertex_normals[vH];
102 plan.push_back(pose);
106 nav_msgs::Path path_msg;
107 path_msg.poses = plan;
146 new dynamic_reconfigure::Server<dijkstra_mesh_planner::DijkstraMeshPlannerConfig>(
private_nh));
161 ROS_INFO_STREAM(
"New height diff layer config through dynamic reconfigure.");
175 for (
auto v3 :
mesh.vertices())
182 const auto& vec3 =
mesh.getVertexPosition(v3);
183 const auto& vec1 =
mesh.getVertexPosition(v1);
186 const auto dirVec = vec1 - vec3;
194 std::list<lvr2::VertexHandle>& path)
209 const auto& vertex_costs =
mesh_map->vertexCosts();
217 const auto& start_opt =
mesh_map->getNearestVertexHandle(original_start);
218 const auto& goal_opt =
mesh_map->getNearestVertexHandle(original_goal);
223 return mbf_msgs::GetPathResult::INVALID_START;
225 return mbf_msgs::GetPathResult::INVALID_GOAL;
227 const auto& start_vertex = start_opt.unwrap();
228 const auto& goal_vertex = goal_opt.unwrap();
234 if (goal_vertex == start_vertex)
236 return mbf_msgs::GetPathResult::SUCCESS;
249 for (
auto const& vH :
mesh.vertices())
251 distances.
insert(vH, std::numeric_limits<float>::infinity());
259 distances[start_vertex] = 0;
260 pq.
insert(start_vertex, 0);
262 float goal_dist = std::numeric_limits<float>::infinity();
266 double initialization_duration = (t_propagation_start - t_initialization_start).toNSec() * 1e-6;
268 size_t fixed_set_cnt = 0;
273 fixed[current_vh] =
true;
276 if (current_vh == goal_vertex)
282 if (distances[current_vh] > goal_dist)
285 if (vertex_costs[current_vh] >
config.cost_limit)
288 std::vector<lvr2::EdgeHandle> edges;
291 mesh.getEdgesOfVertex(current_vh, edges);
295 invalid.insert(current_vh,
true);
300 invalid.insert(current_vh,
true);
303 for (
auto eH : edges)
307 std::array<lvr2::VertexHandle, 2> vertices =
mesh.getVerticesOfEdge(eH);
308 auto vH = vertices[0] == current_vh ? vertices[1] : vertices[0];
314 float tmp_cost = distances[current_vh] + edge_weights[eH];
315 if (tmp_cost < distances[vH])
317 distances[vH] = tmp_cost;
336 return mbf_msgs::GetPathResult::CANCELED;
339 ROS_INFO_STREAM(
"The Dijkstra Mesh Planner finished the propagation.");
343 ROS_WARN(
"Predecessor of the goal is not set! No path found!");
344 return mbf_msgs::GetPathResult::NO_PATH_FOUND;
348 double propagation_duration = (t_propagation_end - t_propagation_start).toNSec() * 1e-6;
350 auto vH = goal_vertex;
359 double execution_time = (t_end - t_start).toNSec() * 1e-6;
361 <<
" num vertices in the mesh.");
368 return mbf_msgs::GetPathResult::CANCELED;
372 double path_backtracking_duration = (t_path_backtracking - t_propagation_end).toNSec() * 1e-6;
374 ROS_INFO_STREAM(
"Processed " << fixed_set_cnt <<
" vertices in the fixed set.");
375 ROS_INFO_STREAM(
"Initialization duration (ms): " << initialization_duration);
376 ROS_INFO_STREAM(
"Execution time wavefront propagation (ms): "<< propagation_duration);
377 ROS_INFO_STREAM(
"Path backtracking duration (ms): " << path_backtracking_duration);
380 return mbf_msgs::GetPathResult::SUCCESS;