This project implements a fuzzy logic controller using Python and scikit-fuzzy to determine a robot's movement speed based on the distance to an obstacle. The system simulates how a robot should slow down or stop as it approaches an object, mimicking human-like reasoning under uncertainty.
The goal is to understand and implement a fuzzy logic system to solve a real-world control problem using:
- Fuzzy sets and membership functions
- Fuzzy rules
- A fuzzy inference engine
- Defuzzification to produce actionable outputs
In uncertain environments, robots need to make decisions based on incomplete or imprecise information. This system models a robot that adjusts its speed based on how far it is from an obstacle:
- Close obstacle → Stop
- Medium distance → Slow down
- Far distance → Move fast
- Distance (cm):
0 to 100- Fuzzy sets:
Close,Medium,Far
- Fuzzy sets:
- Speed (0 to 10 units):
- Fuzzy sets:
Stop,Slow,Fast
- Fuzzy sets:
- If distance is close, then speed is stop
- If distance is medium, then speed is slow
- If distance is far, then speed is fast
- If distance is close AND medium, then speed is stop
- If distance is medium AND far, then speed is slow
- Language: Python 3.x
- Library:
scikit-fuzzy - Visualization:
matplotlib
pip install scikit-fuzzy matplotlib numpy- Open the Jupyter notebook and execute the cells sequentially.
- Fuzzy Sets and Membership Functions: Define input and output fuzzy sets and their corresponding membership functions.
- Fuzzy Rules and Inference: Design fuzzy rules and implement the inference engine.
- Testing: Test the system with sample input values (e.g., distances) and visualize the results.
- Visualizations: View graphs of membership functions and output results.
The script:
- Defines fuzzy sets and membership functions
- Creates fuzzy rules
- Runs the fuzzy inference system
- Tests with various distances
- Outputs results and plots
Distance (cm) → Speed (0–10)
-----------------------------
10 → 0.75
30 → 2.42
50 → 4.84
70 → 7.25
90 → 9.12
- Membership functions for
distanceandspeed - Inferred output graphs for each input scenario
The fuzzy logic controller successfully models gradual and safe decision-making for robot navigation based on obstacle distance. The system demonstrates smooth transitions, robustness to uncertain input, and ease of rule modification.