Implementation:CARLA simulator Carla WalkerEvent
| Knowledge Sources | |
|---|---|
| Domains | Navigation, Pedestrian AI |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
The WalkerEvent module defines event types and a visitor pattern for handling pedestrian route events such as waiting, stopping to check for vehicles, and traffic light awareness.
Description
This module uses std::variant to define a WalkerEvent type with three event variants:
- WalkerEventIgnore -- an empty event that immediately ends (returns
EventResult::End) - WalkerEventWait -- a timed wait event that decrements its
timefield by delta seconds each tick, returningContinueuntil time expires - WalkerEventStopAndCheck -- a complex event where the walker pauses, checks for nearby traffic lights (only on the first tick), respects red light states by continuing to wait, and checks for nearby vehicles within 6 meters in the crosswalk direction. Returns
TimeOutif the wait duration expires,Endwhen no vehicles are near, orContinuewhile hazards remain.
The EventResult enum provides three outcomes: Continue, End, and TimeOut.
The WalkerEventVisitor class implements the visitor pattern with overloaded operator() for each event type, receiving the WalkerManager pointer, actor ID, and delta time.
Usage
These events are used in walker route points to define behavior at crosswalks and intersections. The WalkerManager processes these events each tick using std::visit.
Code Reference
Source Location
- Repository: CARLA
- Files:
LibCarla/source/carla/nav/WalkerEvent.h,LibCarla/source/carla/nav/WalkerEvent.cpp
Signature
enum class EventResult : uint8_t { Continue, End, TimeOut };
struct WalkerEventIgnore {};
struct WalkerEventWait { double time; };
struct WalkerEventStopAndCheck {
double time;
bool check_for_trafficlight;
SharedPtr<client::TrafficLight> actor;
};
using WalkerEvent = std::variant<WalkerEventIgnore, WalkerEventWait, WalkerEventStopAndCheck>;
class WalkerEventVisitor {
public:
WalkerEventVisitor(WalkerManager *manager, ActorId id, double delta);
EventResult operator()(WalkerEventIgnore &event);
EventResult operator()(WalkerEventWait &event);
EventResult operator()(WalkerEventStopAndCheck &event);
};
Import
#include "carla/nav/WalkerEvent.h"
I/O Contract
| Input | Type | Description |
|---|---|---|
double | Time elapsed since last tick
| ||
WalkerManager * | Reference to walker manager for navigation queries
| ||
ActorId | Walker actor ID
|
| Output | Type | Description |
|---|---|---|
EventResult | Continue, End, or TimeOut
|
Usage Examples
WalkerEventVisitor visitor(&walker_manager, actor_id, delta_time);
EventResult result = std::visit(visitor, route_point.event);
if (result == EventResult::End) {
// Move to next route point
}