CARLA
DebugHelper.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017 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 
8 
10 #include "carla/rpc/DebugShape.h"
11 
12 namespace carla {
13 namespace client {
14 
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 
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 
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 
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 
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 
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 } // namespace client
85 } // namespace carla
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
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
A 32-bit BGRA color.
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
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
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
static void DrawShape(detail::EpisodeProxy &episode, const T &primitive, rpc::Color color, float life_time, bool persistent_lines)
Definition: DebugHelper.cpp:18
detail::EpisodeProxy _episode
Definition: DebugHelper.h:68
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
SharedPtrType Lock() const
Same as TryLock but never return nullptr.