CARLA
OpenDriveMap.h
Go to the documentation of this file.
1 // Copyright (c) 2019 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 
10 #include <carla/road/Map.h>
12 
13 #include "OpenDriveMap.generated.h"
14 
15 USTRUCT(BlueprintType)
16 struct CARLA_API FWaypoint
17 {
18  GENERATED_BODY()
19 
20  carla::road::element::Waypoint Waypoint;
21 };
22 
23 USTRUCT(BlueprintType)
24 struct CARLA_API FWaypointConnection
25 {
26  GENERATED_BODY()
27 
28  UPROPERTY(BlueprintReadWrite)
29  FWaypoint Start;
30 
31  UPROPERTY(BlueprintReadWrite)
32  FWaypoint End;
33 };
34 
35 /// Helper class for exposing CARLA OpenDrive API to blueprints.
36 UCLASS(BlueprintType, Blueprintable)
37 class CARLA_API UOpenDriveMap : public UObject
38 {
39  GENERATED_BODY()
40 
41 public:
42 
43  UOpenDriveMap(const FObjectInitializer &ObjectInitializer);
44 
45  /// Return whether this map has been initialized.
46  UFUNCTION(BlueprintCallable)
47  bool HasMap() const
48  {
49  return Map.IsSet();
50  }
51 
52  /// Load this map with an OpenDrive (XODR) file.
53  UFUNCTION(BlueprintCallable)
54  bool Load(const FString &XODRContent);
55 
56  /// Given a location, return the closest point on the centre of a lane.
57  UFUNCTION(BlueprintCallable)
58  FWaypoint GetClosestWaypointOnRoad(FVector Location, bool &Success) const;
59 
60  /// Generate waypoints all over the map at an approximated distance.
61  UFUNCTION(BlueprintCallable)
62  TArray<FWaypoint> GenerateWaypoints(float ApproxDistance = 100.0f) const;
63 
64  /// Generate the minimum set of waypoints that define the topology of this
65  /// map. The waypoints are placed at the entrance of each lane.
66  UFUNCTION(BlueprintCallable)
67  TArray<FWaypointConnection> GenerateTopology() const;
68 
69  /// Generate waypoints on each lane at the start of each road.
70  UFUNCTION(BlueprintCallable)
71  TArray<FWaypoint> GenerateWaypointsOnRoadEntries() const;
72 
73  /// Compute the location of a waypoint.
74  UFUNCTION(BlueprintCallable)
75  FVector ComputeLocation(FWaypoint Waypoint) const;
76 
77  /// Compute the locations of an array of waypoints.
78  UFUNCTION(BlueprintCallable)
79  TArray<FVector> ComputeLocations(const TArray<FWaypoint> &Waypoints) const;
80 
81  /// Compute the transform of a waypoint. The X-axis is directed towards the
82  /// direction of the road at that waypoint.
83  UFUNCTION(BlueprintCallable)
84  FTransform ComputeTransform(FWaypoint Waypoint) const;
85 
86  /// Compute the transforms of an array of waypoints.
87  UFUNCTION(BlueprintCallable)
88  TArray<FTransform> ComputeTransforms(const TArray<FWaypoint> &Waypoints) const;
89 
90  /// Return the list of waypoints at a given distance such that a vehicle at
91  /// waypoint could drive to.
92  UFUNCTION(BlueprintCallable)
93  TArray<FWaypoint> GetNext(FWaypoint Waypoint, float Distance = 100.0f) const;
94 
95 private:
96 
97  TOptional<carla::road::Map> Map;
98 };
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
TOptional< carla::road::Map > Map
Definition: OpenDriveMap.h:97
static EpisodeProxyPointerType::Shared Load(EpisodeProxyPointerType::Strong ptr)
geom::Location Location
Definition: rpc/Location.h:14
Helper class for exposing CARLA OpenDrive API to blueprints.
Definition: OpenDriveMap.h:37