home Forums # Technical Support Problems about NAN values output

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2292
    Unknown
    Member

    Good morning Juan, first of all thank you Juan for your well coded library fuzzyLite. I’m in trouble about NAN values in C++ (1.#QNAN). I try to call engine->isready(“…”) function without sucess. I mean everything good with a bool returning 1. I give you my code (I was inspired by the multiple exemple). The input value is well set on engine, the error must be on the rules or on the defuzzification.

    Engine* GainController::mamdaniForKuka()
    {
    fl::Engine* FSys_ = new fl::Engine(“Kuka”);
    fl::InputVariable* position = new fl::InputVariable(“y”, 0.000, 1.000);
    position->setEnabled(true);
    position->addTerm(new fl::Triangle(“HIGH”, 1.000, 0.7000, 0.5000));
    position->addTerm(new fl::Triangle(“LESSHIGH”, 0.7000, 0.5000, 0.3000));
    position->addTerm(new fl::Triangle(“LOW”, 0.5000, 0.3000, 0.000));
    FSys_->addInputVariable(position);

    fl::OutputVariable* Weight = new OutputVariable(“w4”, 0.000, 80.000);
    Weight->setDefaultValue(fl::nan);
    Weight->setEnabled(true);
    Weight->setLockPreviousOutputValue(false);
    Weight->setLockOutputValueInRange(false);
    Weight->addTerm(new fl::Triangle(“LESSCONSTRAINT”, 1.000, 5.000, 10.000));
    Weight->addTerm(new fl::Triangle(“NORMALCONSTRAINT”, 5.000, 40.000, 60.000));
    Weight->addTerm(new fl::Triangle(“VERYCONSTRAINT”, 40.000, 60.000, 80.000));
    Weight->fuzzyOutput()->setAccumulation(new Maximum);
    Weight->setDefuzzifier(new Centroid(500));
    FSys_->addOutputVariable(Weight);

    fl::RuleBlock* ruleblock = new RuleBlock();
    ruleblock->setEnabled(true);
    ruleblock->setConjunction(new Minimum);
    ruleblock->setDisjunction(new Maximum);
    ruleblock->setActivation(new Minimum);
    ruleblock->addRule(fl::Rule::parse(“if y is HIGH then w4 is VERYCONSTRAINT”, FSys_));
    ruleblock->addRule(fl::Rule::parse(“if y is LESSHIGH then w4 is NORMALCONSTRAINT”, FSys_));
    ruleblock->addRule(fl::Rule::parse(“if y is LOW then w4 is LESSCONSTRAINT”, FSys_));
    FSys_->addRuleBlock(ruleblock);

    //FSys_->configure(“”, “”, “Minimum”, “Maximum”, “Centroid”);

    return FSys_;
    }

    void GainController::update()
    {
    if (cartesianObjectives_.size() == 1 && jointObjectives_.size() == 7)
    {
    std::string* status = new std::string();
    ofstream fichier(“GainControlerLog.txt”,ios::out|ios::app);
    if(fichier)
    {
    fichier << “\n”<<“\t enter on update”<<“\t.”;
    body_ = cartesianObjectives_[0]->getBody();
    fichier << “\n”<<“\t position : \t”<<body_.getPosition().z()<<“\t.”;
    FSys_->setInputValue(“y”,body_.getPosition().z());
    fichier << “\n”<<“\t set input value : Done “<<FSys_->getInputVariable(“y”)->getInputValue()<<“\t.”;
    Solve();
    fichier << “\n”<<“\t solving problems “<<“\t.”;
    fichier << “\n”<<“\t output value “<< FSys_->getOutputVariable(“w4”)->getOutputValue() <<“\t.”;
    FSys_->isReady(status);
    fichier << “\n”<<“\t Fuzzy system status “<< *status <<“;”<<FSys_->isReady(status)<<“\t.”;
    fichier << “\n”<<“\t Fuzzy number of rules block : “<<“;”<<FSys_->numberOfRuleBlocks()<<“\t.”;

    fichier.close();
    }
    else cerr<<“erreur”<<endl;
    }
    }

    void GainController::Solve()
    {
    FSys_->process();
    OutputVariable* outputVariable = FSys_->getOutputVariable(“w4”);
    outputVariable->defuzzify();
    outputValues = outputVariable->getOutputValue();
    }

    it’s an university project to control robot, thanks for helping me, it must probably be a noob error.
    Best regard

    the fairy Tingle

    #2293

    Hi,

    thank you for your post and your kind words.

    The best approach is to use QtFuzzyLite. You can use the either the commercial or the community version. I am sure that will help you a lot. If you still have problems, can you please post the code using the FuzzyLite Language?

    
    FL_LOG(engine->toString()); //or using
    FL_LOG(FllExporter().toString(engine));
    

    Thanks,

    Juan.

    #2294
    Unknown
    Member

    Yes, it’s working properly now (the order of the rank of my triangle terms wasn’t good), thank’s i’m now working with Qt fuzzylite community it’s more intuitive for visualizing. thanks

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.