CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
client
DebugHelper.cpp
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
#include "
carla/client/DebugHelper.h
"
8
9
#include "
carla/client/detail/Simulator.h
"
10
#include "
carla/rpc/DebugShape.h
"
11
12
namespace
carla
{
13
namespace
client
{
14
15
using
Shape
=
rpc::DebugShape
;
16
17
template
<
typename
T>
18
static
void
DrawShape
(
19
detail::EpisodeProxy
&episode,
20
const
T &primitive,
21
rpc::Color
color,
22
float
life_time,
23
bool
persistent_lines) {
24
const
Shape
shape{primitive, color, life_time, persistent_lines};
25
episode.
Lock
()->DrawDebugShape(shape);
26
}
27
28
void
DebugHelper::DrawPoint
(
29
const
geom::Location
&location,
30
float
size,
31
sensor::data::Color
color,
32
float
life_time,
33
bool
persistent_lines) {
34
Shape::Point
point{location, size};
35
DrawShape
(
_episode
, point, color, life_time, persistent_lines);
36
}
37
38
void
DebugHelper::DrawLine
(
39
const
geom::Location
&begin,
40
const
geom::Location
&end,
41
float
thickness,
42
sensor::data::Color
color,
43
float
life_time,
44
bool
persistent_lines) {
45
Shape::Line
line{begin, end, thickness};
46
DrawShape
(
_episode
, line, color, life_time, persistent_lines);
47
}
48
49
void
DebugHelper::DrawArrow
(
50
const
geom::Location
&begin,
51
const
geom::Location
&end,
52
float
thickness,
53
float
arrow_size,
54
sensor::data::Color
color,
55
float
life_time,
56
bool
persistent_lines) {
57
Shape::Line
line{begin, end, thickness};
58
Shape::Arrow
arrow{line, arrow_size};
59
DrawShape
(
_episode
, arrow, color, life_time, persistent_lines);
60
}
61
62
void
DebugHelper::DrawBox
(
63
const
geom::BoundingBox
&box,
64
const
geom::Rotation
&rotation,
65
float
thickness,
66
sensor::data::Color
color,
67
float
life_time,
68
bool
persistent_lines) {
69
Shape::Box
the_box{box, rotation, thickness};
70
DrawShape
(
_episode
, the_box, color, life_time, persistent_lines);
71
}
72
73
void
DebugHelper::DrawString
(
74
const
geom::Location
&location,
75
const
std::string &text,
76
bool
draw_shadow,
77
sensor::data::Color
color,
78
float
life_time,
79
bool
persistent_lines) {
80
Shape::String
string
{location, text, draw_shadow};
81
DrawShape
(
_episode
,
string
, color, life_time, persistent_lines);
82
}
83
84
void
DebugHelper::ClearDebugShape
() {
85
_episode
.
Lock
()->ClearDebugShape();
86
}
87
88
void
DebugHelper::ClearDebugString
() {
89
_episode
.
Lock
()->ClearDebugString();
90
}
91
92
}
// namespace client
93
}
// namespace carla
DebugHelper.h
DebugShape.h
Simulator.h
carla::client::DebugHelper::ClearDebugString
void ClearDebugString()
Clear every persistent debug string currently shown in the HUD.
Definition
DebugHelper.cpp:88
carla::client::DebugHelper::DrawString
void DrawString(const geom::Location &location, const std::string &text, bool draw_shadow=false, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
Definition
DebugHelper.cpp:73
carla::client::DebugHelper::DrawLine
void DrawLine(const geom::Location &begin, const geom::Location &end, float thickness=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
Definition
DebugHelper.cpp:38
carla::client::DebugHelper::_episode
detail::EpisodeProxy _episode
Definition
DebugHelper.h:75
carla::client::DebugHelper::DrawArrow
void DrawArrow(const geom::Location &begin, const geom::Location &end, float thickness=0.1f, float arrow_size=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
Definition
DebugHelper.cpp:49
carla::client::DebugHelper::ClearDebugShape
void ClearDebugShape()
Clear every persistent debug shape (lines, points, boxes, arrows) previously drawn from this world.
Definition
DebugHelper.cpp:84
carla::client::DebugHelper::DrawPoint
void DrawPoint(const geom::Location &location, float size=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
Definition
DebugHelper.cpp:28
carla::client::DebugHelper::DrawBox
void DrawBox(const geom::BoundingBox &box, const geom::Rotation &rotation, float thickness=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
Definition
DebugHelper.cpp:62
carla::client::detail::EpisodeProxyImpl::Lock
SharedPtrType Lock() const
Same as TryLock but never return nullptr.
Definition
EpisodeProxy.cpp:39
carla::geom::BoundingBox
Definition
LibCarla/source/carla/geom/BoundingBox.h:26
carla::geom::Rotation
Euler angles of a rotation in CARLA's / Unreal's left-handed frame: x forward, y right,...
Definition
Rotation.h:45
carla::rpc::Color
Definition
rpc/Color.h:22
carla::rpc::DebugShape
Definition
DebugShape.h:29
carla::client::detail::EpisodeProxy
EpisodeProxyImpl< EpisodeProxyPointerType::Strong > EpisodeProxy
Definition
EpisodeProxy.h:69
carla::client
Definition
BasicAgent.h:24
carla::client::DrawShape
static void DrawShape(detail::EpisodeProxy &episode, const T &primitive, rpc::Color color, float life_time, bool persistent_lines)
Definition
DebugHelper.cpp:18
carla::client::Shape
rpc::DebugShape Shape
Definition
DebugHelper.cpp:15
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
carla::geom::Location
Definition
geom/Location.h:23
carla::rpc::DebugShape::Arrow
Definition
DebugShape.h:45
carla::rpc::DebugShape::Box
Definition
DebugShape.h:51
carla::rpc::DebugShape::Line
Definition
DebugShape.h:38
carla::rpc::DebugShape::Point
Definition
DebugShape.h:32
carla::rpc::DebugShape::String
Definition
DebugShape.h:58
carla::sensor::data::Color
A 32-bit BGRA color.
Definition
sensor/data/Color.h:20
Generated by
1.18.0