CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
agents
navigation
Misc.h
Go to the documentation of this file.
1
// Copyright (c) 2018-2020 CVC.
2
//
3
// This work is licensed under the terms of the MIT license.
4
// For a copy, see <https://opensource.org/licenses/MIT>.
5
6
#pragma once
7
8
#include "
carla/Memory.h
"
9
10
#include <array>
11
#include <optional>
12
#include <utility>
13
#include <vector>
14
15
namespace
carla
{
16
17
namespace
client
{
18
class
Actor
;
19
class
TrafficLight
;
20
class
Waypoint
;
21
class
World
;
22
}
// namespace client
23
24
namespace
geom
{
25
struct
Location
;
26
class
Transform
;
27
}
// namespace geom
28
29
namespace
agents
{
30
namespace
navigation {
31
32
/// Compute speed of an actor in km/h.
33
float
GetSpeed
(
SharedPtr<client::Actor>
actor);
34
35
/// Compute the world-space trigger location of a traffic light, mirroring
36
/// the helper in `agents.tools.misc.get_trafficlight_trigger_location`.
37
geom::Location
GetTrafficLightTriggerLocation
(
38
SharedPtr<client::TrafficLight>
traffic_light);
39
40
/// Returns true when @a target is within @a max_distance of @a reference.
41
/// When @a angle_interval is provided, the angle (in degrees) between the
42
/// reference's forward vector and the vector reference -> target must lie
43
/// in the open interval (min, max).
44
bool
IsWithinDistance
(
45
const
geom::Transform
&target,
46
const
geom::Transform
&reference,
47
float
max_distance,
48
std::optional<std::pair<float, float>> angle_interval = std::nullopt);
49
50
/// Returns the (distance, angle in degrees) from @a current to @a target
51
/// relative to a forward orientation @a orientation_deg in degrees.
52
std::pair<float, float>
ComputeMagnitudeAngle
(
53
const
geom::Location
&target,
54
const
geom::Location
¤t,
55
float
orientation_deg);
56
57
/// 2-D distance between a waypoint and a vehicle transform.
58
float
DistanceVehicle
(
59
SharedPtr<client::Waypoint>
waypoint,
60
const
geom::Transform
&vehicle_transform);
61
62
/// Unit vector going from @a a to @a b, including the z component.
63
std::array<float, 3>
UnitVector
(
64
const
geom::Location
&a,
65
const
geom::Location
&b);
66
67
/// Euclidean distance between two locations (matches numpy's regularised
68
/// version that adds an epsilon to avoid 0).
69
float
ComputeDistance
(
70
const
geom::Location
&a,
71
const
geom::Location
&b);
72
73
/// Clamp @a v at zero. Inline because it's tiny.
74
inline
float
Positive
(
float
v) {
return
v > 0.0f ? v : 0.0f; }
75
76
/// Draw the supplied waypoints in the world for a fixed lifetime.
77
void
DrawWaypoints
(
78
SharedPtr<client::World>
world,
79
const
std::vector<
SharedPtr<client::Waypoint>
> &waypoints,
80
float
z = 0.5f);
81
82
}
// namespace navigation
83
}
// namespace agents
84
}
// namespace carla
Memory.h
carla::client::Actor
Represents an actor in the simulation.
Definition
client/Actor.h:21
carla::client::TrafficLight
Definition
TrafficLight.h:16
carla::client::Waypoint
Definition
client/Waypoint.h:31
carla::client::World
Definition
World.h:45
carla::geom::Transform
A rigid transform in CARLA's / Unreal's left-handed frame: x forward, y right, z up,...
Definition
geom/Transform.h:32
carla::agents::navigation::IsWithinDistance
bool IsWithinDistance(const geom::Transform &target, const geom::Transform &reference, float max_distance, std::optional< std::pair< float, float > > angle_interval)
Returns true when target is within max_distance of reference.
Definition
Misc.cpp:78
carla::agents::navigation::ComputeDistance
float ComputeDistance(const geom::Location &a, const geom::Location &b)
Euclidean distance between two locations (matches numpy's regularised version that adds an epsilon to...
Definition
Misc.cpp:150
carla::agents::navigation::DrawWaypoints
void DrawWaypoints(SharedPtr< client::World > world, const std::vector< SharedPtr< client::Waypoint > > &waypoints, float z)
Draw the supplied waypoints in the world for a fixed lifetime.
Definition
Misc.cpp:159
carla::agents::navigation::GetTrafficLightTriggerLocation
geom::Location GetTrafficLightTriggerLocation(SharedPtr< client::TrafficLight > traffic_light)
Compute the world-space trigger location of a traffic light, mirroring the helper in agents....
Definition
Misc.cpp:45
carla::agents::navigation::Positive
float Positive(float v)
Clamp v at zero. Inline because it's tiny.
Definition
Misc.h:74
carla::agents::navigation::GetSpeed
float GetSpeed(SharedPtr< client::Actor > actor)
Compute speed of an actor in km/h.
Definition
Misc.cpp:37
carla::agents::navigation::ComputeMagnitudeAngle
std::pair< float, float > ComputeMagnitudeAngle(const geom::Location &target, const geom::Location ¤t, float orientation_deg)
Returns the (distance, angle in degrees) from current to target relative to a forward orientation ori...
Definition
Misc.cpp:109
carla::agents::navigation::DistanceVehicle
float DistanceVehicle(SharedPtr< client::Waypoint > waypoint, const geom::Transform &vehicle_transform)
2-D distance between a waypoint and a vehicle transform.
Definition
Misc.cpp:130
carla::agents::navigation::UnitVector
std::array< float, 3 > UnitVector(const geom::Location &a, const geom::Location &b)
Unit vector going from a to b, including the z component.
Definition
Misc.cpp:139
carla::agents
Definition
BasicAgent.cpp:39
carla::client
Definition
BasicAgent.h:24
carla::geom
Definition
Misc.h:24
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
carla::SharedPtr
std::shared_ptr< T > SharedPtr
Definition
Memory.h:15
carla::geom::Location
Definition
geom/Location.h:23
Generated by
1.18.0