Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CarlaControl

A Windows desktop control panel for the CARLA autonomous-driving simulator. Instead of scripting CARLA by hand, you spawn and drive vehicles, choreograph timed movements, draw and replay paths, steer the camera, change weather and time of day, and record video — all from a WinForms UI that drives CARLA's Python API underneath.

build

📷 Add a screenshot or a short GIF of the UI driving the simulator here — this app is highly visual and a clip sells it instantly.

Platform: Windows, .NET 8 (WinForms) front-end + Python 3.7 CARLA scripts.


What it does

  • Actors: spawn vehicles/objects (with autopilot, freeze, and color options), list them, delete them, and read back their live coordinates.
  • Movement: move an actor to a point at a chosen velocity, move many actors at once, follow an actor with the spectator camera, or schedule sequences of timed moves.
  • Path drawing: draw vehicle paths into the world and replay recorded trajectories, with per-key color selection.
  • World: change map, set weather presets, time of day, and wind; toggle map layers.
  • Camera & video: move the spectator, record camera feeds, and convert recordings to MP4.
  • Scenes: save the full scene (actors + spectator + drawings) to disk and reload it later.

Architecture

CarlaControl is a two-process application: a C# front-end and a set of Python workers that hold the actual CARLA connection.

┌──────────────────────────┐        TCP  localhost:9999        ┌───────────────────────────┐
│  CarlaControl (C# / WinForms)  │ ──── text commands ────▶ │  carla_script.py --server │ ──▶ CARLA
│                          │ ◀── <BEGIN_OUTPUT>…<END_OUTPUT> │  (persistent CARLA client) │     simulator
│  Managers / Services / Models │                            └───────────────────────────┘
└──────────────────────────┘
        │  also launches, per task:
        ├─ carla_drawing.py        (path overlay, pygame)
        ├─ carla_recording.py      (camera capture → frames)
        ├─ carla_vehiclepath.py    (moving-path drawing)
        └─ carla_videoconverter.py (frames → MP4 via ffmpeg)
  • PythonScriptService runs a persistent Python "server" and exchanges newline-free text commands (spawn_object, move_actor_to, set_weather, …) over a TCP socket, parsing results delimited by <BEGIN_OUTPUT>…<END_OUTPUT>. If the server can't be reached it falls back to a stateless mode, launching Python once per command — so the UI keeps working even without the persistent connection.
  • ProcessManager owns the auxiliary long-running processes (recording, drawing, follow-camera), with lifecycle tracking and cleanup.
  • Managers/ Services/ Models/ keep the concerns separated: coordinate math, scheduled-move sequencing, actor bookkeeping, file I/O, and the DTOs (de)serialized with System.Text.Json / Newtonsoft.Json.

The C# side never imports CARLA — it treats the Python workers as a small command server, which keeps the heavy simulator dependency entirely on the Python side.

The Python components (PythonApp/)

Script Role
carla_script.py The command server — spawns/controls actors, weather, scenes; everything the UI drives
carla_drawing.py Interactive path/shape drawing overlay (pygame)
carla_vehiclepath.py Renders moving vehicle paths
carla_recording.py Captures camera feeds to a session folder
carla_videoconverter.py Stitches captured frames into MP4 (ffmpeg)
simple_vehicle_control.py Minimal manual driving script
update_z_coordinates.py Utility to snap saved coordinates to the road surface

Requirements

  • CARLA 0.9.x simulator running locally (default localhost:2000).
  • Python 3.7+ with carla, pygame, and numpy (CARLA's PythonAPI matches the simulator version).
  • .NET 8 SDK (Windows).
  • ffmpeg on PATH for the video-conversion step.

Setup & run

  1. Start CARLA (CarlaUE4.exe) so it's listening on localhost:2000.
  2. Prepare the Python workers. Globals.cs expects them as executables under dist/… (built with PyInstaller, e.g. pyinstaller --onedir PythonApp/carla_script.py). To run from source instead, point the paths in CarlaControl/Models/Globals.cs at python PythonApp/<script>.py.
  3. Build and run the C# app:
    dotnet build -c Release
    dotnet run -c Release --project CarlaControl
  4. In the app, start the Python server, then spawn actors and drive the simulator from the UI.

Repository layout

CarlaControl/            C# WinForms front-end
  Managers/              process + coordinate + scheduling logic
  Services/              Python bridge + file I/O
  Models/                DTOs, enums, and Globals (paths/config)
PythonApp/               the CARLA Python workers

Notes & scope

  • Built against CARLA 0.9.x; the command vocabulary lives in carla_script.py and mirrors the methods on PythonScriptService.
  • The build carries nullable-reference warnings typical of a large WinForms project; they are diagnostics, not defects.
  • The CARLA PythonAPI itself is not vendored here — install it from your CARLA distribution so versions match.

License

MIT — see LICENSE.

About

Windows desktop control panel for the CARLA autonomous-driving simulator (C# + Python).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages