Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CARLA simulator Carla DebugHelper Class

From Leeroopedia
Revision as of 12:13, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/CARLA_simulator_Carla_DebugHelper_Class.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Client Library, Debugging, Visualization
Last Updated 2026-02-15 05:00 GMT

Overview

DebugHelper provides client-side methods for drawing debug shapes (points, lines, arrows, boxes, and text strings) in the CARLA simulation world for visualization and debugging purposes.

Description

The DebugHelper class in the carla::client namespace offers a set of drawing primitives that render directly in the simulator's viewport. Each method accepts optional parameters for size/thickness, color, life_time, and persistent_lines.

Construction

Created with a detail::EpisodeProxy which provides the connection to the simulator for issuing draw commands.

Drawing Methods

  • DrawPoint(location, size, color, life_time, persistent_lines) -- Draws a point at the given location with specified size (default 0.1).
  • DrawLine(begin, end, thickness, color, life_time, persistent_lines) -- Draws a line between two locations with specified thickness (default 0.1).
  • DrawArrow(begin, end, thickness, arrow_size, color, life_time, persistent_lines) -- Draws an arrow from begin to end with configurable arrow head size (default 0.1).
  • DrawBox(box, rotation, thickness, color, life_time, persistent_lines) -- Draws a wireframe bounding box with the given rotation.
  • DrawString(location, text, draw_shadow, color, life_time, persistent_lines) -- Draws a text string at the given location, optionally with a shadow.

Common Parameters

All methods share these defaults:

  • Color defaults to red: Color{255u, 0u, 0u}.
  • life_time defaults to -1.0f (persistent until cleared).
  • persistent_lines defaults to true.

The Color type alias maps to sensor::data::Color.

Usage

Use DebugHelper for visual debugging of simulation scenarios -- drawing waypoints, routes, bounding boxes around actors, or labeling objects with text. Access it via world.MakeDebugHelper() or the Python API's world.debug.

Code Reference

Source Location

  • Repository: CARLA
  • File: LibCarla/source/carla/client/DebugHelper.h (72 lines)

Signature

namespace carla {
namespace client {

class DebugHelper {
public:
  using Color = sensor::data::Color;

  explicit DebugHelper(detail::EpisodeProxy episode);

  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);

  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);

  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);

  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);

  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);

private:
  detail::EpisodeProxy _episode;
};

} // namespace client
} // namespace carla

Import

#include "carla/client/DebugHelper.h"

I/O Contract

Inputs

Name Type Required Description
episode detail::EpisodeProxy Yes Episode proxy for communicating with the simulator
location geom::Location Yes Position for drawing points, strings, or shape anchors
begin / end geom::Location Yes (for lines/arrows) Start and end points of lines and arrows
box geom::BoundingBox Yes (for DrawBox) Bounding box dimensions and offset
rotation geom::Rotation Yes (for DrawBox) Rotation for the bounding box
color Color No Drawing color (default: red)
life_time float No Duration in seconds (-1.0 for persistent)
text std::string Yes (for DrawString) Text content to display

Outputs

Name Type Description
Visual rendering void Shapes are rendered in the simulator viewport (no return value)

Usage Examples

auto debug = world.MakeDebugHelper();

// Draw a waypoint marker
debug.DrawPoint(
    carla::geom::Location(100.0f, 200.0f, 0.5f),
    0.2f,
    carla::sensor::data::Color{0u, 255u, 0u},
    5.0f);

// Draw a bounding box around a vehicle
auto bbox = vehicle->GetBoundingBox();
debug.DrawBox(
    bbox,
    vehicle->GetTransform().rotation,
    0.05f,
    carla::sensor::data::Color{255u, 255u, 0u},
    0.1f);

// Draw a label
debug.DrawString(
    vehicle->GetLocation(),
    "Ego Vehicle",
    true,
    carla::sensor::data::Color{255u, 255u, 255u});

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment