DEV Community

Cover image for Carla Simulator 1 : How to Set Up CARLA Simulator – Toretto Style 🏎️🔥
Mitansh Gor
Mitansh Gor

Posted on

Carla Simulator 1 : How to Set Up CARLA Simulator – Toretto Style 🏎️🔥

Yo, it's Dom here 🏁. Family's everything to me, but today, I'm pulling over from the street races to drop some knowledge about setting up the CARLA simulator. We're about to step into a virtual world where precision meets adrenaline. Buckle up, because we're cruising through what CARLA is, why it's your ultimate driving ally, and how to set it up like a pro.

Image description

check Video.

What’s CARLA, and Why Do We Need It? 🛠️🚗

CARLA isn't just some fancy tool; it's the NOS of autonomous driving simulators. Built on Unreal Engine, this open-source bad boy helps you:

  • Train perception algorithms 🎯.
  • Learn driving policies.
  • Validate your autonomous systems safely without denting a single bumper.
  • From radars to cameras and even LIDAR, CARLA hooks up your virtual ride with every sensor imaginable. Need realistic urban setups? It’s got those. Want to replay every crash like a Fast & Furious movie? There's a recorder for that. 🌆🎥

Why Simulators Like CARLA Matter 🚦

So, why the heck do we need CARLA? Well, these simulators are game-changers for anyone in autonomous driving. You wouldn’t take your muscle car out on a high-speed chase without practicing first, right? The same goes for autonomous cars—they need to be trained in different environments and situations, and that's where CARLA comes in.

We use simulators like CARLA for:

  1. Training algorithms that teach cars to drive themselves (without causing a wreck).
  2. Testing perception systems (sensors that make sure the car sees everything it needs to).
  3. Learning driving policies (figuring out how to make the car follow the rules of the road and not blow through red lights).

Without simulators, self-driving cars would be like a race car driver trying to learn by just jumping into a car and going 200 mph without practice. You need to test the machine before hitting the real world. And trust me, we don’t want any bad surprises when we’re going full throttle.

Setting Up CARLA - Let's Get to Work 💻💥

Alright, now let’s get down to business. listen up! You wanna set up CARLA on a Linux VM? It's gonna be a wild ride, but I've got your back. Follow these steps like you're gunning for a 10-second quarter mile. Let's get this show on the road. 🔥

Download CARLA

First, hit up the CARLA GitHub repo to grab the carla-0.9.12-linux tarball. This is the start of your journey.

wget https://tiny.carla.org/carla-0-9-12-linux

You can’t drive a car without a motor, right? This tarball's gonna be your engine. Now, let’s crack that tarball open and release the power inside. Run the command.

tar -xzvf carla-0.9.12-linux

Install NVIDIA Drivers

If you’re running this on a beefy machine with a GPU (and you should be, because we’re going for high-speed performance here), we need to get the right drivers in place. Install the NVIDIA drivers:
sudo apt install nvidia-driver-535
Once the drivers are installed, you’ve gotta give your system a little restart to make sure everything kicks into gear using sudo reboot.
After rebooting, make sure your NVIDIA drivers are running smooth. Run nvidia-smi.

Install Vulkan Tools

Vulkan is your performance boost, just like nitrous on a muscle car. Install it with
sudo apt-get install vulkan-tools
We need all the performance we can get for this simulation. Think of Vulkan as your nitrous system—helps CARLA run smoother and faster.

Download and Install XQuartz

You can’t drive the machine if you can’t see the road. For that, we need XQuartz to get the display working on your Mac. Download it from url and install it.

SSH into the VM with X11 Forwarding

Now, you need to connect to your Linux VM from your Mac, with some special sauce (X11 forwarding). Use:

ssh -X <studentid>@host

Export Display Port

You’re not racing if you can’t see the track. Set the display port like this:

export DISPLAY=:0

This ensures you’re looking at the right display—your virtual cockpit

Export XDG_RUNTIME

For the system to know where to store the runtime files, do this:

export XDG_RUNTIME_DIR=/run/user/$(id -u)

Run this command to make sure everything’s running like a well-oiled machine vulkaninfo.

CARLA Python client

To make sure your machine can talk to the CARLA simulator server, you're gonna need the CARLA Python client. Let’s get it installed fast, like we're revving up for a race. 🏁

Run this command in your terminal:

pip install carla

Start Simulator

Alright, you’ve done the hard work. Now it’s time to hit the gas! 🏁
Let’s fire up CARLA and see what this machine can do. Run the command below, and watch the magic happen. 🚗💨

./CarlaUE4.sh -vulkan

Boom, you're in the driver’s seat. CARLA’s about to show you what real simulation looks like. Let’s roll! 👊

If you hit an error saying it can't access the display, it's like your car's stuck in the garage and the door won’t open. 🚗💥 Time to unlock that door with:

xhost +local:root

if you're still facing display issues, let's put the pedal to the metal and get creative. 💥
Hit it with this command:

export DISPLAY=localhost:10.0

Connect to Your Cloud VM Using VNC

we need to get that simulator running on the cloud VM and beam it over to your local machine. Think of it like driving a car in the clouds and watching it on your own screen.

We’re gonna use SSH tunneling to forward the port where the CARLA simulator is running in the VM to your local screen. It's like connecting the engine to the wheels. 🏎️
ssh -L <VM_simulator_port>:localhost:5901 <your_vm_username>@<vm_ip_address>

Now, you should be seeing the CARLA simulator on your local screen. It’s like you’ve got the wheel in your hands while the car’s on the cloud. 🌩️

What You'll See 🌟

Just like how I always say, “I live my life a quarter mile at a time,” with CARLA, you can take your simulations step by step. It’s not just about fast cars—it’s about using the right tools to get things done the right way. So, whether you’re testing driving policies, training perception algorithms, or just want to feel the thrill of autonomous driving, CARLA’s your ticket.

Now go out there, hit the gas, and get started with CARLA. It’s a wild ride, but you’ve got the skills to drive it home. 🏁

Family’s got your back!


Hold tight because, in the next blog, we’ll dive into adding cars, walkers, and more into CARLA. And who better to take the wheel for that than my close friend, right-hand man, and brother, Brian O’Conner?

Stay tuned—he’s up next. 🔥
Dominic Toretto, signing off. 🏎️💨
check Blog 2 of Carla Simulator.

Top comments (0)