31 static constexpr double EPSILON = 10.0 * std::numeric_limits<double>::epsilon();
32 static constexpr double MESH_EPSILON = 50.0 * std::numeric_limits<double>::epsilon();
36 for (
auto &&lane_section :
road.GetLaneSections()) {
39 return std::make_unique<Mesh>(out_mesh);
44 for (
auto &&lane_pair : lane_section.
GetLanes()) {
45 out_mesh += *
Generate(lane_pair.second);
47 return std::make_unique<Mesh>(out_mesh);
53 return Generate(lane, s_start, s_end);
63 const road::Lane &lane,
const double s_start,
const double s_end)
const {
71 if (lane.
GetId() == 0) {
72 return std::make_unique<Mesh>(out_mesh);
74 double s_current = s_start;
76 std::vector<geom::Vector3D> vertices;
81 vertices.push_back(edges.first);
82 vertices.push_back(edges.second);
88 vertices.push_back(edges.first);
89 vertices.push_back(edges.second);
93 }
while(s_current < s_end);
100 vertices.push_back(edges.first);
101 vertices.push_back(edges.second);
109 return std::make_unique<Mesh>(out_mesh);
113 const road::Lane& lane,
const double s_start,
const double s_end)
const {
121 if (lane.
GetId() == 0) {
122 return std::make_unique<Mesh>(out_mesh);
124 double s_current = s_start;
126 std::vector<geom::Vector3D> vertices;
129 const size_t segments_number = vertices_in_width - 1;
131 std::vector<geom::Vector2D> uvs;
138 const geom::Vector3D segments_size = ( edges.second - edges.first ) /
static_cast<float>(segments_number);
141 for (
size_t i = 0; i < vertices_in_width; ++i) {
142 uvs.push_back(
geom::Vector2D(
static_cast<float>(uvx),
static_cast<float>(uvy)));
143 vertices.push_back(current_vertex);
144 current_vertex = current_vertex + segments_size;
150 }
while (s_current < s_end);
156 std::pair<carla::geom::Vector3D, carla::geom::Vector3D> edges =
158 const geom::Vector3D segments_size = (edges.second - edges.first) /
static_cast<float>(segments_number);
161 for (
size_t i = 0; i < vertices_in_width; ++i)
163 uvs.push_back(
geom::Vector2D(
static_cast<float>(uvx),
static_cast<float>(uvy)));
164 vertices.push_back(current_vertex);
165 current_vertex = current_vertex + segments_size;
176 const size_t number_of_rows = (vertices.size() / vertices_in_width);
178 for (
size_t i = 0; i < (number_of_rows - 1); ++i) {
179 for (
size_t j = 0; j < vertices_in_width - 1; ++j) {
180 out_mesh.
AddIndex( j + ( i * vertices_in_width ) + 1);
181 out_mesh.
AddIndex( ( j + 1 ) + ( i * vertices_in_width ) + 1);
182 out_mesh.
AddIndex( j + ( ( i + 1 ) * vertices_in_width ) + 1);
184 out_mesh.
AddIndex( ( j + 1 ) + ( i * vertices_in_width ) + 1);
185 out_mesh.
AddIndex( ( j + 1 ) + ( ( i + 1 ) * vertices_in_width ) + 1);
186 out_mesh.
AddIndex( j + ( ( i + 1 ) * vertices_in_width ) + 1);
190 return std::make_unique<Mesh>(out_mesh);
199 std::vector<size_t> redirections;
200 for (
auto &&lane_pair : lane_section.
GetLanes()) {
201 auto it = std::find(redirections.begin(), redirections.end(),
static_cast<size_t>(lane_pair.first));
202 if ( it == redirections.end() ) {
203 redirections.push_back(
static_cast<size_t>(lane_pair.first));
204 it = std::find(redirections.begin(), redirections.end(),
static_cast<size_t>(lane_pair.first));
206 size_t PosToAdd =
static_cast<size_t>(it - redirections.begin());
215 if( result[lane_pair.second.GetType()].size() <= PosToAdd ){
216 result[lane_pair.second.GetType()].push_back(std::make_unique<Mesh>(out_mesh));
218 uint32_t verticesinwidth = 0;
220 verticesinwidth =
static_cast<uint32_t
>(vertices_in_width);
226 (result[lane_pair.second.GetType()][PosToAdd])->ConcatMesh(out_mesh,
static_cast<int>(verticesinwidth));
234 for (
auto &&lane_pair : lane_section.
GetLanes()) {
235 const double s_start = lane_pair.second.GetDistance() +
EPSILON;
236 const double s_end = lane_pair.second.GetDistance() + lane_pair.second.GetLength() -
EPSILON;
239 return std::make_unique<Mesh>(out_mesh);
248 const double s_end )
const {
257 if (lane.
GetId() == 0) {
258 return std::make_unique<Mesh>(out_mesh);
260 double s_current = s_start;
262 std::vector<geom::Vector3D> vertices;
264 const size_t vertices_in_width = 6;
265 std::vector<geom::Vector2D> uvs;
271 std::pair<geom::Vector3D, geom::Vector3D> edges =
276 vertices.push_back(low_vertex_first);
279 vertices.push_back(edges.first);
282 vertices.push_back(edges.first);
285 vertices.push_back(edges.second);
288 vertices.push_back(edges.second);
291 vertices.push_back(low_vertex_second);
297 }
while (s_current < s_end);
303 std::pair<carla::geom::Vector3D, carla::geom::Vector3D> edges =
309 vertices.push_back(low_vertex_first);
312 vertices.push_back(edges.first);
315 vertices.push_back(edges.first);
318 vertices.push_back(edges.second);
321 vertices.push_back(edges.second);
324 vertices.push_back(low_vertex_second);
335 const size_t number_of_rows = (vertices.size() / vertices_in_width);
337 for (
size_t i = 0; i < (number_of_rows - 1); ++i) {
338 for (
size_t j = 0; j < vertices_in_width - 1; ++j) {
340 if(j == 1 || j == 3){
344 out_mesh.
AddIndex( j + ( i * vertices_in_width ) + 1);
345 out_mesh.
AddIndex( ( j + 1 ) + ( i * vertices_in_width ) + 1);
346 out_mesh.
AddIndex( j + ( ( i + 1 ) * vertices_in_width ) + 1);
348 out_mesh.
AddIndex( ( j + 1 ) + ( i * vertices_in_width ) + 1);
349 out_mesh.
AddIndex( ( j + 1 ) + ( ( i + 1 ) * vertices_in_width ) + 1);
350 out_mesh.
AddIndex( j + ( ( i + 1 ) * vertices_in_width ) + 1);
355 return std::make_unique<Mesh>(out_mesh);
360 const auto min_lane = lane_section.
GetLanes().begin()->first == 0 ?
361 1 : lane_section.
GetLanes().begin()->first;
362 const auto max_lane = lane_section.
GetLanes().rbegin()->first == 0 ?
363 -1 : lane_section.
GetLanes().rbegin()->first;
365 for (
auto &&lane_pair : lane_section.
GetLanes()) {
366 const auto &lane = lane_pair.second;
367 const double s_start = lane.GetDistance() +
EPSILON;
368 const double s_end = lane.GetDistance() + lane.GetLength() -
EPSILON;
369 if (lane.GetId() == max_lane) {
372 if (lane.GetId() == min_lane) {
376 return std::make_unique<Mesh>(out_mesh);
380 const road::Lane &lane,
const double s_start,
const double s_end)
const {
388 if (lane.
GetId() == 0) {
389 return std::make_unique<Mesh>(out_mesh);
391 double s_current = s_start;
394 std::vector<geom::Vector3D> r_vertices;
399 r_vertices.push_back(edges.first + height_vector);
400 r_vertices.push_back(edges.first);
406 r_vertices.push_back(edges.first + height_vector);
407 r_vertices.push_back(edges.first);
411 }
while(s_current < s_end);
418 r_vertices.push_back(edges.first + height_vector);
419 r_vertices.push_back(edges.first);
427 return std::make_unique<Mesh>(out_mesh);
431 const road::Lane &lane,
const double s_start,
const double s_end)
const {
439 if (lane.
GetId() == 0) {
440 return std::make_unique<Mesh>(out_mesh);
442 double s_current = s_start;
445 std::vector<geom::Vector3D> l_vertices;
450 l_vertices.push_back(edges.second);
451 l_vertices.push_back(edges.second + height_vector);
457 l_vertices.push_back(edges.second);
458 l_vertices.push_back(edges.second + height_vector);
462 }
while(s_current < s_end);
469 l_vertices.push_back(edges.second);
470 l_vertices.push_back(edges.second + height_vector);
478 return std::make_unique<Mesh>(out_mesh);
483 std::vector<std::unique_ptr<Mesh>> mesh_uptr_list;
484 for (
auto &&lane_section :
road.GetLaneSections()) {
486 mesh_uptr_list.insert(
487 mesh_uptr_list.end(),
488 std::make_move_iterator(section_uptr_list.begin()),
489 std::make_move_iterator(section_uptr_list.end()));
491 return mesh_uptr_list;
496 std::vector<std::unique_ptr<Mesh>> mesh_uptr_list;
498 mesh_uptr_list.emplace_back(
Generate(lane_section));
504 Mesh lane_section_mesh;
505 for (
auto &&lane_pair : lane_section.
GetLanes()) {
506 lane_section_mesh += *
Generate(lane_pair.second, s_current, s_until);
508 mesh_uptr_list.emplace_back(std::make_unique<Mesh>(lane_section_mesh));
511 if (s_end - s_current >
EPSILON) {
512 Mesh lane_section_mesh;
513 for (
auto &&lane_pair : lane_section.
GetLanes()) {
514 lane_section_mesh += *
Generate(lane_pair.second, s_current, s_end);
516 mesh_uptr_list.emplace_back(std::make_unique<Mesh>(lane_section_mesh));
519 return mesh_uptr_list;
524 std::map<road::Lane::LaneType , std::vector<std::unique_ptr<Mesh>>> mesh_uptr_list;
525 for (
auto &&lane_section :
road.GetLaneSections()) {
526 std::map<road::Lane::LaneType , std::vector<std::unique_ptr<Mesh>>> section_uptr_list =
GenerateOrderedWithMaxLen(lane_section);
527 mesh_uptr_list.insert(
528 std::make_move_iterator(section_uptr_list.begin()),
529 std::make_move_iterator(section_uptr_list.end()));
531 return mesh_uptr_list;
537 std::map<road::Lane::LaneType , std::vector<std::unique_ptr<Mesh>>> mesh_uptr_list;
544 std::vector<size_t> redirections;
548 for (
auto &&lane_pair : lane_section.
GetLanes()) {
549 Mesh lane_section_mesh;
553 lane_section_mesh += *
GenerateSidewalk(lane_pair.second, s_current, s_until);
556 auto it = std::find(redirections.begin(), redirections.end(),
static_cast<size_t>(lane_pair.first));
557 if (it == redirections.end()) {
558 redirections.push_back(
static_cast<size_t>(lane_pair.first));
559 it = std::find(redirections.begin(), redirections.end(),
static_cast<size_t>(lane_pair.first));
562 size_t PosToAdd =
static_cast<size_t>(it - redirections.begin());
563 if (mesh_uptr_list[lane_pair.second.GetType()].size() <= PosToAdd) {
564 mesh_uptr_list[lane_pair.second.GetType()].push_back(std::make_unique<Mesh>(lane_section_mesh));
566 uint32_t verticesinwidth = 0;
568 verticesinwidth =
static_cast<uint32_t
>(vertices_in_width);
574 (mesh_uptr_list[lane_pair.second.GetType()][PosToAdd])->ConcatMesh(lane_section_mesh,
static_cast<int>(verticesinwidth));
579 if (s_end - s_current >
EPSILON) {
580 for (
auto &&lane_pair : lane_section.
GetLanes()) {
581 Mesh lane_section_mesh;
588 auto it = std::find(redirections.begin(), redirections.end(),
static_cast<size_t>(lane_pair.first));
589 if (it == redirections.end()) {
590 redirections.push_back(
static_cast<size_t>(lane_pair.first));
591 it = std::find(redirections.begin(), redirections.end(),
static_cast<size_t>(lane_pair.first));
594 size_t PosToAdd =
static_cast<size_t>(it - redirections.begin());
596 if (mesh_uptr_list[lane_pair.second.GetType()].size() <= PosToAdd) {
597 mesh_uptr_list[lane_pair.second.GetType()].push_back(std::make_unique<Mesh>(lane_section_mesh));
599 uint32_t verticesinwidth = 0;
601 verticesinwidth =
static_cast<uint32_t
>(vertices_in_width);
607 *(mesh_uptr_list[lane_pair.second.GetType()][PosToAdd]) += lane_section_mesh;
612 return mesh_uptr_list;
617 std::vector<std::unique_ptr<Mesh>> mesh_uptr_list;
618 for (
auto &&lane_section :
road.GetLaneSections()) {
620 mesh_uptr_list.insert(
621 mesh_uptr_list.end(),
622 std::make_move_iterator(section_uptr_list.begin()),
623 std::make_move_iterator(section_uptr_list.end()));
625 return mesh_uptr_list;
630 std::vector<std::unique_ptr<Mesh>> mesh_uptr_list;
632 const auto min_lane = lane_section.
GetLanes().begin()->first == 0 ?
633 1 : lane_section.
GetLanes().begin()->first;
634 const auto max_lane = lane_section.
GetLanes().rbegin()->first == 0 ?
635 -1 : lane_section.
GetLanes().rbegin()->first;
644 Mesh lane_section_mesh;
645 for (
auto &&lane_pair : lane_section.
GetLanes()) {
646 const auto &lane = lane_pair.second;
647 if (lane.GetId() == max_lane) {
650 if (lane.GetId() == min_lane) {
654 mesh_uptr_list.emplace_back(std::make_unique<Mesh>(lane_section_mesh));
657 if (s_end - s_current >
EPSILON) {
658 Mesh lane_section_mesh;
659 for (
auto &&lane_pair : lane_section.
GetLanes()) {
660 const auto &lane = lane_pair.second;
661 if (lane.GetId() == max_lane) {
664 if (lane.GetId() == min_lane) {
668 mesh_uptr_list.emplace_back(std::make_unique<Mesh>(lane_section_mesh));
671 return mesh_uptr_list;
676 std::vector<std::unique_ptr<Mesh>> mesh_uptr_list;
680 mesh_uptr_list.insert(
681 mesh_uptr_list.end(),
682 std::make_move_iterator(roads.begin()),
683 std::make_move_iterator(roads.end()));
686 if (!
road.IsJunction()) {
689 if (roads.size() == walls.size()) {
690 for (
size_t i = 0; i < walls.size(); ++i) {
691 *mesh_uptr_list[i] += *walls[i];
694 mesh_uptr_list.insert(
695 mesh_uptr_list.end(),
696 std::make_move_iterator(walls.begin()),
697 std::make_move_iterator(walls.end()));
701 return mesh_uptr_list;
711 for (
auto &pair_map : result)
713 std::vector<std::unique_ptr<Mesh>>& origin = roads[pair_map.first];
714 std::vector<std::unique_ptr<Mesh>>& source = pair_map.second;
715 std::move(source.begin(), source.end(), std::back_inserter(origin));
721 std::vector<std::unique_ptr<Mesh>>& inout,
722 std::vector<std::string>& outinfo )
const
724 for (
auto&& lane_section :
road.GetLaneSections()) {
725 for (
auto&& lane : lane_section.GetLanes()) {
726 if (lane.first != 0) {
729 outinfo.push_back(
"white");
734 outinfo.push_back(
"yellow");
744 std::vector<std::unique_ptr<Mesh>>& inout,
745 std::vector<std::string>& )
const {
749 double s_current = s_start;
750 std::vector<geom::Vector3D> vertices;
751 std::vector<size_t> indices;
756 if (road_info_mark !=
nullptr) {
759 switch (lane_mark_info.
type) {
761 size_t currentIndex = out_mesh.
GetVertices().size() + 1;
763 std::pair<geom::Vector3D, geom::Vector3D> edges =
781 if (s_current > s_end) {
791 out_mesh.
AddIndex(currentIndex + 1);
792 out_mesh.
AddIndex(currentIndex + 2);
794 out_mesh.
AddIndex(currentIndex + 1);
795 out_mesh.
AddIndex(currentIndex + 3);
796 out_mesh.
AddIndex(currentIndex + 2);
801 size_t currentIndex = out_mesh.
GetVertices().size() + 1;
803 std::pair<geom::Vector3D, geom::Vector3D> edges =
810 if (s_current > s_end)
821 out_mesh.
AddIndex(currentIndex + 1);
822 out_mesh.
AddIndex(currentIndex + 2);
824 out_mesh.
AddIndex(currentIndex + 1);
825 out_mesh.
AddIndex(currentIndex + 3);
826 out_mesh.
AddIndex(currentIndex + 2);
870 }
while (s_current < s_end);
874 if (road_info_mark !=
nullptr) {
877 std::pair<geom::Vector3D, geom::Vector3D> edges =
883 inout.push_back(std::make_unique<Mesh>(out_mesh));
891 std::vector<std::unique_ptr<Mesh>>& inout,
892 std::vector<std::string>& )
const
897 double s_current = s_start;
898 std::vector<geom::Vector3D> vertices;
899 std::vector<size_t> indices;
904 if (road_info_mark !=
nullptr) {
907 switch (lane_mark_info.
type) {
909 size_t currentIndex = out_mesh.
GetVertices().size() + 1;
935 if (s_current > s_end) {
939 rightpoint =
road.GetDirectedPointIn(s_current);
940 leftpoint = rightpoint;
952 out_mesh.
AddIndex(currentIndex + 1);
953 out_mesh.
AddIndex(currentIndex + 2);
955 out_mesh.
AddIndex(currentIndex + 1);
956 out_mesh.
AddIndex(currentIndex + 3);
957 out_mesh.
AddIndex(currentIndex + 2);
962 size_t currentIndex = out_mesh.
GetVertices().size() + 1;
964 std::pair<geom::Vector3D, geom::Vector3D> edges =
971 if (s_current > s_end) {
981 out_mesh.
AddIndex(currentIndex + 1);
982 out_mesh.
AddIndex(currentIndex + 2);
984 out_mesh.
AddIndex(currentIndex + 1);
985 out_mesh.
AddIndex(currentIndex + 3);
986 out_mesh.
AddIndex(currentIndex + 2);
1030 }
while (s_current < s_end);
1034 if (road_info_mark !=
nullptr)
1051 inout.push_back(std::make_unique<Mesh>(out_mesh));
1077 return {neighbor_info.
vertex, 0};
1079 if(abs(distance3D) <
EPSILON) {
1080 return {neighbor_info.
vertex, 0};
1082 float weight = geom::Math::Clamp<float>(1.0f / distance3D, 0.0f, 100000.0f);
1092 return {neighbor_info.
vertex, weight};
1098 std::vector<std::unique_ptr<Mesh>> &lane_meshes) {
1101 using Point = Rtree::BPoint;
1103 for (
size_t lane_mesh_idx = 0; lane_mesh_idx < lane_meshes.size(); ++lane_mesh_idx) {
1104 auto& mesh = lane_meshes[lane_mesh_idx];
1105 for(
size_t i = 0; i < mesh->GetVerticesNum(); ++i) {
1106 auto& vertex = mesh->GetVertices()[i];
1107 Point
point(vertex.x, vertex.y, vertex.z);
1108 if (i < 2 || i >= mesh->GetVerticesNum() - 2) {
1109 rtree.InsertElement({
point, {&vertex, lane_mesh_idx,
true}});
1111 rtree.InsertElement({
point, {&vertex, lane_mesh_idx,
false}});
1117 std::vector<VertexNeighbors> vertices_neighborhoods;
1118 for (
size_t lane_mesh_idx = 0; lane_mesh_idx < lane_meshes.size(); ++lane_mesh_idx) {
1119 auto& mesh = lane_meshes[lane_mesh_idx];
1120 for(
size_t i = 0; i < mesh->GetVerticesNum(); ++i) {
1121 if (i > 2 && i < mesh->GetVerticesNum() - 2) {
1122 auto& vertex = mesh->GetVertices()[i];
1123 Point
point(vertex.x, vertex.y, vertex.z);
1124 auto closest_vertices = rtree.GetNearestNeighbours(
point, 20);
1126 vertex_neighborhood.
vertex = &vertex;
1127 for(
auto& close_vertex : closest_vertices) {
1128 auto &vertex_info = close_vertex.second;
1129 if(&vertex == vertex_info.vertex) {
1133 road_param, {&vertex, lane_mesh_idx,
false}, vertex_info);
1134 if(vertex_weight.weight > 0)
1135 vertex_neighborhood.
neighbors.push_back(vertex_weight);
1137 vertices_neighborhoods.push_back(vertex_neighborhood);
1141 return vertices_neighborhoods;
1150 auto Laplacian = [&](
const Mesh::vertex_type* vertex,
const std::vector<VertexWeight> &neighbors) ->
double {
1152 double sum_weight = 0;
1153 for(
auto &element : neighbors) {
1154 sum += (element.vertex->z - vertex->
z)*element.weight;
1155 sum_weight += element.weight;
1158 return sum / sum_weight;
1163 double lambda = 0.5;
1164 int iterations = 100;
1165 for(
int iter = 0; iter < iterations; ++iter) {
1166 for (
auto& vertex_neighborhood : vertices_neighborhoods) {
1167 auto * vertex = vertex_neighborhood.vertex;
1168 vertex->
z +=
static_cast<float>(lambda*Laplacian(vertex, vertex_neighborhood.neighbors));
1172 for(
auto &mesh : lane_meshes) {
1176 return std::make_unique<Mesh>(out_mesh);
1183 const double s_current,
1184 const double lanemark_width,
1185 const float extra_width)
const {
1186 std::pair<geom::Vector3D, geom::Vector3D> edges =
1190 if (edges.first != edges.second) {
1201 director = (edges.second - edges.first).MakeUnitVector();
1203 const std::map<road::LaneId, road::Lane> & lanes = lane_section.
GetLanes();
1204 for (
const auto& lane_pair : lanes) {
1205 std::pair<geom::Vector3D, geom::Vector3D> another_edge =
1206 lane_pair.second.GetCornerPositions(s_current, extra_width);
1207 if (another_edge.first != another_edge.second) {
1208 director = (another_edge.second - another_edge.first).MakeUnitVector();
1213 geom::Vector3D endmarking = edges.first + director *
static_cast<float>(lanemark_width);
1214 return std::make_pair(edges.first, endmarking);
#define DEBUG_ASSERT(predicate)
#define RELEASE_ASSERT(pred)
std::map< std::string, unsigned int > road
static auto Distance(const Vector3D &a, const Vector3D &b)
std::unique_ptr< Mesh > GenerateRightWall(const road::Lane &lane, const double s_start, const double s_end) const
Generates a wall-like mesh at the right side of the lane.
std::unique_ptr< Mesh > GenerateSidewalk(const road::LaneSection &lane_section) const
std::unique_ptr< Mesh > GenerateLeftWall(const road::Lane &lane, const double s_start, const double s_end) const
Generates a wall-like mesh at the left side of the lane.
std::unique_ptr< Mesh > MergeAndSmooth(std::vector< std::unique_ptr< Mesh > > &lane_meshes) const
void GenerateLaneMarksForCenterLine(const road::Road &road, const road::LaneSection &lane_section, const road::Lane &lane, std::vector< std::unique_ptr< Mesh > > &inout, std::vector< std::string > &outinfo) const
std::pair< geom::Vector3D, geom::Vector3D > ComputeEdgesForLanemark(const road::LaneSection &lane_section, const road::Lane &lane, const double s_current, const double lanemark_width, const float extra_width) const
std::vector< std::unique_ptr< Mesh > > GenerateWallsWithMaxLen(const road::Road &road) const
Generates a list of meshes that defines a road safety wall with a maximum length.
void GenerateLaneMarkForRoad(const road::Road &road, std::vector< std::unique_ptr< Mesh > > &inout, std::vector< std::string > &outinfo) const
MeshFactory(rpc::OpendriveGenerationParameters params=rpc::OpendriveGenerationParameters())
RoadParameters road_param
std::unique_ptr< Mesh > Generate(const road::Road &road) const
Generates a mesh that defines a road.
void GenerateLaneMarksForNotCenterLine(const road::LaneSection &lane_section, const road::Lane &lane, std::vector< std::unique_ptr< Mesh > > &inout, std::vector< std::string > &outinfo) const
void GenerateLaneSectionOrdered(const road::LaneSection &lane_section, std::map< carla::road::Lane::LaneType, std::vector< std::unique_ptr< Mesh > > > &result) const
Generates a mesh that defines a lane section.
std::unique_ptr< Mesh > GenerateTesselated(const road::Lane &lane, const double s_start, const double s_end) const
Generates a mesh that defines a lane from a given s start and end with bigger tesselation.
std::vector< std::unique_ptr< Mesh > > GenerateAllWithMaxLen(const road::Road &road) const
Generates a chunked road with all the features needed for simulation.
std::vector< std::unique_ptr< Mesh > > GenerateWithMaxLen(const road::Road &road) const
Generates a list of meshes that defines a road with a maximum length.
std::map< carla::road::Lane::LaneType, std::vector< std::unique_ptr< Mesh > > > GenerateOrderedWithMaxLen(const road::Road &road) const
Generates a list of meshes that defines a road with a maximum length.
std::unique_ptr< Mesh > GenerateWalls(const road::LaneSection &lane_section) const
Genrates a mesh representing a wall on the road corners to avoid cars falling down.
void GenerateAllOrderedWithMaxLen(const road::Road &road, std::map< road::Lane::LaneType, std::vector< std::unique_ptr< Mesh > > > &roads) const
Mesh data container, validator and exporter.
void AddIndex(index_type index)
Appends a index to the indexes list.
void AddVertex(vertex_type vertex)
Appends a vertex to the vertices list.
void AddVertices(const std::vector< vertex_type > &vertices)
Appends a vertex to the vertices list.
bool IsValid() const
Check if the mesh can be valid or not.
void AddUVs(const std::vector< uv_type > &uv)
Appends uvs.
void AddMaterial(const std::string &material_name)
Starts applying a new material to the new added triangles.
void EndMaterial()
Stops applying the material to the new added triangles.
void AddTriangleStrip(const std::vector< vertex_type > &vertices)
Adds a triangle strip to the mesh, vertex order is counterclockwise.
const std::vector< vertex_type > & GetVertices() const
Rtree class working with 3D point clouds.
double GetDistance() const
std::map< LaneId, Lane > & GetLanes()
bool IsStraight() const
Checks whether the geometry is straight or not.
const T * GetInfo(const double s) const
LaneType
Can be used as flags.
double GetDistance() const
std::pair< geom::Vector3D, geom::Vector3D > GetCornerPositions(const double s, const float extra_width=0.f) const
Computes the location of the edges given a s.
Each lane within a road cross section can be provided with several road markentries.
static constexpr double EPSILON
We use this epsilon to shift the waypoints away from the edges of the lane sections to avoid floating...
static VertexWeight ComputeVertexWeight(const MeshFactory::RoadParameters &road_param, const VertexInfo &vertex_info, const VertexInfo &neighbor_info)
static constexpr double MESH_EPSILON
std::vector< VertexNeighbors > GetVertexNeighborhoodAndWeights(const MeshFactory::RoadParameters &road_param, std::vector< std::unique_ptr< Mesh > > &lane_meshes)
This file contains definitions of common data structures used in traffic manager.
Parameters for the road generation.
float lane_ends_multiplier
float same_lane_weight_multiplier
float max_weight_distance
float vertex_width_resolution
Mesh::vertex_type * vertex
Mesh::vertex_type * vertex
std::vector< VertexWeight > neighbors
Mesh::vertex_type * vertex
void ApplyLateralOffset(float lateral_offset)
Seting for map generation from opendrive without additional geometry.
double vertex_width_resolution