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 WalkerEvent

From Leeroopedia
Revision as of 12:15, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/CARLA_simulator_Carla_WalkerEvent.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 time field by delta seconds each tick, returning Continue until 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 TimeOut if the wait duration expires, End when no vehicles are near, or Continue while 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
}

Related Pages

Page Connections

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