Code Monkey home page Code Monkey logo

fuzzy-yaml's Introduction

fuzzy-yaml

Fuzzy logic control C++ library loaded from a YAML config file

This is a refactored version of the source code originally used in the following paper

B. P. Putra, G. S. Mahardika, M. Faris, and A. I. Cahyadi, "Humanoid Robot Pitch Axis Stabilization using Linear Quadratic Regulator with Fuzzy Logic and Capture Point", arXiv [cs.RO]. 2021.

Instead of using arrays for storing the linguistic sets, key-value maps are utilized for a more natural way of accessing them by calling their respective string key.

Note: As of May 2024, this library is only applicable for the Mamdani type-1 fuzzy inference system with:

  • trapezoid and triangle membership functions, and
  • 2-dimensional rule table with AND operation

However, contributions for additional features are welcome.

Dependencies

  1. CMake

  2. Boost

  3. yaml-cpp

Build & Run

  1. Make sure you have installed the dependencies.

  2. Open a new command line terminal. Clone the repository

    git clone https://github.com/BagaskaraPutra/fuzzy-yaml.git
  3. Build the project using CMake.

    cd fuzzy-yaml
    mkdir build
    cd build
    cmake ..
    make
  4. The example executable files will be generated in the build/examples/ directory.

  5. Run the executable, for example:

    ./examples/multiAnklePitch
  6. If you wish to run other YAML config files, add the file path after the executable. For example:

    ./examples/anklePitch ../config/allTrapezoidAnklePitch.yaml

Tutorial

A typical YAML config file for the fuzzy-yaml library consists of three main nodes:

inputVariables:
  ...
outputVariables:
  ...
ruleBase:
  ...

The inputVariables node is structured as:

inputVariables:
  Crisp input variable 1:
    memberships:
      Linguistic fuzzy input variable 1.1:
        type: ...
        ...
      Linguistic fuzzy input variable 1.2:
        type: ...
        ...
  Crisp input variable 2:
    memberships:
      Linguistic fuzzy input variable 2.1:
        type: ...
        ...
      Linguistic fuzzy input variable 2.2:
        type: ...
        ...
    ...

Similarly for the outputVariables node:

outputVariables:
  Crisp output variable 1:
    memberships:
      Linguistic fuzzy output variable 1.1:
        type: ...
        ...
    defuzzifier: ...
  Crisp output variable 2:
    memberships:
      Linguistic fuzzy output variable 2.1:
        type: ...
        ...
    defuzzifier: ...
  ...

For the outputVariables node, we have an additional defuzzifier method parameter. As of now, only the centroid defuzzifier method is available.

On the other hand, the ruleBase node consists of the following structure:

ruleBase:
  Crisp output variable 1:
    # rules
    ...
  Crisp output variable 2:
    # rules
    ...

For now, the ruleBase only accepts the 2-dimensional table format. For example in the examples/anklePitch.yaml file, the rule table

ruleBase:
  Kp:
    row_variable: Angle
    row_values: [NegativeHigh, Negative, Positive, PositiveHigh]
    column_variable: AngularVelocity
    column_values: [Negative, Average, Positive]
    operator: AND
    table: 
      - [High, High, High]
      - [Medium, Medium, Medium]
      - [Zero, Zero, Zero]
      - [High, High, High]

is equivalent to having the following 12 fuzzy rules:

  • IF Angle is NegativeHigh AND AngularVelocity is Negative THEN Kp is High
  • IF Angle is Negative AND AngularVelocity is Negative THEN Kp is Medium
  • IF Angle is Positive AND AngularVelocity is Negative THEN Kp is Zero
  • ...
  • IF Angle is PositiveHigh AND AngularVelocity is Positive THEN Kp is High

Citation

If you intend to use this code in your work, you may cite it as:

@misc{putra2021humanoid,
      title={Humanoid Robot Pitch Axis Stabilization using Linear Quadratic Regulator with Fuzzy Logic and Capture Point}, 
      author={Bagaskara Primastya Putra and Gabrielle Satya Mahardika and Muhammad Faris and Adha Imam Cahyadi},
      year={2021},
      eprint={2012.10867},
      archivePrefix={arXiv},
      primaryClass={cs.RO}
}

fuzzy-yaml's People

Contributors

bagaskaraputra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.