Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kart

Side project from March 2018 — an experiment in driving a real kart while wearing a VR headset.

First try

A VR kart racing game that bridges a virtual Unreal Engine 4 world with a real Razor Crazy Cart XL. An Arduino Uno reads the physical accelerator pedal and drives the engine throttle through a DAC, while UE4 manages the game logic — track positioning, checkpoints, pickups, barriers — and can override throttle intensity in real time over serial.

Hardware

  • Razor Crazy Cart XL — the physical kart
  • Arduino Uno — reads the accelerator pedal (analog input) and outputs throttle voltage via an Adafruit MCP4725 12-bit DAC
  • VR headset & motion controllers — HTC Vive (or compatible SteamVR headset) for the in-game experience and controller calibration

Repository Structure

kart/
├── arduino/          Arduino firmware
│   ├── src/main/         Main firmware (pedal → DAC → engine)
│   ├── src/test_dac/     Standalone DAC test sketch
│   └── libraries/
│       ├── kart/             Shared protocol defines (also included by UE4)
│       └── Adafruit_MCP4725/ Vendored DAC library
├── ue4/              Unreal Engine 4.19 project
│   ├── Source/kart/      C++ game module
│   └── Content/          Blueprints, levels, meshes, materials, sounds
├── assets/           Source art (Blender), sounds (MP3), textures (JPG)
└── deploy.bat        Copies release build to network share

How It Works

  1. The Arduino reads pedal voltage, normalizes it to a 0–1 intensity, and outputs a corresponding throttle voltage (1.5–3.2 V) through the MCP4725 DAC.
  2. UE4 connects to the Arduino over serial (9600 baud, auto-detected COM port) using a background thread for non-blocking communication.
  3. The game can read current pedal/throttle intensity and set constraints — max intensity caps and periodic throttle cuts — to tie real-world kart behavior to in-game events (e.g. slow down on collision, cut throttle when out of track).
  4. A VR track system maps the physical driving space to virtual track geometry, tracking checkpoints, lap progress, and out-of-bounds detection.

Prerequisites

  • Windows (serial communication uses Win32 API)
  • Unreal Engine 4.19
  • Arduino IDE with the Adafruit_MCP4725 library (vendored in arduino/libraries/)
  • SteamVR-compatible headset and controllers

Building

UE4

Open ue4/kart.uproject in Unreal Engine 4.19 and build from the editor or via Unreal Build Tool.

Arduino

  1. Open arduino/src/main/main.ino in the Arduino IDE.
  2. Make sure the Arduino IDE library path includes arduino/libraries/ (for kart/shared_defines.h and Adafruit_MCP4725).
  3. Upload to the Arduino Uno.

Deploy

Run deploy.bat to mirror the packaged release build to the network share.

Serial Protocol

The Arduino and UE4 share command definitions via arduino/libraries/kart/shared_defines.h. Communication is binary at 9600 baud.

ID Command Direction Payload
1 CMD_GET_ACCELERATOR_INTENSITY UE4 → Arduino → UE4 Returns float
2 CMD_SET_ACCELERATOR_MAX_INTENSITY UE4 → Arduino Sends float
3 CMD_SET_ACCELERATOR_CUT_DELAY UE4 → Arduino Sends int
4 CMD_GET_THROTTLE_INTENSITY UE4 → Arduino → UE4 Returns float

On startup the Arduino sends its ID byte (77). UE4 scans COM ports for an "Arduino Uno" device and validates this ID to establish the connection.

License

MIT

About

Drive a cart with a VR headset

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages