← Projects

Layered autonomous driving in Gazebo

A ROS 2 driving stack integrating lane keeping, YOLO perception, LiDAR safety, SLAM and Nav2 in simulation.

Role
Software developer and co-author
Organization
Kocaeli University
Period
2026
Stack
ROS 2 · Gazebo · Python · C++ · YOLO11 · Nav2 · OpenCV
A Toyota Prius model at an intersection in the Gazebo autonomous-driving simulation.

Problem

Testing autonomous-driving software on a physical vehicle is expensive and risky. This graduation project set out to build an end-to-end environment in which perception, localization, planning and control could be developed and measured without physical hardware.

The system runs on ROS 2 Humble and Gazebo Classic 11 with a Toyota Prius model, a front camera, 3D LiDAR and odometry. Rather than building one large node, we split the stack into five modules with explicit ROS 2 topic interfaces: lane keeping, traffic perception, collision avoidance, SLAM and Nav2-based navigation.

Four-layer architecture connecting Gazebo sensors, ROS 2 interfaces, perception modules and Nav2 orchestration

Perception and control

The lane-keeping module processes the lower 35% of the camera frame, applies a 7×7 Gaussian filter, finds edges with Canny and extracts lane markings with a probabilistic Hough transform. A PID controller converts the detected center error into steering commands. On the straight-road test it kept the vehicle within the ±0.30 m target for 96.2% of frames, with 0.142 m average deviation at 0.8 m/s.

Lane-detection pipeline from the simulated camera image through grayscale, Gaussian filtering and Canny edges

Traffic lights and signs are detected with a YOLO11s model trained for eight classes on 6,478 images. The ONNX version reached 0.946 mAP50 and 67.63 FPS on the held-out test benchmark. Its detections feed driving decisions: stopping at red lights and stop signs, continuing on green, and changing the simulated speed limit.

YOLO traffic-sign detection in the Gazebo camera view with a detected 50 speed-limit sign

Safety, mapping and navigation

The safety layer filters 3D LiDAR PointCloud2 data by height and region of interest, then calculates a stopping distance that grows with vehicle speed. Its command has the highest priority in twist_mux, allowing it to override lane or navigation commands. All 70 isolated safety tests passed; the integrated side-obstacle transition was measured at 161 ms with no false alarms in the clear-route run.

Google Cartographer produced a map of the 3×3 simulated city with 0.09 m RMS metric error. Nav2 combined Hybrid A* planning, Regulated Pure Pursuit control and behavior trees to coordinate route following with the perception and safety layers.

Cartographer map of the simulated road network with the vehicle and LiDAR scan visible at an intersection

What did not work

The repeated roads and intersections created perceptual aliasing. AMCL became uncertain in the symmetric environment and could place the vehicle inside an obstacle, leaving the planner unable to produce a route. Cartographer also drifted along visually similar corridors. Increasing the odometry and rotation weights in its Ceres solver stabilized mapping; final route tests used an odometry-EKF localization bypass and documented online localization as a remaining limitation.

Free-goal navigation caused a second problem: a shortest path could ignore the road structure. The final system therefore used ordered route waypoints. Generating those routes automatically from a Lanelet2 road graph remains the next architectural step.

Result

The complete stack finished straight, left-turn and right-turn routes, stopped at a red light, continued on green, observed simulated speed limits and passed a static obstacle with 1.73 m clearance. In the online unknown-obstacle test it completed 18 of 18 waypoints and replanned twice without triggering the emergency safety veto.

All validation was performed in Gazebo. The results establish the behavior of the modular stack in its defined simulation environment; real sensors, timing and vehicle dynamics would require a separate sim-to-real validation stage.