CARLA
 
载入中...
搜索中...
未找到
SimpleWaypoint.h
浏览该文件的文档.
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
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 /// This method is used to get the closest left waypoint for a lane change.
98
99 /// This method is used to get the closest right waypoint for a lane change.
101
102 /// Accessor methods for geodesic grid id.
103 void SetGeodesicGridId(GeoGridId _geodesic_grid_id);
105
106 /// Method to retreive junction id of the waypoint.
107 GeoGridId GetJunctionId() const;
108
109 /// Calculates the distance from the object's waypoint to the passed
110 /// location.
111 float Distance(const cg::Location &location) const;
112
113 /// Calculates the distance the other SimpleWaypoint object.
114 float Distance(const SimpleWaypointPtr &other) const;
115
116 /// Calculates the square of the distance to given location.
117 float DistanceSquared(const cg::Location &location) const;
118
119 /// Calculates the square of the distance to other waypoints.
120 float DistanceSquared(const SimpleWaypointPtr &other) const;
121
122 /// Returns true if the object's waypoint belongs to an intersection.
123 bool CheckJunction() const;
124
125 /// This method is used to set whether the waypoint belongs to a junction.
126 void SetIsJunction(bool value);
127
128 /// Returns true if the object's waypoint belongs to an intersection (Doesn't use OpenDrive).
129 bool CheckIntersection() const;
130
131 /// Return transform object for the current waypoint.
133
134 // Accessor methods for road option.
135 void SetRoadOption(RoadOption _road_option);
137 };
138
139} // namespace traffic_manager
140} // namespace carla
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 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.
Definition Carla.cpp:133
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