Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sparshg/fuzzy-controller
Fuzzy Controller to fly a simulated drone
https://github.com/sparshg/fuzzy-controller
Last synced: 3 months ago
JSON representation
Fuzzy Controller to fly a simulated drone
- Host: GitHub
- URL: https://github.com/sparshg/fuzzy-controller
- Owner: sparshg
- Created: 2023-09-17T19:27:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-23T09:38:13.000Z (about 1 year ago)
- Last Synced: 2024-05-15T14:38:48.323Z (6 months ago)
- Language: Rust
- Homepage:
- Size: 1.37 MB
- Stars: 79
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-quads - Fuzzy Drone Controller - a controller that uses Mamdani Fuzzy inference system to control a drone, simulated using a physics engine. (Apps or visualizations / Apps or visualizations: On top of macroquad)
README
# Fuzzy Drone Controller
## [Try on Web](https://sparshg.github.io/fuzzy-controller/)
## Notation Used
I have used these symbols throughout for the controllers, more information in the next section:
Controller 1 (Contols `amplitude`):
InputsOutputs
| | |
| :----: | :--------: |
| Y | Y Position Error|
| Vy | Y Velocity |
| | |
| :----: | :--------: |
|Z| Zero thrust amplitude|
|S| Small thrust amplitude|
|L| Large thrust amplitude|
Controller 2 (Contols `diff`)
InputsOutputs
| | |
| :----: | :--------: |
|X| X Position Error|
|Vx| X Velocity|
|Th| Angle from horizontal|
|W| Angular velocity|| | |
| :----: | :--------: |
| Z| Zero|
| NS/PS| Small (-/+) thrust difference|
| NM/PM| Medium (-/+) thrust difference|
| NL/PL| Large (-/+) thrust difference|
where Positive is the anti-clockwise direction
and Negative is the clockwise direction## Working
This is a controller that uses [Mamdani Fuzzy inference](https://in.mathworks.com/help/fuzzy/types-of-fuzzy-inference-systems.html) system to control a drone, simulated using a physics engine.
The drone has 2 thrusters controlled by 2 fuzzy controllers. The controllers analyze the current state of the system and output the required thrust for each thruster. One takes the `(y_pos, y_vel)` and computes an `amplitude`. The other one takes `(x_pos, x_vel, angle, ang_vel)` and computes a `diff`. Then the thrusters are assigned the forces given by `amplitude + diff` and `amplitude - diff`.
A fuzzy controller is a rule-based system that uses fuzzy logic to map inputs to outputs. We can often derive these rules by observing the system and using our intuition. For example,
```
if x_vel is positive: apply small negative force
if x_vel is negative: apply small positive force
```
We can further use and, or, not operators on fuzzy sets to create complex rules. To do this I overloaded the bitwise operators on the inputs. This creates a parse tree of the rules, which can be evaluated at the runtime to get the outputs.To use these abstract or "fuzzy" rules on exact or "crisp" values of inputs, we fuzzify the inputs. For example, a tilt of `1 rad` to the left can be defined as `80% positive` and `20% negative`, according to whatever membership functions we define. We can then apply these fuzzy rules to the fuzzy inputs to get fuzzy outputs. Finally, we defuzzify the fuzzy outputs to get crisp outputs.
## Build and RunInstall [Rust](https://www.rust-lang.org/tools/install), and then:
```
cargo run --release
```