A reactive programming implementation of an autonomous line-following robot with advanced features including obstacle detection, avoidance, and automated parking capabilities.
This project implements a sophisticated line-following robot using a state machine architecture. The robot can follow both white and black lines, navigate around obstacles, and perform autonomous parking maneuvers when reaching designated parking areas.
- Kush Mangukiya (24M0769)
- Jasbir Singh Kalsi (24M0745)
- Ashutosh Birla (24M0752)
- Dual Line Following: Supports both white line and black line following
- Adaptive Calibration: Automatic sensor calibration during startup
- PID Control: Smooth line following with proportional-integral-derivative control
- Obstacle Detection: Three-sensor IR obstacle detection system
- Obstacle Avoidance: Right-hand wall following algorithm for obstacle navigation
- Autonomous Parking: Automatic parking detection and execution
- U-turn Recovery: Automatic recovery when line is lost
- State-based Architecture: Robust finite state machine implementation
-
5 Line Sensors: Array of IR sensors for line detection (
sen[0]tosen[4])sen[0]: Leftmost sensorsen[1]: Left-center sensorsen[2]: Center sensorsen[3]: Right-center sensorsen[4]: Rightmost sensor
-
3 Obstacle Sensors: IR proximity sensors for obstacle detection
irsenLeft: Left obstacle sensorirsenFront: Front obstacle sensorirsenRight: Right obstacle sensor
- 2 Motors: Differential drive system
- Left motor speed:
v_l - Right motor speed:
v_r
- Left motor speed:
- Direction Control: Movement direction indicator
- Purpose: Initial calibration phase
- Duration: 3000 cycles for sensor averaging
- Function: Calculates baseline sensor values for white surface detection
- Purpose: White line following mode
- Features:
- PID control with gains (Kp=3, Ki=0.001, Kd=1)
- Speed adjustment based on error magnitude
- Transition detection for line intersections
- Purpose: Handles line color transitions (white to black)
- Features:
- Modified PID gains (Kp=2, Ki=0.001, Kd=1)
- Inverted sensor logic for black line detection
- Right turn detection capability
- Purpose: Black line following mode
- Features:
- Enhanced PID control (Kp=3, Ki=0.001, Kd=1)
- Intersection counting for parking detection
- U-turn detection and recovery
- Turns right when obstacle detected
- Continues until left sensor clears
- Moves forward along obstacle edge
- Monitors for line reacquisition
- Follows left wall of obstacle
- Handles complex obstacle shapes
- Final turn to rejoin line after obstacle
- Ensures proper line reacquisition
- Navigation Pattern: Follows predefined timing sequence
- Parking Detection: Uses IR sensors at specific intervals
- Decision Logic:
- Both sensors clear → Go straight
- Left clear, right blocked → Park right
- Left blocked, right clear → Park left
- Both blocked → Default left
- Duration: 1800 cycles
- Phases:
- Approach (500 cycles): Move forward
- Turn (1200 cycles): Execute parking maneuver
- Align (100 cycles): Final positioning
- Final state - robot stops permanently
- All outputs set to zero
-
White Surface Calibration (3000 cycles):
- Robot placed on white surface
- Sensors accumulate baseline readings
- Average values calculated automatically
-
Threshold Setting:
- Black line threshold = white_average - 150
- Binary conversion: sensor ≤ threshold → line detected