CARLA
Loading...
Searching...
No Matches
SimpleWaypoint.h
Go to the documentation of this file.
1// Copyright (c) 2026 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
12#include "carla/geom/Location.h"
14#include "carla/geom/Vector3D.h"
15#include "carla/Memory.h"
17
18namespace carla {
19namespace traffic_manager {
20
21 namespace cc = carla::client;
22 namespace cg = carla::geom;
25 enum class RoadOption : uint8_t {
26 Void = 0,
27 Left = 1,
28 Right = 2,
29 Straight = 3,
30 LaneFollow = 4,
33 RoadEnd = 7
34 };
35
36 /// This is a simple wrapper class on Carla's waypoint object.
37 /// The class is used to represent discrete samples of the world map.
39
40 using SimpleWaypointPtr = std::shared_ptr<SimpleWaypoint>;
41
42 private:
43
44 /// Pointer to Carla's waypoint object around which this class wraps around.
46 /// List of pointers to next connecting waypoints.
47 std::vector<SimpleWaypointPtr> next_waypoints;
48 /// List of pointers to previous connecting waypoints.
49 std::vector<SimpleWaypointPtr> previous_waypoints;
50 /// Pointer to left lane change waypoint.
52 /// Pointer to right lane change waypoint.
54 /// RoadOption for the actual waypoint.
56 /// Integer placing the waypoint into a geodesic grid.
58 // Boolean to hold if the waypoint belongs to a junction
59 bool _is_junction = false;
60
61 public:
62
63 SimpleWaypoint(WaypointPtr _waypoint);
65
66 /// Returns the location object for this waypoint.
68
69 /// Returns a carla::shared_ptr to carla::waypoint.
71
72 /// Returns the list of next waypoints.
73 std::vector<SimpleWaypointPtr> GetNextWaypoint() const;
74
75 /// Returns the list of previous waypoints.
76 std::vector<SimpleWaypointPtr> GetPreviousWaypoint() const;
77
78 /// Returns the vector along the waypoint's direction.
80
81 /// Returns the unique id for the waypoint.
82 uint64_t GetId() const;
83
84 /// This method is used to set the next waypoints.
85 uint64_t SetNextWaypoint(const std::vector<SimpleWaypointPtr> &next_waypoints);
86
87 /// This method is used to set the previous waypoints.
88 uint64_t SetPreviousWaypoint(const std::vector<SimpleWaypointPtr> &next_waypoints);
89
90 /// This method is used to set the closest left waypoint for a lane change.
92
93 /// This method is used to set the closest right waypoint for a lane change.
95
96 /// Drops the links to the neighbouring waypoints (next, previous, left and
97 /// right). They are shared pointers that point at each other, so a graph of
98 /// waypoints is freed only once they are dropped.
99 void ClearLinks();
100
101 /// This method is used to get the closest left waypoint for a lane change.
103
104 /// This method is used to get the closest right waypoint for a lane change.
106
107 /// Accessor methods for geodesic grid id.
108 void SetGeodesicGridId(GeoGridId _geodesic_grid_id);
110
111 /// Method to retreive junction id of the waypoint.
112 GeoGridId GetJunctionId() const;
113
114 /// Calculates the distance from the object's waypoint to the passed
115 /// location.
116 float Distance(const cg::Location &location) const;
117
118 /// Calculates the distance the other SimpleWaypoint object.
119 float Distance(const SimpleWaypointPtr &other) const;
120
121 /// Calculates the square of the distance to given location.
122 float DistanceSquared(const cg::Location &location) const;
123
124 /// Calculates the square of the distance to other waypoints.
125 float DistanceSquared(const SimpleWaypointPtr &other) const;
126
127 /// Returns true if the object's waypoint belongs to an intersection.
128 bool CheckJunction() const;
129
130 /// This method is used to set whether the waypoint belongs to a junction.
131 void SetIsJunction(bool value);
132
133 /// Returns true if the object's waypoint belongs to an intersection (Doesn't use OpenDrive).
134 bool CheckIntersection() const;
135
136 /// Return transform object for the current waypoint.
138
139 // Accessor methods for road option.
140 void SetRoadOption(RoadOption _road_option);
142 };
143
144} // namespace traffic_manager
145} // namespace carla
A rigid transform in CARLA's / Unreal's left-handed frame: x forward, y right, z up,...
This is a simple wrapper class on Carla's waypoint object.
std::vector< SimpleWaypointPtr > previous_waypoints
List of pointers to previous connecting waypoints.
bool CheckIntersection() const
Returns true if the object's waypoint belongs to an intersection (Doesn't use OpenDrive).
uint64_t SetNextWaypoint(const std::vector< SimpleWaypointPtr > &next_waypoints)
This method is used to set the next waypoints.
GeoGridId GetJunctionId() const
Method to retreive junction id of the waypoint.
void SetLeftWaypoint(SimpleWaypointPtr &waypoint)
This method is used to set the closest left waypoint for a lane change.
std::vector< SimpleWaypointPtr > GetNextWaypoint() const
Returns the list of next waypoints.
void SetRightWaypoint(SimpleWaypointPtr &waypoint)
This method is used to set the closest right waypoint for a lane change.
SimpleWaypointPtr next_left_waypoint
Pointer to left lane change waypoint.
WaypointPtr waypoint
Pointer to Carla's waypoint object around which this class wraps around.
bool CheckJunction() const
Returns true if the object's waypoint belongs to an intersection.
float DistanceSquared(const cg::Location &location) const
Calculates the square of the distance to given location.
GeoGridId geodesic_grid_id
Integer placing the waypoint into a geodesic grid.
cg::Vector3D GetForwardVector() const
Returns the vector along the waypoint's direction.
void SetRoadOption(RoadOption _road_option)
std::vector< SimpleWaypointPtr > next_waypoints
List of pointers to next connecting waypoints.
std::vector< SimpleWaypointPtr > GetPreviousWaypoint() const
Returns the list of previous waypoints.
uint64_t GetId() const
Returns the unique id for the waypoint.
WaypointPtr GetWaypoint() const
Returns a carla::shared_ptr to carla::waypoint.
SimpleWaypointPtr next_right_waypoint
Pointer to right lane change waypoint.
void ClearLinks()
Drops the links to the neighbouring waypoints (next, previous, left and right).
void SetIsJunction(bool value)
This method is used to set whether the waypoint belongs to a junction.
uint64_t SetPreviousWaypoint(const std::vector< SimpleWaypointPtr > &next_waypoints)
This method is used to set the previous waypoints.
cg::Transform GetTransform() const
Return transform object for the current waypoint.
SimpleWaypointPtr GetLeftWaypoint()
This method is used to get the closest left waypoint for a lane change.
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr
float Distance(const cg::Location &location) const
Calculates the distance from the object's waypoint to the passed location.
void SetGeodesicGridId(GeoGridId _geodesic_grid_id)
Accessor methods for geodesic grid id.
cg::Location GetLocation() const
Returns the location object for this waypoint.
SimpleWaypointPtr GetRightWaypoint()
This method is used to get the closest right waypoint for a lane change.
RoadOption road_option
RoadOption for the actual waypoint.
int32_t JuncId
Definition RoadTypes.h:17
carla::SharedPtr< cc::Waypoint > WaypointPtr
Definition InMemoryMap.h:45
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< T > SharedPtr
Definition Memory.h:15