Drake
directed_waypoint.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utility>
4 #include <vector>
5 
6 #include "ignition/math/Vector3.hh"
7 #include "ignition/rndf/UniqueId.hh"
8 
10 
11 namespace drake {
12 namespace maliput {
13 namespace rndf {
14 
15 /// A container that holds the information needed by a Builder to construct a
16 /// Lane from a sequence of ignition::rndf::Waypoint objects.
18  public:
20 
21  /// Default constructor.
22  /// All the class attributes will be set with default values. Consequently,
23  /// the id will be initialized with an invalid ignition::rndf::UniqueId (-1,
24  /// -1, -1), position and tangent will be zero 3D vectors and, is_entry() and
25  /// is_exit() will be false.
26  DirectedWaypoint() = default;
27 
28  /// Constructor.
29  /// @param id RNDF waypoint's ID. It may be generated by the Builder or a copy
30  /// of what has been parsed by ignition::rndf::RNDF.
31  /// @param position The 3D coordinates of the knot in the api::GeoPosition
32  /// frame.
33  /// @param tangent The tangent vector at @p position in the api::GeoPosition
34  /// frame.
35  /// @param is_entry True if the original RNDF waypoint acts as the entry for
36  /// the RNDF lane.
37  /// @param is_exit True if the original RNDF waypoint acts as the exit for the
38  /// RNDF lane.
39  DirectedWaypoint(const ignition::rndf::UniqueId& id,
40  const ignition::math::Vector3d& position,
41  const ignition::math::Vector3d& tangent, bool is_entry,
42  bool is_exit)
43  : id_(id),
44  position_(position),
45  tangent_(tangent),
46  is_entry_(is_entry),
47  is_exit_(is_exit) {}
48 
49  const ignition::rndf::UniqueId& id() const { return id_; }
50 
51  void set_id(const ignition::rndf::UniqueId& id) { id_ = id; }
52 
53  const ignition::math::Vector3d& position() const { return position_; }
54 
55  void set_position(const ignition::math::Vector3d& position) {
56  position_ = position;
57  }
58 
59  const ignition::math::Vector3d& tangent() const { return tangent_; }
60 
61  void set_tangent(const ignition::math::Vector3d& tangent) {
62  tangent_ = tangent;
63  }
64 
65  bool is_entry() const { return is_entry_; }
66 
67  void set_is_entry(bool is_entry) { is_entry_ = is_entry; }
68 
69  bool is_exit() const { return is_exit_; }
70 
71  void set_is_exit(bool is_exit) { is_exit_ = is_exit; }
72 
73  /// Gets the bounding box of a vector of @p directed_waypoints. It
74  /// gets the minimum and maximum x and y coordinates from all the items.
75  /// z coordinate will always be zero as RNDF is a flat map.
76  /// @param directed_waypoints A vector of DirectedWaypoints whose positions
77  /// are evaluated to define the corners of a bounding box that holds them.
78  /// @return A std::pair that holds two diagonal corners of the bounding box
79  /// that encloses @p directed_waypoints. The pair's first value is the
80  /// minimum x and y coordinate and the second value is the maximum x and y
81  /// coordinate. When @p directed_waypoints is an empty vector, the returned
82  /// pair are both zero vectors.
83  static std::pair<ignition::math::Vector3d, ignition::math::Vector3d>
84  CalculateBoundingBox(const std::vector<DirectedWaypoint>& directed_waypoints);
85 
86  private:
87  // TODO(@agalbachicar) Uniqueness of the id_, when it is valid, should be
88  // verified and guaranteed.
89  // The ID.
90  ignition::rndf::UniqueId id_;
91  // A 3D vector which is the coordinate of the waypoint in the api::GeoPosition
92  // frame.
93  ignition::math::Vector3d position_;
94  // A 3D vector which is the tangent of the waypoint at position_.
95  ignition::math::Vector3d tangent_;
96  // Tells whether or not the original RNDF waypoint acts as an entry for the
97  // RNDF lane.
98  bool is_entry_{false};
99  // Tells whether or not the original RNDF waypoint acts as an exit for the
100  // RNDF lane.
101  bool is_exit_{false};
102 };
103 
104 } // namespace rndf
105 } // namespace maliput
106 } // namespace drake
DirectedWaypoint()=default
Default constructor.
DirectedWaypoint(const ignition::rndf::UniqueId &id, const ignition::math::Vector3d &position, const ignition::math::Vector3d &tangent, bool is_entry, bool is_exit)
Constructor.
Definition: directed_waypoint.h:39
void set_is_entry(bool is_entry)
Definition: directed_waypoint.h:67
Definition: automotive_demo.cc:88
static std::pair< ignition::math::Vector3d, ignition::math::Vector3d > CalculateBoundingBox(const std::vector< DirectedWaypoint > &directed_waypoints)
Gets the bounding box of a vector of directed_waypoints.
Definition: directed_waypoint.cc:11
void set_is_exit(bool is_exit)
Definition: directed_waypoint.h:71
bool is_exit() const
Definition: directed_waypoint.h:69
Definition: branch_point.cc:7
A container that holds the information needed by a Builder to construct a Lane from a sequence of ign...
Definition: directed_waypoint.h:17
void set_position(const ignition::math::Vector3d &position)
Definition: directed_waypoint.h:55
bool is_entry() const
Definition: directed_waypoint.h:65
#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
const ignition::math::Vector3d & position() const
Definition: directed_waypoint.h:53
void set_tangent(const ignition::math::Vector3d &tangent)
Definition: directed_waypoint.h:61
const ignition::math::Vector3d & tangent() const
Definition: directed_waypoint.h:59
const ignition::rndf::UniqueId & id() const
Definition: directed_waypoint.h:49
Provides careful macros to selectively enable or disable the special member functions for copy-constr...
void set_id(const ignition::rndf::UniqueId &id)
Definition: directed_waypoint.h:51