Drake
speed_limit_rule.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace drake {
8 namespace maliput {
9 namespace api {
10 namespace rules {
11 
12 /// Rule describing speed limits.
13 ///
14 /// Each rule instance describes speed limits applied to a longitudinal
15 /// portion of a Lane (which may be the entire length of the Lane). Each
16 /// instance is tagged with a severity; multiple instances with different
17 /// severities may apply to the same region of the road network.
18 ///
19 /// Each instance mandates a maximum speed limit as well as a minimum
20 /// speed limit. Since neither limit may be less than zero, a minimum
21 /// limit of exactly zero is equivalent to having no minimum limit at all.
23  public:
25 
26  /// Severity classification.
27  enum class Severity {
28  kStrict = 0, ///< A strict limit is the established mandatory limit.
29  kAdvisory ///< An advisory limit is a recommendation, typically
30  /// reflecting a road condition (e.g., a sharp curve).
31  };
32 
34 
35  /// Constructs a SpeedLimitRule.
36  ///
37  /// @param id the unique ID of this rule (in the RoadRulebook)
38  /// @param zone LaneSRange to which this rule applies
39  /// @param severity Severity of the rule
40  /// @param min minimum speed
41  /// @param max maximum speed
42  ///
43  /// `min` and `max` must be non-negative, and `min` must be less than
44  /// or equal to `max`, otherwise a runtime_error is thrown.
46  double min, double max)
47  : id_(id), zone_(zone), severity_(severity), min_(min), max_(max) {
48  DRAKE_THROW_UNLESS(min >= 0.);
49  DRAKE_THROW_UNLESS(max >= 0.);
50  DRAKE_THROW_UNLESS(min <= max);
51  }
52 
53  /// Returns the persistent identifier.
54  Id id() const { return id_; }
55 
56  /// Returns the zone to which this rule instance applies.
57  const LaneSRange& zone() const { return zone_; }
58 
59  /// Returns the severity of this rule instance.
60  Severity severity() const { return severity_; }
61 
62  /// Returns the minimum limit.
63  double min() const { return min_; }
64 
65  /// Returns the maximum limit.
66  double max() const { return max_; }
67 
68  private:
69  Id id_;
70  LaneSRange zone_;
71  Severity severity_{};
72  double min_{};
73  double max_{};
74  // TODO(maddog@tri.global) Capture applicable vehicle types (e.g., 'trucks').
75  // TODO(maddog@tri.global) Capture time-of-day aspect (e.g., 'night only')
76 };
77 
78 } // namespace rules
79 } // namespace api
80 } // namespace maliput
81 } // namespace drake
SpeedLimitRule(const Id &id, const LaneSRange &zone, Severity severity, double min, double max)
Constructs a SpeedLimitRule.
Definition: speed_limit_rule.h:45
Definition: bullet_model.cc:22
Id id() const
Returns the persistent identifier.
Definition: speed_limit_rule.h:54
double min() const
Returns the minimum limit.
Definition: speed_limit_rule.h:63
Severity severity() const
Returns the severity of this rule instance.
Definition: speed_limit_rule.h:60
Rule describing speed limits.
Definition: speed_limit_rule.h:22
const LaneSRange & zone() const
Returns the zone to which this rule instance applies.
Definition: speed_limit_rule.h:57
#define DRAKE_THROW_UNLESS(condition)
Evaluates condition and iff the value is false will throw an exception with a message showing at leas...
Definition: drake_throw.h:23
A strict limit is the established mandatory limit.
#define DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Classname)
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN defaults the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:57
Directed longitudinal range of a specific Lane, identified by a LaneId.
Definition: regions.h:45
double max() const
Returns the maximum limit.
Definition: speed_limit_rule.h:66
An advisory limit is a recommendation, typically reflecting a road condition (e.g., a sharp curve).
Severity
Severity classification.
Definition: speed_limit_rule.h:27
Provides careful macros to selectively enable or disable the special member functions for copy-constr...