Environment-Aware Bot
Robotics · Autonomous Navigation

Environment-Aware Bot

C++ ESP32 Ultrasonic Radar IR Sensors State Machine SolidWorks
3 Autonomous Modes
180° Radar Sweep Arc
5+ Sensor Inputs

Project Overview

The Environment-Aware Bot is an exploration into reactive autonomy. Instead of hardcoded paths, the robot makes split-second decisions from live sensor feeds — a 180° ultrasonic radar sweep combined with multiple downward and forward-facing IR sensors.

The chassis was designed and modeled in SolidWorks before being fabricated, ensuring precise sensor placement and weight distribution for stable navigation at speed.

Navigation Modes

The system supports three primary autonomous behaviors, implemented as a clean modular state machine in C++. Switching between modes is triggered by environmental conditions in real time:

🎯
Object Following
Tracks and maintains distance to a moving object in the radar's field of view
🚧
Obstacle Avoidance
Detects and navigates around static obstacles using sweep scan data
⬇️
Edge Avoidance
IR sensors detect table edges and cliff drops to prevent falls
State Machine · Object Following Logic C++
void objectFollowing() {
    int distance = getRadarDistance();
    if (distance > 10 && distance < 30) {
        moveForward(SPEED_NORMAL);
    } else if (distance <= 10) {
        stopMotors();
    } else {
        scanForObject(); // Initiates sweeping motion
    }
}

Sensor Noise Filtering

A major challenge was the ultrasonic sensor's susceptibility to false positives from echo bouncing off low surfaces. I resolved this by implementing a median filter over multiple consecutive ping cycles, which smoothed the data curve significantly and eliminated phantom obstacle detections.

Signal Processing · Median Filter C++
int getFilteredDistance() {
    int readings[SAMPLE_COUNT];
    for (int i = 0; i < SAMPLE_COUNT; i++) {
        readings[i] = sonar.ping_cm();
        delay(5);
    }
    // Sort and return median
    sort(readings, readings + SAMPLE_COUNT);
    return readings[SAMPLE_COUNT / 2];
}

Need autonomous navigation logic for a custom robot?

Get in Touch ← All Projects