Implementation:CARLA simulator Carla DebugShape
| Knowledge Sources | |
|---|---|
| Domains | Debug Visualization, RPC Serialization |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
DebugShape is an RPC-serializable class that represents a debug drawing primitive (point, line, arrow, box, or string) that can be rendered in the CARLA simulation viewport.
Description
Defined in the carla::rpc namespace, this class uses a std::variant to hold one of five primitive shape types:
- Point: a location with a size
- Line: two endpoints with a thickness
- Arrow: a line with an arrow head size
- Box: a bounding box with rotation and thickness
- String: a location with text and shadow option
Each shape has a color (default red: 255,0,0), a life_time in seconds (-1.0 for permanent), and a persistent_lines flag (default true). All types are individually MsgPack-serializable, and the variant-based primitive is serialized as part of the top-level MSGPACK_DEFINE_ARRAY.
Usage
Use this type to send debug visualization commands from the client to the server for rendering points, lines, arrows, boxes, or text strings in the 3D viewport.
Code Reference
Source Location
- Repository: CARLA
- File:
LibCarla/source/carla/rpc/DebugShape.h
Signature
namespace carla {
namespace rpc {
class DebugShape {
public:
struct Point { geom::Location location; float size; };
struct Line { geom::Location begin; geom::Location end; float thickness; };
struct Arrow { Line line; float arrow_size; };
struct Box { geom::BoundingBox box; geom::Rotation rotation; float thickness; };
struct String { geom::Location location; std::string text; bool draw_shadow; };
std::variant<Point, Line, Arrow, Box, String> primitive;
Color color = {255u, 0u, 0u};
float life_time = -1.0f;
bool persistent_lines = true;
MSGPACK_DEFINE_ARRAY(primitive, color, life_time, persistent_lines);
};
} // namespace rpc
} // namespace carla
Import
#include "carla/rpc/DebugShape.h"
I/O Contract
| Field | Type | Default | Description |
|---|---|---|---|
| primitive | std::variant<Point, Line, Arrow, Box, String> |
-- | The shape to render |
| color | Color |
{255, 0, 0} | RGB color for the shape |
| life_time | float |
-1.0f | Duration in seconds (-1 = permanent) |
| persistent_lines | bool |
true | Whether lines persist across frames |
Usage Examples
#include "carla/rpc/DebugShape.h"
carla::rpc::DebugShape shape;
shape.primitive = carla::rpc::DebugShape::Point{
carla::geom::Location(10.0f, 20.0f, 1.0f), 0.5f
};
shape.color = {0u, 255u, 0u}; // green
shape.life_time = 5.0f; // 5 seconds
// Send shape to server for debug rendering