LEADS is a lightweight embedded assisted driving system. It is designed to simplify the development of the
instrumentation and control system for electric vehicles. It is written in well-organized Python and C/C++ with
impressive performance. It is not only plug-and-play
(the VeC Project) but also fully customizable. It provides
multiple abstract layers that allow users to pull out the components and rearrange them into a new project. You can
either configure the existing executable module leads_vec and leads_vec_rc simply through a JSON file or write your
own codes based on the framework as easily as building a LEGO.
The hardware components chosen for this project are geared towards amateur developers. It uses neither a CAN bus nor any dedicated circuit board, but generic development kits such as Raspberry Pi and Arduino instead. However, as it is a high-level system running on a host computer, the software framework has the ability to adapt to any type of hardware component if you are willing to write some codes.
This document will guide you through LEADS VeC. You will find a detailed version here.
LEADS VeC Demo
LEADS VeC Demo (Manual Mode)
🔗 Docs
🔗 Remote Analyst Online Dashboard
- Modern UI design
- Auto dark mode support
- Fancy widgets
- TCP communication system
- Remote analyst
- Replaying recorded data
- Data recording system with the following components
- A speed recording system
- A G force recording system
- A GPS recording system
- A battery voltage recording system
- ESC with the following components
- DTCS (Dynamic Traction Control System)
- ABS (Anti-lock Braking System)
- EBI (Emergency Braking Intervention)
- ATBS (Automatic Trail Braking System)
The codes are never designed for average high school students to understand. You may find it hard to read the codes if you do not satisfy the following requirements of skills and knowledge.
- Advanced Python knowledge (you should be familiar with everything and even programming philosophy in Python)
- Solid knowledge of Physics (you should understand how a car moves in reality)
- Basic embedded development experience (C/C++, Raspberry Pi, Arduino, serial communication, PWM)
- Rich experience in Web development (React, Next.js, FastAPI, TCP/IP, sockets)
- Basic machine learning knowledge (linear regression, polynomial regression)
Note that LEADS requires Python >= 3.12. To set up the environment on a Raspberry Pi by only a single line of command, see Environment Setup.
pip install Pillow customtkinter pynput pyserial lgpio gpiozero pynmea2 leadsnumpy and pandas will be automatically installed with leads.
Pillow, customtkinter, pynput, pyserial, lgpio, gpiozero, and pynmea2 are optional.
If you only want the framework, run the following.
pip install leadspython -m leads_vec infoYou can install LEADS-Arduino from Arduino Library Manager. Note that it is named "LEADS", not "LEADS-Arduino", in the index.
See Read the Docs for the documentation of how to customize and make use of the framework in your project.
python -m leads_vec runRun the following to get a list of all the supported arguments.
python -m leads_vec -hpython -m leads_vec -c path/to/the/config/file.json runIf not specified, all configurations will be default values.
To learn about the configuration file, read Configurations.
python -m leads_vec -d path/to/the/devices.py runTo learn about the devices module, read Devices Module.
python -m leads_vec -r config runThis will generate a default "config.json" file under the current directory.
python -m leads_vec -r systemd runThis will register a system service to start the program.
To enable auto-start at boot, run the following.
systemctl daemon-reload
systemctl enable leads_vecpython -m leads_vec -t path/to/the/theme.json runTo learn about themes, read Color and Themes.
python -m leads_vec -mfs 1.5 runThis will magnify all font sizes by 1.5.
python -m leads_vec --emu runThis will force the program to use emulation even if the environment is available.
python -m leads_vec --auto-mfs runSimilar to Magnify Font Sizes, but instead of manually deciding the factor, the program will automatically calculate the best factor to keep the original proportion as designed.
python -m leads_vec_rcGo to the online dashboard at https://leads-vec-rc.projectneura.org.
Run the following to get a list of all the supported arguments.
python -m leads_vec_rc -hpython -m leads_vec_rc -p 80If not specified, the port is 8000 by default.
python -m leads_vec_rc -c path/to/the/config/file.jsonIf not specified, all configurations will be default values.
To learn about the configuration file, read Configurations.
If you install Python using the scripts, you will not find python ..., python3 ..., pip ..., or pip3 ... working
because you have to specify the Python version such that python3.12 ... and python3.12 -m pip ....
This section helps you set up the identical environment we have for the VeC project. A more detailed guide of reproduction is available here, but first of all, we run an Ubuntu 22.04 LTS on a Raspberry Pi 4 Model B 8GB. After the OS is set up, just run the one-line commands listed below. You may also choose to clone the repository or download the scripts from releases (only stable releases provide scripts).
You can simply run "setup.sh" and it will install everything including LEADS for you. If anything goes wrong, you can also manually install everything.
/bin/sh "setup.sh$(wget -O setup.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/setup.sh)" && rm setup.sh || rm setup.shWe also use OBS Studio for streaming, but it is not required. If you want to install, run "obs-install.sh".
/bin/sh "obs-install.sh$(wget -O obs-install.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/obs-install.sh)" && rm obs-install.sh || rm obs-install.shDo not run the OBS Studio directly, instead, use "obs-run.sh".
wget -O obs-run.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/obs-run.sh
/bin/sh obs-run.shThe configuration is a JSON file that has the following settings. You can have an empty configuration file like the following as all the settings are optional.
{}Note that a purely empty file could cause an error.
| Index | Type | Usage | Used By | Default |
|---|---|---|---|---|
w_debug_level |
str |
"DEBUG", "INFO", "WARN", "ERROR" |
Main, Remote | "DEBUG" |
data_seq_size |
int |
Buffer size of history data | Main | 100 |
data_dir |
str |
The directory for the data recording system | Remote | "data" |
width |
int |
Window width | Main | 720 |
height |
int |
Window height | Main | 480 |
fullscreen |
bool |
True: auto maximize; False: window mode |
Main | False |
no_title_bar |
bool |
True: no title bar; False: default title bar |
Main | False |
theme_mode |
bool |
"system", "light", "dark" |
Main | False |
manual_mode |
bool |
True: hide control system; False: show control system |
Main | False |
refresh_rate |
int |
GUI frame per second | Main | 30 |
m_ratio |
float |
Meter widget size ratio | Main | 0.7 |
font_size_small |
int |
Small font size | Main | 14 |
font_size_medium |
int |
Medium font size | Main | 28 |
font_size_large |
int |
Large font size | Main | 42 |
font_size_x_large |
int |
Extra large font size | Main | 56 |
comm_addr |
str |
Communication server address | Remote | "127.0.0.1" |
comm_port |
int |
The port on which the communication system runs on | Main, Remote | 16900 |
save_data |
bool |
True: save data; False: discard data |
Remote | False |
from leads import controller, MAIN_CONTROLLER
from leads_emulation import RandomController
@controller(MAIN_CONTROLLER)
class MainController(RandomController):
passThe devices module will be executed after configuration registration. Register your devices in this module using AOP paradigm. A more detailed explanation can be found here.
Our team management completely relies on GitHub. Tasks are published and assigned as issues. You will be notified if you are assigned to certain tasks. However, you may also join other discussions for which you are not responsible.
There are a few labels that classify the issues.
bugreports a bugcode reviewdiscusses a code review or commentdocumentationsuggests a documentation enhancementduplicatemarks that a similar issue has been raisedenhancementproposes a new feature or requesthelp wantedmeans that extra attention is needed to this issueinvalidmarks that the issue is in a valid formatquestionrequests further informationreportstates that it is discussed in the meetingtodocreates a new taskwontfixmarks that the issue is ignored
Label your issue with at least one of the labels above before you submit.
You can have a look at the whole schedule of each project in a timeline using the projects feature.
See CONTRIBUTING.md.



