The Unvarnished Reality of Real-Time Perception Stacks

Building a real-time perception system for autonomous vehicles is a complex undertaking, often presented in tutorials as a straightforward integration of cutting-edge tools. One developer's recent three-week project, however, paints a far more realistic picture. The goal was ambitious: to create a system capable of detecting and tracking objects within a simulated environment, feeding that data into a navigation stack, and crucially, running fast enough for actual autonomous decision-making. The chosen toolkit included CARLA for simulation, YOLOv11 for object detection, and ByteTrack for object tracking, all orchestrated with ROS 2.

This wasn't an exercise in theoretical architecture. It was a hands-on, often messy, exploration of what happens when academic concepts meet the gritty demands of real-time execution. The journey involved wrestling with the practicalities of making disparate systems communicate, debugging unexpected performance bottlenecks, and adapting existing algorithms to fit a specific, demanding use case. The outcome is a valuable case study for anyone venturing into robotics perception, highlighting the gap between curated documentation and the messy, iterative process of building functional systems.

Project Goals: Beyond Detection

The core objectives for this project were clear and demanding:

  • Real-time Object Detection: Accurately identify objects within the CARLA simulation environment as a vehicle moves.
  • Stable Object Tracking: Maintain consistent identities for detected objects across multiple video frames. This is critical for understanding object behavior and intent.
  • ROS 2 Integration: Structure the output of the perception system into a format that could be directly consumed by a ROS 2 navigation stack.
  • Performance Threshold: Achieve a processing speed that is genuinely useful for autonomous decision-making, meaning low latency and high throughput.

The selection of tools was deliberate. CARLA provides a robust, open-source simulator environment for autonomous driving research. YOLOv11, a state-of-the-art object detection model, was chosen for its speed and accuracy. For tracking, ByteTrack was initially considered for its ability to handle occlusions and track low-confidence detections, a common challenge in dynamic environments. StrongSORT, another advanced tracking algorithm, was also part of the experimental toolkit. Finally, ROS 2 (Robot Operating System 2) served as the middleware, the glue intended to connect the perception output to downstream navigation and control modules.

The Integration Gauntlet: What Broke First

The initial phase of the project focused on getting the core components to communicate. The first major hurdle was establishing a reliable data pipeline between CARLA and the perception modules. CARLA generates sensor data (like camera feeds) and ground truth information. This data needs to be formatted correctly for YOLOv11. While CARLA offers Python APIs, translating its high-fidelity sensor outputs into the specific input formats required by deep learning models can be non-trivial, especially when aiming for real-time performance. Frame synchronization issues and data conversion overhead quickly emerged as significant performance drains.

Getting YOLOv11 to run efficiently was another challenge. While pre-trained models are available, fine-tuning them for specific object classes or optimizing them for inference speed within the simulator's loop requires careful configuration. The tutorials often demonstrate running detection on static images or short, pre-recorded sequences. Real-time operation within a dynamic simulation introduces complexities like managing GPU memory, CPU-GPU data transfer latency, and ensuring consistent frame rates under varying simulation loads.

Diagram illustrating the flow of data from CARLA sensor inputs to object detection and tracking algorithms.

Tracking: More Than Just Connecting Dots

Object tracking, the process of assigning a unique ID to each detected object and following it across frames, proved to be a particularly thorny area. ByteTrack, lauded for its ability to handle occlusions by incorporating low-score detections, presented integration challenges. The output format of YOLOv11 needed to be precisely matched to ByteTrack's input expectations. Furthermore, the computational cost of running an advanced tracker like ByteTrack or StrongSORT in real-time, on top of object detection, significantly impacted the overall system throughput. Maintaining stable identities for objects that become temporarily occluded or move erratically required careful tuning of tracking parameters, often a trial-and-error process.

The ROS 2 integration layer also introduced its own set of complexities. While ROS 2 is designed for distributed robotics systems, setting up the message types, publishers, and subscribers for high-bandwidth sensor data and perception results requires meticulous configuration. Latency introduced by ROS 2 message serialization and deserialization, especially at high frame rates, had to be accounted for. The ideal scenario of a clean, structured output feeding directly into a navigation stack quickly became a reality of debugging message queues and ensuring data integrity.

Surprising Discoveries and Learned Lessons

The most surprising detail was not the complexity of any single component, but the sheer difficulty of achieving a truly real-time loop across all of them. Tutorials often abstract away the inter-process communication overhead, the GPU memory management, and the precise data type conversions that consume significant development time. The performance sweet spot where detection, tracking, and ROS 2 communication could coexist without introducing unacceptable latency was elusive and required extensive profiling and optimization. It felt less like assembling pre-fabricated modules and more like carefully balancing a house of cards.

Several key lessons emerged from this intensive three-week period:

  • Simulation vs. Reality: Even high-fidelity simulators like CARLA do not perfectly replicate the real-world challenges of sensor noise, unpredictable environmental conditions, and hardware limitations. However, they are invaluable for iterating on algorithms and system integration before deploying to expensive physical hardware.
  • Component Interoperability: The