Warning
This repository is under active development. This file explains the overall idea of the project and may include information about systems that are not yet implemented. See the “Goals of the project” section below for the current implementation status.
This repository contains code that enables you to build a model of an autonomous car. The car collects various data such as:
- Steering angle
- Current driving speed
- Camera view
Data collected from wheel encoders and servos, providing real feedback, can be used for systems like PID control, course correction, and machine learning.
Table of contents
- Manual steering
- Course mapping
- Simple course following
- Advanced course following
- Course navigation
Implemented functionalities are marked.
Here is the list of the main components used for this project. These are the components required for the current state of the software. The links are provided for your convenience only; I am in no way affiliated with the sellers.
- Jetson Orin Nano Developer Kit
- 4x DDSM400 Wheel Servo
- DDSM Driver Board
- 2x Servo Motor with High-Precision Magnetic Encoder
- Servo Driver Board
- 12 V battery (see power layout section)
- 4x Suspension for DDSM400
- 512 GB M.2 NVMe SSD
This section will be expanded.
Using driver boards simplifies the power layout, but appropriate connectors are needed. The Jetson can be safely powered from the same battery as the rest of the components, but it requires a high-quality regulator in between. Currently considering DFRobot.
Device | Voltage range | Max current | Connector |
---|---|---|---|
Servo (single) | DC 6–12.6 V | 2.4 A | PH2.0×3P |
Servo driver board | DC 6–12 V | 4.8 A1 | 5.5×2.1 mm DC power jack |
DDSM400 (single) | DC 9–28 V | 2.4 A | PH2.0×4P |
DDSM400 driver board | DC 9–28 V | 9.6 A1 | 5.5×2.5 mm DC power jack or XT60 |
Jetson Orin Nano | DC 9–20 V | ~2.3 A | 5.5×2.5 mm DC power jack |
This section will be expanded.
There are two main parts of the software:
- Arduino code for the driver boards
- Python code running on the Jetson
This will be changed in the future to simplify the communication protocol.
I am using the default example code provided by Waveshare. It comes with a lot of features, but this project uses JSON communication over UART.
Communication protocol is subject to change.
The provided code (servoDriver.ino
) implements a very simple communication protocol.
- Feedback enable command
FBK
, e.g.,FBK20
enables a 20 ms response loop. - Steering command
CMD
, e.g.,CMD90;90
steers both servos to 90°.
The driver board responds with an ACK
command every time, e.g., ACK20
for FBK20
and ACK45;135
for CMD45;135
.
This section will be updated when new modules are implemented.
The Python code is built as modules, which are then imported into the main.py
file that orchestrates execution. The flow is separated into two parts:
- Setup stage
- Launching workers
Every module implements a class with two methods, setup()
and startWorker()
, corresponding to the two stages of execution.
setup()
launches tasks that prepare the module for actual work. This may include checking if devices are connected, creating files for writing, or opening serial connections. This step is crucial for synchronizing all devices.startWorker()
launches all tasks that need to be parallelized within the module.
To abstract thread creation, I use Python’s ThreadPoolExecutor
from concurrent.futures
.
Setup schematic:
Worker launching schematic; each oval represents a thread inside ThreadPoolExecutor
:
This section will be expanded.
To set up the Jetson, follow the official guide. Then use the Arduino IDE to flash the driver boards with the provided code. The last step is to set up the Python code on your Jetson device:
git clone https://github.com/M1chol/jetson-car
cd jetson-car
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python main.py
This project is licensed under the Apache License, Version 2.0, modified with the Commons Clause. See https://commonsclause.com/ for more information.
Proofread with AI assistance