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 RawData

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

Overview

RawData is a wrapper around a raw binary buffer generated by a sensor, providing accessors for meta-information such as sensor type ID, frame count, timestamp, and sensor transform.

Description

The RawData class encapsulates a Buffer that contains serialized sensor output. It uses the SensorHeaderSerializer to extract metadata from a fixed-size header at the beginning of the buffer. The header contains the sensor type ID, frame number, timestamp, and the sensor transform at the time of data capture.

The class provides STL-compatible iterators (begin(), end()) that point to the payload data region of the buffer (i.e., everything after the header offset). The data() method returns a pointer to the start of the payload, and size() returns the payload size in bytes.

RawData has a private constructor that accepts a Buffer&& and is only constructible by friend classes: CompositeSerializer (any instantiation) and carla::ros2::ROS2. This ensures that raw data objects are only created through the sensor framework pipeline.

Usage

RawData is used internally during the deserialization pipeline. When a buffer arrives from a sensor stream, CompositeSerializer::Deserialize wraps it in a RawData instance, reads the sensor type ID to determine which serializer to invoke, and then forwards the RawData to the appropriate serializer for full deserialization into a SensorData subclass.

Code Reference

Source Location

  • Repository: CARLA
  • File: LibCarla/source/carla/sensor/RawData.h

Signature

class RawData {
public:
    uint64_t GetSensorTypeId() const;
    uint64_t GetFrame() const;
    double GetTimestamp() const;
    const rpc::Transform &GetSensorTransform() const;

    auto begin() noexcept;
    auto begin() const noexcept;
    auto end() noexcept;
    auto end() const noexcept;
    auto data() noexcept;
    auto data() const noexcept;
    size_t size() const;

private:
    RawData(Buffer &&buffer);
    Buffer _buffer;
};

Import

#include "carla/sensor/RawData.h"

I/O Contract

Inputs

Name Type Required Description
buffer Buffer&& Yes Move-constructed raw binary buffer containing header + sensor payload

Outputs

Name Type Description
GetSensorTypeId() uint64_t Numeric identifier of the sensor type that generated the data
GetFrame() uint64_t Frame count at the time the data was generated
GetTimestamp() double Simulation timestamp when the data was generated
GetSensorTransform() const rpc::Transform& World transform of the sensor when the data was captured
begin()/end() iterator Iterators over the raw payload bytes (after header)
size() size_t Size in bytes of the payload data (excluding header)

Usage Examples

// RawData is typically constructed internally by CompositeSerializer::Deserialize
// Example of reading metadata from raw sensor data:
RawData message(std::move(buffer));
uint64_t sensorType = message.GetSensorTypeId();
uint64_t frame = message.GetFrame();
double timestamp = message.GetTimestamp();

// Access raw payload bytes
const unsigned char *payloadStart = message.data();
size_t payloadSize = message.size();

Related Pages

Page Connections

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