Giter VIP home page Giter VIP logo

carla_exploration's Introduction

Carla Exploration

CARLA is an open source simulation based on the Unreal engine created for autonomous driving research. Although it's still very much under development, it has a lot to offer and this repository is meant to demonstrate some of the possible tasks that can be performed in the simulation. Specifically, I explored the capabilities of lidar, other sensors, pedestrian detection, and using reinforcement learning to build a self-driving agent in CARLA. For more information about CARLA, view the latest docs.

Getting Started

Prerequisites

Although this code should theoretically work on Linux, it was developed on a Windows 10 environment

To run any of the code in this repository, you will first need:

Installing

  1. Clone the repository to your local machine
  2. Change directory into the cloned repository
  3. Create a virtual environment in the cloned directory. Example: python3 -m venv carla_exploration_venv
  4. Activate the virtual environment. Example: carla_exploration_venv\scripts\activate on Windows
  5. Install the required packages from requirements.txt. Example: pip install -r requirements.txt

Contents of this repository

Lidar

The lidar raycast sensor in CARLA implements a rotating lidar using ray-casting. My goal was to attach a lidar sensor to a vehicle and create a point cloud animation of it passing another vehicle. Here's what I ended up with:

Point cloud animation gif of one car passing another

Since the lidar raycasts bounce off of the collision detector for each agent it interacts with rather than the visual texture, vehicles seen through lidar have significantly simplified models. In addition, I ran into issues using the SpringArm attachment type to attach the lidar sensor to the vehicle in CARLA 0.9.9. These issues will hopefully be fixed in the future.

Other Sensors

Carla has many other sensors including collision detectors, GNSS, IMU, lane inversion detectors, obstacle detectors, and radar. In addition, Carla offers RGB, depth, and semantic segmentation cameras. I was able to implement all of these sensors successfully and the documentation provided for these sensors is more than sufficient.

Pedestrian detection

I attempted pedestrian detection using the pretrained default person detector HOG model from OpenCV on RGB sensor data. I found that this model trained on real people was able to detect walkers in CARLA with relative accuracy. I tracked the distance from the camera to the pedestrian to determine the distance the sensor was able to start detecting true positive bounding boxes.

Pedestrian detection gif straight on

With the camera sensor going straight at the pedestrian, the model is able to safely produce true positive bounding boxes at around 12.2 meters. In order to test that the initial bounding boxes drawn around 25 - 30 meters were false positives, I moved the pedestrian a bit to the left.

Pedestrian detection gif from the side

Sure enough, the bounding box gets drawn anyways in the same area of the image and the model even draws two bounding boxes once it sees the real pedestrian. How exciting! Spending some time fine tuning the model would be beneficial to its accuracy, but this was just meant as an initial exploration. The default person detector model from OpenCV was able to detect artificial walkers in CARLA.

Building a Self Driving Agent

Unfortunately, my laptop ended up being a limiting factor in creating a self driving agent because it kept overheating and crashing. Disabling rendering may have been beneficial to performance. I was able to train an agent using deep Q learning to drive straight forward at 50kmh for 10 seconds. I used code from sentdex on pythonprogramming.net and I'd recommend checking out his tutorial if you're interested in learning more. The one thing to note is that he trains his model using multi-threading, and I was only able to get multi-threaded training working with Keras 2.2.5 and TensorFlow 1.14. This is the behavior of the model I trained to drive straight forward starting from various spawn points.

Self driving model test gif

CARLA is clearly meant for autonomous driving research and I'm sure it is possible to train a proper self driving agent in this simulation. Access to varied environments, a satisfactory amount of sensors to use for reward and punishment, and the ability to control multiple vehicles at once make CARLA an ideal simulation for autonomous driving research with the right hardware.

Built with

  • CARLA - Autonomous vehicle simulation
  • TensorFlow - Machine learning platform
  • OpenCV - Computer vision library

Authors

Acknowledgements

carla_exploration's People

Contributors

ryanhopkins7 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.