Skip to the content
2 layers50 × 80 mmAI4R SENSORPCB, the printed circuit board in 3D

Autonomous RC car with cone-based lane keeping, ToF obstacle avoidance, and software-in-the-loop simulation using ROS2

Size
50 × 80 mm
Copper layers
2
Thickness
1.6 mm
Parts
25
Nets
67
Pads
184
Tracks, vias
304, 52
Pours
1
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
24 Nov 2025
Updated
24 Nov 2025

Overview

AI4R SENSORPCB is an open-source printed circuit board by pranavpai, from the pranavpai/Autonomous-RC-Car-AI-Project repository on GitHub, published under the MIT licence. It is a 2-layer board of 50 × 80 mm with 25 parts on 67 nets, routed with 304 tracks and 52 vias.

It is built around the FSM300, LD1117V33C and RP2040-ZERO. Its parts include 10 connectors, 3 ICs, 2 capacitors, 2 resistors and 1 transistor. It belongs with the sensors and measurement and robots and motor control boards and the RP2040 boards of this library.

Main components

3

README

README.md

Autonomous RC Car AI Project

Intelligent Lane-Keeping and Obstacle Avoidance for RC Scale Vehicles

ROS2 Humble Python 3.10+ Ubuntu 22.04 License: MIT Docker


A complete autonomous driving stack for RC-scale vehicles featuring real-time cone-based lane keeping, ToF-based obstacle avoidance, and a comprehensive software-in-the-loop simulation environment.


Watch the Demo

Click the image above to watch the RC car navigating different scenarios


Table of Contents


Overview

This project implements a complete autonomous driving system for a Traxxas RC car platform, developed as part of the AI for Robotics (ELEN90095) course. The system combines:

  • Real-time perception using YOLOv8-based cone detection and VL53L5CX Time-of-Flight sensors
  • Intelligent control policies for lane-keeping and obstacle avoidance with PD controllers
  • Software-in-the-loop simulation that mirrors real hardware for rapid policy development
  • Production-ready deployment with Docker containerization and web-based monitoring

The vehicle successfully navigates cone-defined tracks while dynamically avoiding obstacles, demonstrating the integration of computer vision, sensor fusion, and real-time control.


Key Features

FeatureDescription
Cone-Based Lane KeepingLinear regression on detected yellow/blue cones with proportional steering control
Obstacle AvoidanceMulti-zone ToF sensing with velocity-aware PD controller and emergency braking
Gap NavigationIntelligent maneuvering around obstacles when sufficient clearance exists
Sensor FusionIntegration of camera, ToF, IMU, LiDAR, and wheel encoder data
Simulation EnvironmentComplete SIL testing with realistic sensor noise models
Batch TestingAutomated regression testing across multiple track scenarios
Web InterfaceReal-time monitoring and control via browser-based dashboard
Docker DeploymentContainerized environment for reproducible builds

System Architecture

text
┌─────────────────────────────────────────────────────────────────────────┐
│                           PERCEPTION LAYER                               │
├─────────────────┬─────────────────┬─────────────────┬───────────────────┤
│   OAK-D Camera  │  VL53L5CX ToF   │   BNO08x IMU    │    RPLiDAR A1     │
│   (YOLOv8)      │   (4x4 Array)   │   (9-DOF)       │    (360°)         │
│   30 Hz         │   20 Hz         │   400 Hz        │    10 Hz          │
└────────┬────────┴────────┬────────┴────────┬────────┴─────────┬─────────┘
         │                 │                 │                   │
         ▼                 ▼                 ▼                   ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                          ROS2 MESSAGE LAYER                              │
│  /cone_points    /tof_sensor    /imu_sensor    /scan    /wheel_speed    │
└─────────────────────────────────┬───────────────────────────────────────┘
                                  │
                                  ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                           POLICY NODE                                    │
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐         │
│  │  Lane Keeping   │  │    Obstacle     │  │  Gap Navigation │         │
│  │  (Cone Fitting) │  │   Avoidance     │  │   (Maneuvering) │         │
│  │                 │  │   (PD Control)  │  │                 │         │
│  └────────┬────────┘  └────────┬────────┘  └────────┬────────┘         │
│           └────────────────────┼────────────────────┘                   │
│                                ▼                                         │

Hardware Platform

Vehicle Base

  • Platform: Traxxas RC Car (1:10 scale)
  • Wheelbase: 287mm
  • Track Width: 235mm
  • Max Speed: ~3.0 m/s
  • Steering Angle: ±30°

Compute Stack

