CARLA
SimpleWaypoint.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.h>
10 
11 #include "carla/client/Waypoint.h"
12 #include "carla/geom/Location.h"
13 #include "carla/geom/Transform.h"
14 #include "carla/geom/Vector3D.h"
15 #include "carla/Memory.h"
16 #include "carla/road/RoadTypes.h"
17 
18 namespace carla {
19 namespace traffic_manager {
20 
21  namespace cc = carla::client;
22  namespace cg = carla::geom;
25 
26  /// This is a simple wrapper class on Carla's waypoint object.
27  /// The class is used to represent discrete samples of the world map.
29 
30  using SimpleWaypointPtr = std::shared_ptr<SimpleWaypoint>;
31 
32  private:
33 
34  /// Pointer to Carla's waypoint object around which this class wraps around.
36  /// List of pointers to next connecting waypoints.
37  std::vector<SimpleWaypointPtr> next_waypoints;
38  /// List of pointers to previous connecting waypoints.
39  std::vector<SimpleWaypointPtr> previous_waypoints;
40  /// Pointer to left lane change waypoint.
42  /// Pointer to right lane change waypoint.
44  /// Integer placing the waypoint into a geodesic grid.
46  // Boolean to hold if the waypoint belongs to a junction
47  bool _is_junction = false;
48 
49  public:
50 
51  SimpleWaypoint(WaypointPtr _waypoint);
53 
54  /// Returns the location object for this waypoint.
55  cg::Location GetLocation() const;
56 
57  /// Returns a carla::shared_ptr to carla::waypoint.
58  WaypointPtr GetWaypoint() const;
59 
60  /// Returns the list of next waypoints.
61  std::vector<SimpleWaypointPtr> GetNextWaypoint() const;
62 
63  /// Returns the list of previous waypoints.
64  std::vector<SimpleWaypointPtr> GetPreviousWaypoint() const;
65 
66  /// Returns the vector along the waypoint's direction.
68 
69  /// Returns the unique id for the waypoint.
70  uint64_t GetId() const;
71 
72  /// This method is used to set the next waypoints.
73  uint64_t SetNextWaypoint(const std::vector<SimpleWaypointPtr> &next_waypoints);
74 
75  /// This method is used to set the previous waypoints.
76  uint64_t SetPreviousWaypoint(const std::vector<SimpleWaypointPtr> &next_waypoints);
77 
78  /// This method is used to set the closest left waypoint for a lane change.
79  void SetLeftWaypoint(SimpleWaypointPtr &waypoint);
80 
81  /// This method is used to set the closest right waypoint for a lane change.
82  void SetRightWaypoint(SimpleWaypointPtr &waypoint);
83 
84  /// This method is used to get the closest left waypoint for a lane change.
86 
87  /// This method is used to get the closest right waypoint for a lane change.
89 
90  /// Accessor methods for geodesic grid id.
91  void SetGeodesicGridId(GeoGridId _geodesic_grid_id);
93 
94  /// Method to retreive junction id of the waypoint.
95  GeoGridId GetJunctionId() const;
96 
97  /// Calculates the distance from the object's waypoint to the passed
98  /// location.
99  float Distance(const cg::Location &location) const;
100 
101  /// Calculates the distance the other SimpleWaypoint object.
102  float Distance(const SimpleWaypointPtr &other) const;
103 
104  /// Calculates the square of the distance to given location.
105  float DistanceSquared(const cg::Location &location) const;
106 
107  /// Calculates the square of the distance to other waypoints.
108  float DistanceSquared(const SimpleWaypointPtr &other) const;
109 
110  /// Returns true if the object's waypoint belongs to an intersection.
111  bool CheckJunction() const;
112 
113  /// This method is used to set whether the waypoint belongs to a junction.
114  void SetIsJunction(bool value);
115 
116  /// Returns true if the object's waypoint belongs to an intersection (Doesn't use OpenDrive).
117  bool CheckIntersection() const;
118 
119  /// Return transform object for the current waypoint.
120  cg::Transform GetTransform() const;
121  };
122 
123 } // namespace traffic_manager
124 } // namespace carla
void SetIsJunction(bool value)
This method is used to set whether the waypoint belongs to a junction.
SimpleWaypointPtr next_right_waypoint
Pointer to right lane change waypoint.
uint64_t SetNextWaypoint(const std::vector< SimpleWaypointPtr > &next_waypoints)
This method is used to set the next waypoints.
SimpleWaypointPtr next_left_waypoint
Pointer to left lane change waypoint.
cg::Vector3D GetForwardVector() const
Returns the vector along the waypoint&#39;s direction.
void SetLeftWaypoint(SimpleWaypointPtr &waypoint)
This method is used to set the closest left waypoint for a lane change.
WaypointPtr waypoint
Pointer to Carla&#39;s waypoint object around which this class wraps around.
float DistanceSquared(const cg::Location &location) const
Calculates the square of the distance to given location.
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
Definition: Memory.h:20
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:99
SimpleWaypointPtr GetRightWaypoint()
This method is used to get the closest right waypoint for a lane change.
int32_t JuncId
Definition: RoadTypes.h:17
carla::SharedPtr< cc::Waypoint > WaypointPtr
Definition: InMemoryMap.h:35
std::vector< SimpleWaypointPtr > GetPreviousWaypoint() const
Returns the list of previous waypoints.
bool CheckJunction() const
Returns true if the object&#39;s waypoint belongs to an intersection.
std::vector< SimpleWaypointPtr > previous_waypoints
List of pointers to previous connecting waypoints.
uint64_t GetId() const
Returns the unique id for the waypoint.
This is a simple wrapper class on Carla&#39;s waypoint object.
uint64_t SetPreviousWaypoint(const std::vector< SimpleWaypointPtr > &next_waypoints)
This method is used to set the previous waypoints.
bool CheckIntersection() const
Returns true if the object&#39;s waypoint belongs to an intersection (Doesn&#39;t use OpenDrive).
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr
cg::Transform GetTransform() const
Return transform object for the current waypoint.
crd::JuncId GeoGridId
Definition: InMemoryMap.h:38
GeoGridId GetJunctionId() const
Method to retreive junction id of the waypoint.
std::vector< SimpleWaypointPtr > GetNextWaypoint() const
Returns the list of next waypoints.
cg::Location GetLocation() const
Returns the location object for this waypoint.
float Distance(const cg::Location &location) const
Calculates the distance from the object&#39;s waypoint to the passed location.
SimpleWaypointPtr GetLeftWaypoint()
This method is used to get the closest left waypoint for a lane change.
std::vector< SimpleWaypointPtr > next_waypoints
List of pointers to next connecting waypoints.
void SetRightWaypoint(SimpleWaypointPtr &waypoint)
This method is used to set the closest right waypoint for a lane change.
void SetGeodesicGridId(GeoGridId _geodesic_grid_id)
Accessor methods for geodesic grid id.
WaypointPtr GetWaypoint() const
Returns a carla::shared_ptr to carla::waypoint.
GeoGridId geodesic_grid_id
Integer placing the waypoint into a geodesic grid.