This repo contains the main executable that runs on the Drivebrain embedded computer on HyTech Racing's cars. This code is deployed as a systemd service onto the car within HyTech's Raspberry Pi NixOS description. This service handles, among other things:
- high-performance control algorithm execution from both hand written c++ and MATLAB Simulink generated code c++
- car state estimation via both hand written c++ and MATLAB Simulink generated code c++
- Vectornav INS communication via Vectornav's driver
- live telemetry and data recording of all on-car inter-board communications (CAN and Ethernet mostly)
- car-level parameter servicing of all previously listed components via the integrated Foxglove websocket server
This is an active rewrite of an older iteration of Drivebrain, which you can find here.
This guide explains how to build the DriveBrain using the provided Docker cross-compilation environment.
- Docker installed on your system
- Local clone of the DriveBrain repository
Run the following command to build the dockerfile:
docker build -t kkittur/drivebrain_cross_compile .
It may take a few minutes.
Run the following command to start and enter the Docker container with the necessary volumes mounted:
docker compose run devAlternatively, if you want to enter a modified container for whatever reason, you can run:
# running with modified memory and cpu limits
docker run -it \
--mount type=volume,source=drivebrain_conan-cache,target=/root/.conan2 \
--mount type=bind,source="$(pwd)",target=/app \
--memory=16g \
--cpus=4 \
-w /app \
kkittur/drivebrain_cross_compile /bin/bash and pass in whatever flags you see fit.
Inside the container, execute:
./build_script.shThis script will build the DriveBrain software using the cross-compilation toolchain for the target platform. The first time you run it, it will take some time because it needs to compile all the dependencies. However, future builds past the first one take <1 minute because dependencies are cached.
Unit tests have to be compiled to your native architecture if you actually want to see them run. To do this, you can pass in the --test flag in the build script.
./build_script.sh --testand the project along with its unit tests will be compiled and ran.
- Make sure the build script has execute permissions:
chmod +x build_script.sh. - The build artifacts will be generated inside an autogenerated folder that's handled by Docker. You can access these artifacts for debugging by using
docker volume inspect.
Docker Desktop on Windows already runs inside a lightweight Linux VM (WSL2), so
the container itself is fast. The one thing that is slow is file access across
the Windows/Linux boundary. If the repo lives on a Windows path like
C:\Users\you\..., every file the build touches is read and written over that
boundary, and dependency-heavy steps (Conan, CMake, the Python venv) drop from
sub-second to minutes.
The Conan cache is already a Docker named volume, so it stays fast regardless.
The fix for everything else is to keep the source on the Linux side of the
boundary too. Clone the repo into the WSL2 filesystem, not into C:.
- Docker Desktop installed, with the WSL2 backend
- A real Ubuntu WSL distro (Docker's own
docker-desktopdistro does not count)
In PowerShell:
wsl --install -d UbuntuReboot if prompted. On first launch it asks you to create a Linux username and
password. Then make Ubuntu the default so a plain wsl never drops you into
Docker's distro as root:
wsl --set-default UbuntuConfirm it worked:
wsl -l -vUbuntu should be listed as VERSION 2.
Docker Desktop → Settings → Resources → WSL Integration. Turn on integration
with your default distro, and toggle Ubuntu on. Apply & Restart.
Enter wsl with the command wsl -d Ubuntu in powershell. Then run:
cd ~
git clone <drivebrain-remote-url> drivebrain
cd drivebrainThe rest is identical to the Linux/macOS instructions above, run from inside the
Ubuntu shell at ~/drivebrain:
docker build -t kkittur/drivebrain_cross_compile . # once
docker compose run dev
./build_script.sh