ComponentRole
Raspberry Pi 4Main compute, ROS2 nodes
RP2040 Pico #1IMU interface (BNO08x)
RP2040 Pico #2Encoder & RC switch monitoring

Custom PCBs

  • AI4R-PIHAT: Raspberry Pi HAT for sensor/actuator routing
  • AI4R-SENSORPCB: Centralized sensor breakout board

Sensor Suite

SensorModelPurposeKey Specs
CameraOAK-DCone detection (YOLOv8)120° FOV, 30 Hz, 0.5-10m range
ToF ArrayVL53L5CXObstacle detection4×4 zones, 45° FOV, 20 Hz, ±5mm accuracy
IMUBNO08xOrientation & acceleration9-DOF, 400 Hz, auto-calibration
LiDARRPLiDAR A1Environment mapping360°, 10 Hz, 0.15-12m range
EncoderHall EffectSpeed estimation16.32 ticks/rev, period-based

Control Policies

Lane Keeping Policy

The lane-keeping system uses computer vision to detect yellow (left) and blue (right) cones, fitting linear trajectories to determine the road centerline.

python
# Simplified lane-keeping logic
if yellow_cones and blue_cones:
    centerline = (yellow_fit + blue_fit) / 2
elif yellow_cones:
    centerline = yellow_fit - ROAD_WIDTH/2
elif blue_cones:
    centerline = blue_fit + ROAD_WIDTH/2

lateral_error = evaluate_centerline(look_ahead_distance)
steering = -Kp * lateral_error

Key Parameters:

  • ROAD_WIDTH: 1000mm
  • LOOK_AHEAD_DISTANCE: 1000mm
  • Kp_STEER: 80.0

Obstacle Avoidance Policy

A velocity-aware PD controller monitors the ToF sensor array for obstacles, implementing graduated braking and emergency stop capabilities.

text
┌─────────────────────────────────────────────────────────┐
│                    ToF 4×4 Grid                         │
│  ┌───┬───┬───┬───┐                                      │
│  │ 0 │ 1 │ 2 │ 3 │  ← Zones 4-11 used for detection    │
│  ├───┼───┼───┼───┤                                      │
│  │ 4 │ 5 │ 6 │ 7 │  ← Center zones for forward sensing │
│  ├───┼───┼───┼───┤                                      │
│  │ 8 │ 9 │10 │11 │  ← Center zones for forward sensing │
│  ├───┼───┼───┼───┤                                      │
│  │12 │13 │14 │15 │                                      │
│  └───┴───┴───┴───┘                                      │
└─────────────────────────────────────────────────────────┘

Control Strategy:

  • P (Proportional): Responds to distance error from target
  • D (Derivative): Responds to rate of approach
  • Emergency Override: Hard brake if distance < 0.8m

Key Parameters:

  • BASE_TARGET_DISTANCE: 1.2m
  • EMERGENCY_BRAKE_DISTANCE: 0.8m
  • Kp_OBSTACLE: 80.0
  • Kd_OBSTACLE: 40.0

Gap Navigation (Maneuvering)

When an obstacle is detected but sufficient clearance exists on one side, the system calculates navigable gaps and steers around the obstacle.

python
# Gap calculation
gap_on_left = |obstacle_y - yellow_cones_y| - obstacle_width/2
gap_on_right = |obstacle_y - blue_cones_y| - obstacle_width/2

if max(gap_on_left, gap_on_right) >= MIN_GAP_WIDTH:
    steer_toward_larger_gap()
else:
    apply_pd_braking()

Key Parameters:

  • MIN_GAP_WIDTH: 0.35m
  • MANEUVER_DISTANCE_THRESHOLD: 1.6m
  • STEERING_BIAS_GAIN: 80.0

Simulation Framework

The project includes a comprehensive Software-in-the-Loop (SIL) simulation environment that publishes identical ROS2 topics as the real hardware, enabling rapid policy development and testing.

Features

  • Identical Interface: Same topics and message types as hardware
  • Realistic Sensor Models: Gaussian noise, dropout, detection probability
  • Vehicle Dynamics: Bicycle model with tire slip and motor lag
  • Performance Metrics: Automatic scoring and analysis
  • Batch Testing: Run multiple scenarios automatically
  • Video Recording: Auto-generated MP4 visualizations

Available Test Scenarios

ScenarioDescription
simple_straight.yamlBaseline straight track
s_curve.yamlTwo connected curves (20m)
s_curve_tight.yamlTighter radius curves
obstacle_course.yamlMultiple obstacles
obstacle_goldilocks.yamlSingle obstacle at optimal detection distance
obstacle_immediate_wall.yamlEmergency braking test
real_track_oct14.yamlReal measured track layout

