Implementation:CARLA simulator Carla RssSensor
| Knowledge Sources | |
|---|---|
| Domains | Safety, Sensors, RSS |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
RssSensor is a client-side sensor implementation that manages the lifecycle of RSS (Responsibility-Sensitive Safety) checks within the CARLA simulation, integrating map initialization, tick-based processing, and callback management.
Description
The RssSensor class extends carla::client::Sensor and orchestrates the RSS safety checking pipeline. Key responsibilities include:
- Map initialization -- On Listen(), the sensor retrieves the OpenDRIVE map content and initializes the AD Map Access library with intersection and traffic light type configurations. A global atomic counter (_global_map_initialization_counter_) tracks how many sensors have initialized the map to ensure proper cleanup.
- Vehicle parameter extraction -- Automatically extracts the maximum steering angle from the parent vehicle's physics control (wheel parameters) for RSS computations.
- Actor constellation callback registration -- Supports registering a custom ActorConstellationCallbackFunctionType before listening begins via RegisterActorConstellationCallback. If no callback is registered, a default RssCheck instance is created.
- Tick-based processing -- Subscribes to the episode's tick event and calls TickRssSensor each frame with the current timestamp and user callback, protected by a _processing_lock mutex.
- Lifecycle management -- Stop() unsubscribes from tick events, resets the RssCheck instance under a scoped lock, and decrements the global map counter (cleaning up the map when the last sensor stops).
- Log level control -- SetLogLevel and SetMapLogLevel delegate to the underlying RssCheck instance.
Usage
Attach an RssSensor to a vehicle actor, optionally register a custom actor constellation callback, then call Listen() with a response callback. The sensor will automatically perform RSS checks each tick and invoke the callback with RSS response data.
Code Reference
Source Location
- Repository: CARLA
- File:
LibCarla/source/carla/rss/RssSensor.cpp(378 lines)
Signature
namespace carla {
namespace client {
class RssSensor : public Sensor {
public:
using ActorConstellationCallbackFunctionType =
rss::RssCheck::ActorConstellationCallbackFunctionType;
RssSensor(ActorInitializer init);
~RssSensor();
void RegisterActorConstellationCallback(ActorConstellationCallbackFunctionType callback);
void Listen(CallbackFunctionType callback);
void Stop();
void SetLogLevel(const uint8_t &log_level);
void SetMapLogLevel(const uint8_t &map_log_level);
private:
static std::atomic_uint _global_map_initialization_counter_;
std::shared_ptr<carla::rss::RssCheck> _rss_check;
ActorConstellationCallbackFunctionType _rss_actor_constellation_callback;
size_t _on_tick_register_id;
bool _drop_route;
std::mutex _processing_lock;
};
} // namespace client
} // namespace carla
Import
#include "carla/rss/RssSensor.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| init | ActorInitializer | Yes | Actor initialization data from the simulator |
| callback | CallbackFunctionType | Yes | Callback invoked with RSS response data each tick |
| log_level | uint8_t | No | spdlog log level for RSS check output |
| map_log_level | uint8_t | No | spdlog log level for map-related output |
Outputs
| Name | Type | Description |
|---|---|---|
| RSS response callback | CallbackFunctionType invocation | Delivers RSS response data per tick via user callback |
Usage Examples
// Attach RSS sensor to a vehicle and start listening
auto rss_sensor = world.SpawnActor(rss_blueprint, transform, vehicle);
auto rss = std::static_pointer_cast<carla::client::RssSensor>(rss_sensor);
// Optionally register custom constellation callback
rss->RegisterActorConstellationCallback(my_callback);
// Start listening for RSS responses
rss->Listen([](auto data) {
auto rss_response = std::static_pointer_cast<carla::sensor::data::RssResponse>(data);
// Process RSS response
});
// Stop when done
rss->Stop();
Related Pages
- Environment:CARLA_simulator_Carla_Simulation_Runtime
- CARLA_simulator_Carla_RssCheck - Core RSS check implementation used by this sensor
- CARLA_simulator_Carla_RssCheck_Interface - RssCheck interface definition
- CARLA_simulator_Carla_ServerSideSensor - Base server-side sensor pattern