CARLA
 
载入中...
搜索中...
未找到
MeshFactory.h
浏览该文件的文档.
1// Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include <memory>
10#include <vector>
11
12#include <carla/geom/Mesh.h>
13#include <carla/road/Road.h>
15#include <carla/road/Lane.h>
17
18namespace carla {
19namespace geom {
20
21 /// Mesh helper generator
23 public:
24
27
28 // =========================================================================
29 // -- Map Related ----------------------------------------------------------
30 // =========================================================================
31
32 // -- Basic --
33
34 /// Generates a mesh that defines a road
35 std::unique_ptr<Mesh> Generate(const road::Road &road) const;
36
37 /// Generates a mesh that defines a lane section
38 std::unique_ptr<Mesh> Generate(const road::LaneSection &lane_section) const;
39
40 /// Generates a mesh that defines a lane from a given s start and end
41 std::unique_ptr<Mesh> Generate(
42 const road::Lane &lane, const double s_start, const double s_end) const;
43
44 /// Generates a mesh that defines a lane from a given s start and end with bigger tesselation
45 std::unique_ptr<Mesh> GenerateTesselated(
46 const road::Lane& lane, const double s_start, const double s_end) const;
47
48 /// Generates a mesh that defines the whole lane
49 std::unique_ptr<Mesh> Generate(const road::Lane &lane) const;
50
51 /// Generates a mesh that defines the whole lane with bigger tesselation
52 std::unique_ptr<Mesh> GenerateTesselated(const road::Lane& lane) const;
53
54 /// Generates a mesh that defines a lane section
55 void GenerateLaneSectionOrdered(const road::LaneSection &lane_section,
56 std::map<carla::road::Lane::LaneType , std::vector<std::unique_ptr<Mesh>>>& result ) const;
57
58 std::unique_ptr<Mesh> GenerateSidewalk(const road::LaneSection &lane_section) const;
59 std::unique_ptr<Mesh> GenerateSidewalk(const road::Lane &lane) const;
60 std::unique_ptr<Mesh> GenerateSidewalk(const road::Lane &lane, const double s_start, const double s_end) const;
61 // -- Walls --
62
63 /// Genrates a mesh representing a wall on the road corners to avoid
64 /// cars falling down
65 std::unique_ptr<Mesh> GenerateWalls(const road::LaneSection &lane_section) const;
66
67 /// Generates a wall-like mesh at the right side of the lane
68 std::unique_ptr<Mesh> GenerateRightWall(
69 const road::Lane &lane, const double s_start, const double s_end) const;
70
71 /// Generates a wall-like mesh at the left side of the lane
72 std::unique_ptr<Mesh> GenerateLeftWall(
73 const road::Lane &lane, const double s_start, const double s_end) const;
74
75 // -- Chunked --
76
77 /// Generates a list of meshes that defines a road with a maximum length
78 std::vector<std::unique_ptr<Mesh>> GenerateWithMaxLen(
79 const road::Road &road) const;
80
81 /// Generates a list of meshes that defines a lane_section with a maximum length
82 std::vector<std::unique_ptr<Mesh>> GenerateWithMaxLen(
83 const road::LaneSection &lane_section) const;
84
85 /// Generates a list of meshes that defines a road with a maximum length
86 std::map<carla::road::Lane::LaneType , std::vector<std::unique_ptr<Mesh>>> GenerateOrderedWithMaxLen(
87 const road::Road &road) const;
88
89 /// Generates a list of meshes that defines a lane_section with a maximum length
90 std::map<carla::road::Lane::LaneType , std::vector<std::unique_ptr<Mesh>>> GenerateOrderedWithMaxLen(
91 const road::LaneSection &lane_section) const;
92
93 /// Generates a list of meshes that defines a road safety wall with a maximum length
94 std::vector<std::unique_ptr<Mesh>> GenerateWallsWithMaxLen(
95 const road::Road &road) const;
96
97 /// Generates a list of meshes that defines a lane_section safety wall with a maximum length
98 std::vector<std::unique_ptr<Mesh>> GenerateWallsWithMaxLen(
99 const road::LaneSection &lane_section) const;
100
101 // -- Util --
102
103 /// Generates a chunked road with all the features needed for simulation
104 std::vector<std::unique_ptr<Mesh>> GenerateAllWithMaxLen(
105 const road::Road &road) const;
106
107
109 std::map<road::Lane::LaneType , std::vector<std::unique_ptr<Mesh>>>& roads) const;
110
111 std::unique_ptr<Mesh> MergeAndSmooth(std::vector<std::unique_ptr<Mesh>> &lane_meshes) const;
112
113 // -- LaneMarks --
114 void GenerateLaneMarkForRoad(const road::Road& road,
115 std::vector<std::unique_ptr<Mesh>>& inout,
116 std::vector<std::string>& outinfo ) const;
117
118 // Generate for NOT center line AKA All lines but the one which id 0
120 const road::LaneSection& lane_section,
121 const road::Lane& lane,
122 std::vector<std::unique_ptr<Mesh>>& inout,
123 std::vector<std::string>& outinfo ) const;
124
125 // Generate marks ONLY for line with ID 0
127 const road::Road& road,
128 const road::LaneSection& lane_section,
129 const road::Lane& lane,
130 std::vector<std::unique_ptr<Mesh>>& inout,
131 std::vector<std::string>& outinfo ) const;
132
133 // =========================================================================
134 // -- Generation parameters ------------------------------------------------
135 // =========================================================================
136
137 /// Parameters for the road generation
139 float resolution = 2.0f;
140 float max_road_len = 50.0f;
141 float extra_lane_width = 1.0f;
142 float wall_height = 0.6f;
144 // Road mesh smoothness:
148 };
149
151
152
153 // =========================================================================
154 // -- Helper functions ------------------------------------------------
155 // =========================================================================
156
157 static uint32_t SelectVerticesInWidth(uint32_t default_num_vertices, road::Lane::LaneType type);
158 private:
159
160 // Calculate the points on both sides of the lane mark for the specified s_current
161 std::pair<geom::Vector3D, geom::Vector3D> ComputeEdgesForLanemark(
162 const road::LaneSection& lane_section,
163 const road::Lane& lane,
164 const double s_current,
165 const double lanemark_width) const;
166
167 };
168
169} // namespace geom
170} // namespace carla
Mesh helper generator
Definition MeshFactory.h:22
static uint32_t SelectVerticesInWidth(uint32_t default_num_vertices, road::Lane::LaneType type)
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
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
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::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
LaneType
Can be used as flags
Definition Lane.h:29
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
Parameters for the road generation
Seting for map generation from opendrive without additional geometry