Running Simulations

bash
# Single scenario test
ros2 launch ai4r_pkg quick_test.launch.py \
  scenario:=obstacle_goldilocks \
  real_time_factor:=5.0

# Batch testing
ros2 run ai4r_pkg batch_tester.py \
  test/scenarios/tracks/ \
  --filter "obstacle" \
  --timeout 120

Results are saved to sim_results/ including JSON logs, performance plots, and MP4 recordings.


Getting Started

Prerequisites

  • Ubuntu 22.04 LTS
  • ROS2 Humble
  • Python 3.10+
  • Docker (optional, for containerized deployment)

Installation

1. Clone the Repository
bash
git clone https://github.com/yourusername/Autonomous-RC-Car-AI-Project.git
cd Autonomous-RC-Car-AI-Project
2. Install ROS2 Humble

Follow the official ROS2 installation guide.

3. Build the ROS2 Workspace
bash
cd ros2_ws

# Source ROS2
source /opt/ros/humble/setup.bash

# Install dependencies
sudo rosdep init  # Only needed once
rosdep update
rosdep install -i --from-path src --rosdistro humble -y

# Build
colcon build

# Source the workspace
source install/setup.bash
4. (Optional) Build MCU Firmware
bash
cd mcu_ws/build
cmake .. && make
# Outputs: ai4r-sensors-rp1.uf2, ai4r-sensors-rp2.uf2
5. (Optional) Docker Deployment
bash
cd docker
docker-compose up -d
# Access web interface at http://localhost:8080

Sensor PCB Setup

For the sensor PCB parser node to work, grant read/write access to the serial ports:

bash
echo 'KERNEL=="ttyACM0", MODE="0666"' | sudo tee /etc/udev/rules.d/ttyACM0.rules
echo 'KERNEL=="ttyACM1", MODE="0666"' | sudo tee /etc/udev/rules.d/ttyACM1.rules
sudo udevadm control --reload-rules
sudo udevadm trigger

Usage

Launch Full System (Hardware)

bash
ros2 launch ai4r_pkg ai4r_bringup_launch.py

Launch Individual Components

bash
# Vehicle control only
ros2 launch ai4r_pkg traxxas_launch.py

# Sensors + cone detection
ros2 launch ai4r_pkg traxxas_imu_tof_cone_detector_launch.py

# Policy node only
ros2 launch ai4r_pkg policy_launch.py

# Camera streaming
ros2 launch ai4r_pkg camera_stream_launch.py

Manual Control

bash
ros2 run ai4r_pkg keyboard_teleop.py

Monitor Topics

bash
# List all topics
ros2 topic list

# View cone detections
ros2 topic echo /cone_points

# View ToF data
ros2 topic echo /tof_sensor_vl53l5cx

# Check topic frequency
ros2 topic hz /cone_points

Record Data

bash
ros2 bag record /cone_points /tof_sensor_vl53l5cx /imu_sensor /wheel_speed_m_per_sec

Project Structure

text
Autonomous-RC-Car-AI-Project/
├── ros2_ws/                        # Main ROS2 workspace
│   └── src/
│       ├── ai4r_pkg/               # Core package
│       │   ├── scripts/            # Python nodes
│       │   │   ├── policy_node.py  # Main control policy
│       │   │   ├── cone_detector_node.py
│       │   │   └── models/         # YOLOv8 models
│       │   ├── src/                # C++ nodes
│       │   ├── launch/             # Launch files
│       │   ├── config/             # Parameter files
│       │   ├── drivers/            # Hardware drivers
│       │   └── test/
│       │       ├── simulation/     # SIL framework
│       │       └── scenarios/      # Test tracks (YAML)
│       └── ai4r_interfaces/        # Custom messages
│
├── mcu_ws/                         # RP2040 Pico firmware
│   ├── ai4r-sensors-rp1.cpp        # IMU interface
│   ├── ai4r-sensors-rp2.cpp        # Encoder/RC switch
│   └── [libraries]/                # BNO08x, VL53L5CX, servo
│
├── docker/                         # Docker configuration
├── web_interface/                  # Browser-based dashboard

Troubleshooting

Build Error: rosidl_default_generators not found

bash
cd /path/to/repository
sudo chmod 777 -R .

ToF Sensor Not Detected

  1. Check I2C connection: i2cdetect -y 1
  2. Verify power supply (3.3V)
  3. Check sensor address conflicts

Camera Not Streaming

  1. Verify OAK-D is connected: lsusb | grep Movidius
  2. Install DepthAI: pip install depthai
  3. Check permissions: sudo usermod -aG video $USER

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.


Acknowledgments

  • Course: AI for Robotics (ELEN90095)
  • Institution: University of Melbourne
  • Platform: Traxxas RC Car
  • Frameworks: ROS2 Humble, YOLOv8, Pico SDK
  • Libraries: BNO08x, VL53L5CX, DepthAI

Built with ROS2 and Python

ROS2

Parts

25
QtyValueFootprintReferences
4Conn_01x04Connector_JST:JST_SH_SM04B-SRSS-TB_1x04-1MP_P1.00mm_HorizontalJ2, J3, J4, J5
4MountingHoleMountingHole:MountingHole_3.2mm_M3_DIN965_PadH1, H2, H3, H4
2Conn_01x03Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ7, J9
2RResistor_SMD:R_0805_2012MetricR1, R2
2RP2040-ZeroRP2040-Zero:RP2040-ZeroRP1, RP2
1100nFCapacitor_THT:CP_Radial_D4.0mm_P2.00mmC2
110uFCapacitor_THT:CP_Radial_D4.0mm_P2.00mmC1
12N3904Package_TO_SOT_THT:TO-92_InlineQ1
1Conn_01x10Connector_PinHeader_2.54mm:PinHeader_1x10_P2.54mm_VerticalJ8
1Conn_02x10_Odd_EvenConnector_PinHeader_2.54mm:PinHeader_2x10_P2.54mm_VerticalJ10
1Conn_02x11_Odd_EvenConnector_PinHeader_2.54mm:PinHeader_2x11_P2.54mm_VerticalJ6
1FSM300FSM300:FSM300U1
1LD1117V3.3Package_TO_SOT_THT:TO-220-3_VerticalU3
1SolderJumper_2_OpenJumper:SolderJumper-2_P1.3mm_Open_Pad1.0x1.5mmJP1
1USB_B_MiniConnector_USB:USB_Mini-B_Lumberg_2486_01_HorizontalJ11
1~Polulu2801RCSwitch:2801RCSwitchU2

More from pranavpai/Autonomous-RC-Car-AI-Project

1
  • 2 layers65 × 56 mmAI4R PIHAT, the printed circuit board in 3D

    AI4R PIHAT

    pranavpai/Autonomous-RC-Car-AI-Project

    Autonomous RC car with cone-based lane keeping, ToF obstacle avoidance, and software-in-the-loop simulation using ROS2

    15 parts2MIT

Similar boards

  • 6 layers127 × 64.4 mmKRUPS Capsule, the printed circuit board in 3D

    KRUPS Capsule

    krups/RockSatX-GHOST-Hardware

    Hardware files for the 2025 RockSat-X GHOST mission

    116 parts
  • 2 layers102 × 55 mmOpen KIoT, the printed circuit board in 3D

    Open KIoT

    voluta-coop/Open-KIoT

    Voluta.coop ha desarrollado esta PCB para solucionar problemas socioambientales, poniendo la tecnología al servicio de las personas y el medio ambiente.

    55 parts
  • 2 layers120.1 × 99.3 mmSingle WAS IMU POE, the printed circuit board in 3D

    Single WAS IMU POE

    farmerbriantee/Ace

    Modular Development of AOG

    41 parts7MIT
  • 4 layers190 × 160 mmPSU, the printed circuit board in 3D

    PSU

    skylar-slideshows/Digilog_Capstone

    92 parts3
  • 2 layers47.5 × 62.9 mmXBeeBreakoutBoard, the printed circuit board in 3D

    XBeeBreakoutBoard

    MSTRocketDesignTeam/Liquid-Engine-Controller

    Evolution of the RDT's Custom Liquid Engine Control Unit!

    13 parts2AGPL-3.0
  • 2 layers132.3 × 94.9 mmCheapino, the printed circuit board in 3D

    Cheapino

    tompi/cheapino

    An affordable split 36 keys keyboard

    59 parts1.2kCC-BY-4.0

Questions

How big is the AI4R SENSORPCB PCB?

It measures 50 × 80 mm and has 2 copper layers, 1.6 mm thick.

What parts does the AI4R SENSORPCB use?

25 parts, built around the FSM300, LD1117V33C and RP2040-ZERO. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the AI4R SENSORPCB KiCad files?

From the pranavpai/Autonomous-RC-Car-AI-Project repository on GitHub, at the commit this page was made from: the board is pcb_files/AI4R-SENSORPCB/AI4R-SENSORPCB.kicad_pcb and its schematic pcb_files/AI4R-PIHAT/AI4R-PIHAT.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the AI4R SENSORPCB design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).