Skip to content

williankeller/car-lidar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

Robot Car with LiDAR

Robot Car with LiDAR is a project to build a robot car with a LiDAR sensor to navigate the environment and avoid obstacles. The car uses a tank track with 4 DC motors. It can be controlled by a remote control or can be driven autonomously.

There are 3 operational modes: Manual, Autonomous, and Semi-Auto.

  • Manual mode is controlled by a remote control (LiDAR disabled).
  • Autonomous mode is controlled by the LiDAR sensor with smart navigation.
  • Semi-Auto mode is a combination of the Manual and Autonomous modes, it can avoid obstacles even when it is controlled by the RC.

Smart Navigation System

The autonomous mode uses a Vector Field Histogram (VFH) inspired algorithm for intelligent obstacle avoidance. Instead of simple reactive turns, the robot builds a spatial model of its surroundings and selects the probabilistically best path.

How It Works

  1. Sector-Based Mapping - The 180° front field-of-view is divided into 12 sectors (15° each). Each LiDAR point is accumulated into its corresponding sector, building an obstacle density histogram per full scan.

  2. Weighted Density Scoring - Closer obstacles contribute exponentially more to a sector's density using inverse-square weighting (1/d²). This makes the robot more sensitive to nearby threats while still accounting for distant objects.

  3. Multi-Factor Path Selection - Each sector is scored by combining:

    • Openness (primary) - sectors with less obstacle density score higher.
    • Distance - prefers paths where the nearest obstacle is further away.
    • Gap Width - favors wider openings by checking adjacent sectors.
    • Center Preference - slight bonus for going straight to avoid unnecessary deviation.
    • Heading Continuity - prefers directions close to the current heading for smoother motion.
  4. Proportional Steering - Instead of binary hard-left/hard-right turns, steering is proportional to how far the best path is from the current heading, producing smooth, natural turns.

  5. Temporal Smoothing - An exponential moving average blends current and previous scans (alpha = 0.3) to filter out noise and prevent erratic oscillation.

  6. Graduated Speed Control - The robot slows down proportionally as it approaches obstacles:

    • Full speed when clear (> 35cm).
    • Linear deceleration from 35cm down to 16cm.
    • Emergency stop and smart reverse at 16cm or closer.

Tunable Parameters

Parameter Default Description
NUM_SECTORS 12 Number of angular sectors (higher = finer resolution)
SMOOTHING_ALPHA 0.3 Temporal smoothing factor (lower = smoother, slower reaction)
MAX_LIDAR_DISTANCE_CM 50 Maximum detection range in cm
SLOW_DOWN_DISTANCE_CM 35 Distance at which the robot begins to decelerate
MIN_SAFE_DISTANCE_CM 16 Emergency stop distance threshold

Hardware

Components

Pin Configuration

Motors (via L298N)

Pin Function
2 Left Motor Direction 1
3 Left Motor Direction 2
4 Right Motor Direction 1
5 Right Motor Direction 2
6 Left Motor Speed (PWM)
7 Right Motor Speed (PWM)

RP LiDAR Motor

Wire Function
Purple PWM control (Pin 8)
Yellow Motor GND
Red Motor +5V

The LiDAR motor runs at 9V. The PWM wire is connected to Arduino Mega Pin 8 to control motor speed.

RP LiDAR Sensor (Serial1)

Wire Function
White Ground
Black 5V
Orange RX
Green TX

RC Receiver (IBus protocol on Serial2)

Channel Function
CH1 Left / Right steering
CH2 Forward / Reverse
CH3 Throttle
CH4 Rudder (unused)
CH5 (AUX1) Mode selector (< 10 = Manual, > 10 = Autonomous)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages