Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autonomous Driving — CARLA Simulator

A lane detection and autonomous target-point tracking system built for the CARLA Simulator. This project contains two separate scripts that together form a perception-to-control pipeline for CARLA's urban driving environment.

Scripts

lane_detection.py — Simple Lane Detection (Classroom Version)

A straightforward lane detection implementation that mimics the classical OpenCV textbook approach. It connects to a running CARLA server, spawns an ego vehicle with camera sensors, and applies a basic image-processing pipeline to detect lane boundaries in real time.

Pipeline:

Camera Feed → Grayscale → Gaussian Blur → Canny Edges → ROI Mask → Hough Lines → Lane Overlay

This version includes a commented student-exercise block so the pipeline can be used as a teaching tool.

target_point_carla.py — Target Point Tracking + Autonomous Steering

A more advanced script that extends the lane detection concept by computing a steering target point from the detected lane geometry. It handles vehicle spawning, sensor management, and closed-loop steering control within the CARLA simulation.

init.py — CARLA Client Initialization

Shared initialization logic for connecting to the CARLA server and setting up the simulation world.

Features

  • Full CARLA Integration: Spawns ego vehicle, attaches sensors, manages simulation lifecycle
  • Real-time Lane Detection: OpenCV-based pipeline processing at camera frame rate
  • Target Point Tracking: Computes steering targets from detected lane geometry
  • Interactive Controls: Keyboard-driven manual control with autopilot toggle
  • Multi-sensor Support: Switchable camera views (RGB, Depth, Segmentation)
  • Weather System: Dynamic weather presets for robustness testing

Keyboard Controls

Key Action
W / S Throttle / Brake
A / D Steer Left / Right
F1 Restart (respawn vehicle)
F5 Toggle Autopilot
TAB Toggle Camera View
1-9 Switch Sensor Type
F9 Toggle Recording
ESC Quit

Requirements

  • CARLA Simulator (Server running on localhost:2000)
  • Python 3.7+
  • Dependencies: numpy, opencv-python, pygame, matplotlib

Usage

  1. Start the CARLA server (CarlaUE4.exe)
  2. Run the simple lane detection client:
python src/lane_detection.py
  1. For target point tracking with autonomous steering:
python src/target_point_carla.py

Project Structure

autonomous-driving-carla/
├── src/
│   ├── lane_detection.py         # Simple/primitive lane detection (classroom version)
│   ├── target_point_carla.py     # Target point tracking + autonomous steering
│   └── init.py                   # CARLA client initialization
├── tests/
│   └── test_lane_detection.py    # Unit tests for image processing functions
└── docs/
    └── project_guidelines.pdf    # Course project specification

License

MIT License

About

Autonomous lane detection and steering pipeline for CARLA simulator using Canny edge detection, Hough transforms, and ROI masking (Python, OpenCV, Pygame)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages