Drake
loader.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 
6 #include "drake/automotive/maliput/api/road_geometry.h"
7 #include "drake/common/drake_copyable.h"
8 
9 namespace drake {
10 namespace maliput {
11 namespace rndf {
12 
13 /// Holds common api::RoadGeometry characteristics needed to construct one.
15  RoadCharacteristics() = default;
16 
17  /// Constructor for custom geometry characteristics.
18  /// @param default_width_in The default lane width in meters, used when either
19  /// no lane width or zero lane width was specified in the RNDF (as lane widths
20  /// are an optional non negative quantity in the RNDF format).
21  /// @param linear_tolerance_in The linear tolerance for lane geometries, in
22  /// radians.
23  /// @param angular_tolerance_in The angular tolerance for lane geometries, in
24  /// radians.
25  explicit RoadCharacteristics(double default_width_in,
26  double linear_tolerance_in,
27  double angular_tolerance_in)
28  : default_width(default_width_in),
29  linear_tolerance(linear_tolerance_in),
30  angular_tolerance(angular_tolerance_in) {}
31 
32  /// Default width for RNDF Lanes, in meters.
33  double default_width{4.};
34  /// Linear tolerance for RNDF RoadGeometry, in radians.
35  double linear_tolerance{0.01};
36  /// Angular tolerance for RNDF RoadGeometry, in radians.
37  double angular_tolerance{0.01 * M_PI};
38 };
39 
40 /// Loads a given RNDF at @p filepath and builds an equivalent
41 /// api::RoadGeometry with the given @p road_characteristics.
42 ///
43 /// RNDF waypoints are given in UTM (latitude / longitude) coordinates.
44 /// In the resulting api::RoadGeometry, they are mapped to ENU (Cartesian)
45 /// coordinates whose origin coincides with the location of waypoint '1.1.1'.
46 /// Note that due to the planar nature of the underlying api::RoadGeometry
47 /// implementation, the elevation coordinate will be forced to 0.
48 ///
49 /// @param filepath The RNDF path.
50 /// @param road_characteristics The common geometrical aspects to comply with
51 /// when building the api::RoadGeometry.
52 /// @return The built api::RoadGeometry.
53 /// @throw std::runtime_error When the given file is not a valid RNDF.
54 /// @throw std::runtime_error When the given RNDF doesn't have at least
55 /// a single lane segment with one or more waypoints. RNDFs containing
56 /// only zones are not supported.
57 std::unique_ptr<const api::RoadGeometry> LoadFile(
58  const std::string& filepath,
59  const RoadCharacteristics& road_characteristics);
60 
61 /// Loads a given RNDF at @p filepath and builds an equivalent
62 /// api::RoadGeometry.using default RoadCharacteristics.
63 ///
64 /// This is an overloaded function provided for convenience. See
65 /// LoadFile(const std::string&, const RoadCharacteristics&).
66 std::unique_ptr<const api::RoadGeometry> LoadFile(
67  const std::string& filepath);
68 
69 } // namespace rndf
70 } // namespace maliput
71 } // namespace drake
RoadCharacteristics(double default_width_in, double linear_tolerance_in, double angular_tolerance_in)
Constructor for custom geometry characteristics.
Definition: loader.h:25
Definition: automotive_demo.cc:89
Definition: branch_point.cc:7
Holds common api::RoadGeometry characteristics needed to construct one.
Definition: loader.h:14
double default_width
Default width for RNDF Lanes, in meters.
Definition: loader.h:33
double angular_tolerance
Angular tolerance for RNDF RoadGeometry, in radians.
Definition: loader.h:37
std::unique_ptr< const api::RoadGeometry > LoadFile(const std::string &filepath)
Loads a given RNDF at filepath and builds an equivalent api::RoadGeometry.using default RoadCharacter...
Definition: loader.cc:225
double linear_tolerance
Linear tolerance for RNDF RoadGeometry, in radians.
Definition: loader.h:35