Drake
builder.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 #include <string>
6 #include <utility>
7 #include <vector>
8 
9 #include "ignition/math/Spline.hh"
10 #include "ignition/math/Vector3.hh"
11 
18 
19 namespace drake {
20 namespace maliput {
21 namespace rndf {
22 
125 class Builder {
126  public:
128 
129 
130  Builder(double linear_tolerance, double angular_tolerance)
135  : linear_tolerance_(linear_tolerance),
136  angular_tolerance_(angular_tolerance) {}
137 
146  void SetBoundingBox(const std::pair<ignition::math::Vector3d,
147  ignition::math::Vector3d>& bounding_box) {
148  bounding_box_ = bounding_box;
149  }
150 
164  void CreateSegmentConnections(int segment_id,
165  std::vector<Connection>* connections);
166 
183  double width, std::vector<DirectedWaypoint>* perimeter_waypoints);
184 
193  void CreateConnection(double width, const ignition::rndf::UniqueId& exit_id,
194  const ignition::rndf::UniqueId& entry_id);
195 
205  std::unique_ptr<const api::RoadGeometry> Build(const api::RoadGeometryId& id);
206 
207  private:
208  // Inserts a connection of the given @p width, with the given @p key_id, using
209  // the given @p waypoints to the inner connection map.
210  // @pre The given @p waypoints collection size must be at least two (2).
211  // @warning This method will abort if preconditions are not met.
212  void InsertConnection(const std::string& key_id, double width,
213  const std::vector<DirectedWaypoint>& waypoints);
214 
215  // The tolerance used by the RoadGeometry to check linear invariants.
216  const double linear_tolerance_{};
217  // The tolerance used by the RoadGeometry to check angular invariants.
218  const double angular_tolerance_{};
219  // A map to hold all the connections while they are created.
220  std::map<std::string, std::vector<std::unique_ptr<Connection>>> connections_;
221  // A map to hold all the DirectedWaypoints that are used as Lane extents.
222  std::map<std::string, DirectedWaypoint> directed_waypoints_;
223  // The coordinates of the bounding box that encloses RNDF's waypoints.
224  std::pair<ignition::math::Vector3d, ignition::math::Vector3d> bounding_box_;
225 };
226 
227 } // namespace rndf
228 } // namespace maliput
229 } // namespace drake
void CreateConnectionsForZones(double width, std::vector< DirectedWaypoint > *perimeter_waypoints)
Creates a collection of Connection objects between every pair of entry and exit waypoints in perimete...
Definition: builder.cc:590
void CreateSegmentConnections(int segment_id, std::vector< Connection > *connections)
Populates the Builder&#39;s inner connection map with the given connections representing an RNDF segment...
Definition: builder.cc:623
Definition: automotive_demo.cc:88
A class to ease the construction of a RoadGeometry from Connection and DirectedWaypoint objects...
Definition: builder.h:125
void SetBoundingBox(const std::pair< ignition::math::Vector3d, ignition::math::Vector3d > &bounding_box)
Sets the bounding box of the RNDF map.
Definition: builder.h:146
void CreateConnection(double width, const ignition::rndf::UniqueId &exit_id, const ignition::rndf::UniqueId &entry_id)
Creates a connection between two RNDF lanes based on a pair of exit and entry ids that map to specifi...
Definition: builder.cc:576
std::unique_ptr< const api::RoadGeometry > Build(const api::RoadGeometryId &id)
Builds an api::RoadGeometry.
Definition: builder.cc:674
TypeSpecificIdentifier< class RoadGeometry > RoadGeometryId
Persistent identifier for a RoadGeometry element.
Definition: road_geometry.h:19
Builder(const Builder &)=delete
#define DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:35
Provides careful macros to selectively enable or disable the special member functions for copy-constr...