CARLA
MeshFactory.h
Go to the documentation of this file.
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>
14 #include <carla/road/LaneSection.h>
15 #include <carla/road/Lane.h>
17 
18 namespace carla {
19 namespace geom {
20 
21  /// Mesh helper generator
22  class MeshFactory {
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 the whole lane
45  std::unique_ptr<Mesh> Generate(const road::Lane &lane) const;
46 
47  // -- Walls --
48 
49  /// Genrates a mesh representing a wall on the road corners to avoid
50  /// cars falling down
51  std::unique_ptr<Mesh> GenerateWalls(const road::LaneSection &lane_section) const;
52 
53  /// Generates a wall-like mesh at the right side of the lane
54  std::unique_ptr<Mesh> GenerateRightWall(
55  const road::Lane &lane, const double s_start, const double s_end) const;
56 
57  /// Generates a wall-like mesh at the left side of the lane
58  std::unique_ptr<Mesh> GenerateLeftWall(
59  const road::Lane &lane, const double s_start, const double s_end) const;
60 
61  // -- Chunked --
62 
63  /// Generates a list of meshes that defines a road with a maximum length
64  std::vector<std::unique_ptr<Mesh>> GenerateWithMaxLen(
65  const road::Road &road) const;
66 
67  /// Generates a list of meshes that defines a lane_section with a maximum length
68  std::vector<std::unique_ptr<Mesh>> GenerateWithMaxLen(
69  const road::LaneSection &lane_section) const;
70 
71  /// Generates a list of meshes that defines a road safety wall with a maximum length
72  std::vector<std::unique_ptr<Mesh>> GenerateWallsWithMaxLen(
73  const road::Road &road) const;
74 
75  /// Generates a list of meshes that defines a lane_section safety wall with a maximum length
76  std::vector<std::unique_ptr<Mesh>> GenerateWallsWithMaxLen(
77  const road::LaneSection &lane_section) const;
78 
79  // -- Util --
80 
81  /// Generates a chunked road with all the features needed for simulation
82  std::vector<std::unique_ptr<Mesh>> GenerateAllWithMaxLen(
83  const road::Road &road) const;
84 
85  std::unique_ptr<Mesh> MergeAndSmooth(std::vector<std::unique_ptr<Mesh>> &lane_meshes) const;
86 
87  // =========================================================================
88  // -- Generation parameters ------------------------------------------------
89  // =========================================================================
90 
91  /// Parameters for the road generation
92  struct RoadParameters {
93  float resolution = 2.0f;
94  float max_road_len = 50.0f;
95  float extra_lane_width = 1.0f;
96  float wall_height = 0.6f;
97  // Road mesh smoothness:
98  float max_weight_distance = 5.0f;
100  float lane_ends_multiplier = 2.0f;
101  };
102 
104 
105  };
106 
107 } // namespace geom
108 } // namespace carla
Seting for map generation from opendrive without additional geometry.
Mesh helper generator.
Definition: MeshFactory.h:22
std::unique_ptr< Mesh > Generate(const road::Road &road) const
Generates a mesh that defines a road.
Definition: MeshFactory.cpp:29
std::unique_ptr< Mesh > MergeAndSmooth(std::vector< std::unique_ptr< Mesh >> &lane_meshes) const
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.
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:99
RoadParameters road_param
Definition: MeshFactory.h:103
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.
MeshFactory(rpc::OpendriveGenerationParameters params=rpc::OpendriveGenerationParameters())
Definition: MeshFactory.cpp:17
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 > GenerateWalls(const road::LaneSection &lane_section) const
Genrates a mesh representing a wall on the road corners to avoid cars falling down.
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. ...
std::vector< std::unique_ptr< Mesh > > GenerateAllWithMaxLen(const road::Road &road) const
Generates a chunked road with all the features needed for simulation.
Parameters for the road generation.
Definition: MeshFactory.h:92