home › Forums › # Technical Support › Unhandled exception
- This topic has 3 replies, 2 voices, and was last updated 4 years, 5 months ago by
Juan Rada-Vilela (admin).
-
AuthorPosts
-
March 31, 2019 at 06:51 #6358
Unknown
MemberHi, I was wondering if I could get some help with the problem am having.
So, I am using fuzzylite library in VS, and everything seems to work fine, I have set up my two inputs and outputs. But when I try to use “engine->process();” the next line of code that comes after this always gives me an Unhandled exception. And I cant figure out how to fix this, as without it all am getting for my outputs are 0.000;
Heres a small code sniped of what am talking about.
engine->getInputVariable(0)->setValue(-1.000); engine->getInputVariable(1)->setValue(-1.000); engine->process(); OutputVariable* outputVariable = engine->getOutputVariable(0);// this always gives me and error after using process printf("%f\n", outputVariable->fuzzyOutputValue());
March 31, 2019 at 08:09 #6359Juan Rada-Vilela (admin)
KeymasterHi,
Thanks for your post.
Can you try printing the engine to string? “engine->toString()”
It seems you do not have the output variable in your engine.
Also, you might try getting some additional information by using “engine->isReady()”? Check the documentation.
Cheers.
March 31, 2019 at 08:22 #6360Unknown
MemberHi, thanks for the quick reply.
When using “engine->toString()” it does print out my two inputs, output, and all its proportions as well as my Rule Block. But no matter what I do, I can’t seem to get my output based on mt data input or defuzzify it.
Any help is appreciated.
Here is my code if that helps at all
int main(int argc, char* argv[]) { using namespace fl; Engine* engine = new Engine; engine->setName("CAR_AI"); engine->setDescription(""); InputVariable* DistanceVariableInput = new InputVariable; DistanceVariableInput->setName("DistanceVariableInput"); DistanceVariableInput->setDescription(""); DistanceVariableInput->setEnabled(true); DistanceVariableInput->setRange(-1.000, 1.000); DistanceVariableInput->setLockValueInRange(false); DistanceVariableInput->addTerm(new Trapezoid("FarLeftOfLine", -1.000, -1.000, -0.900, -0.600)); DistanceVariableInput->addTerm(new Trapezoid("LeftOfLine", -0.900, -0.600, -0.400, -0.100)); DistanceVariableInput->addTerm(new Triangle("OnLine", -0.100, 0.000, 0.100)); DistanceVariableInput->addTerm(new Trapezoid("RightOfLine", 0.100, 0.400, 0.600, 0.900)); DistanceVariableInput->addTerm(new Trapezoid("FarRightOfLine", 0.700, 0.900, 1.000, 1.000)); engine->addInputVariable(DistanceVariableInput); InputVariable* LinearVelocityInput = new InputVariable; LinearVelocityInput->setName("LinearVelocityInput"); LinearVelocityInput->setDescription(""); LinearVelocityInput->setEnabled(true); LinearVelocityInput->setRange(-1.000, 1.000); LinearVelocityInput->setLockValueInRange(false); LinearVelocityInput->addTerm(new Trapezoid("MovingLeftFast", -1.000, -1.000, -0.800, -0.600)); LinearVelocityInput->addTerm(new Trapezoid("MoveingLeft", -0.800, -0.600, -0.300, -0.100)); LinearVelocityInput->addTerm(new Triangle("GoingStraight", -0.800, 0.000, 0.800)); LinearVelocityInput->addTerm(new Trapezoid("MovingRight", 0.100, 0.300, 0.600, 0.800)); LinearVelocityInput->addTerm(new Trapezoid("MovingRightFast", 0.600, 0.800, 1.000, 1.000)); engine->addInputVariable(LinearVelocityInput); OutputVariable* Steering = new OutputVariable; Steering->setName("Steering"); Steering->setDescription(""); Steering->setEnabled(true); Steering->setRange(-1.000, 1.000); Steering->setLockValueInRange(false); Steering->setAggregation(new Maximum); Steering->setDefuzzifier(new Centroid(100)); Steering->setDefaultValue(fl::nan); Steering->setLockPreviousValue(false); Steering->addTerm(new Triangle("MakeAHardLeft", -1.000, -1.000, -0.900)); Steering->addTerm(new Triangle("MakeALeft", -1.400, -0.900, -0.400)); Steering->addTerm(new Triangle("GoStraight", -1.500, 0.000, 1.500)); Steering->addTerm(new Triangle("MakeARight", 0.400, 0.900, 1.400)); Steering->addTerm(new Triangle("MakeAHardRight", 0.900, 1.000, 1.000)); engine->addOutputVariable(Steering); RuleBlock* OutputRule = new RuleBlock; OutputRule->setName("OutputRule"); OutputRule->setDescription(""); OutputRule->setEnabled(true); OutputRule->setConjunction(fl::null); OutputRule->setDisjunction(fl::null); OutputRule->setImplication(new AlgebraicProduct); OutputRule->setActivation(new General); OutputRule->addRule(Rule::parse("if DistanceVariableInput is OnLine and LinearVelocityInput is GoingStraight then Steering is GoStraight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is OnLine and LinearVelocityInput is MoveingLeft then Steering is GoStraight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is OnLine and LinearVelocityInput is MovingLeftFast then Steering is MakeARight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is OnLine and LinearVelocityInput is MovingRight then Steering is GoStraight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is OnLine and LinearVelocityInput is MovingRightFast then Steering is MakeALeft", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is LeftOfLine and LinearVelocityInput is GoingStraight then Steering is MakeARight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is LeftOfLine and LinearVelocityInput is MoveingLeft then Steering is MakeARight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is LeftOfLine and LinearVelocityInput is MovingLeftFast then Steering is MakeAHardRight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is LeftOfLine and LinearVelocityInput is MovingRight then Steering is GoStraight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is LeftOfLine and LinearVelocityInput is MovingRightFast then Steering is GoStraight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is FarLeftOfLine and LinearVelocityInput is GoingStraight then Steering is MakeARight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is FarLeftOfLine and LinearVelocityInput is MoveingLeft then Steering is MakeAHardRight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is FarLeftOfLine and LinearVelocityInput is MovingLeftFast then Steering is MakeAHardRight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is FarLeftOfLine and LinearVelocityInput is MovingRight then Steering is MakeARight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is FarLeftOfLine and LinearVelocityInput is MovingRightFast then Steering is GoStraight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is RightOfLine and LinearVelocityInput is GoingStraight then Steering is MakeALeft", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is RightOfLine and LinearVelocityInput is MoveingLeft then Steering is GoStraight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is RightOfLine and LinearVelocityInput is MovingLeftFast then Steering is GoStraight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is RightOfLine and LinearVelocityInput is MovingRight then Steering is MakeALeft", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is RightOfLine and LinearVelocityInput is MovingRightFast then Steering is MakeAHardLeft", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is FarRightOfLine and LinearVelocityInput is GoingStraight then Steering is MakeALeft", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is FarRightOfLine and LinearVelocityInput is MoveingLeft then Steering is MakeALeft", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is FarRightOfLine and LinearVelocityInput is MovingLeftFast then Steering is GoStraight", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is FarRightOfLine and LinearVelocityInput is MovingRight then Steering is MakeAHardLeft", engine)); OutputRule->addRule(Rule::parse("if DistanceVariableInput is FarRightOfLine and LinearVelocityInput is MovingRightFast then Steering is MakeAHardLeft", engine)); engine->addRuleBlock(OutputRule); engine->getInputVariable(0)->setValue(-1.000); engine->getInputVariable(1)->setValue(-1.000); engine->process(); printf("%f\n", engine->toString()); OutputVariable* outputVariable = engine->getOutputVariable(0); printf("%f\n", outputVariable->fuzzyOutputValue()); //OutputVariable* output = engine->getOutputVariable(0)->defuzzify(); //printf("%f\n", output); }
April 4, 2019 at 09:12 #6364Juan Rada-Vilela (admin)
KeymasterHi,
can you please post the FLL code? You can get that FLL code by using
engine->toString()
orFllExporter().toString(engine)
.Thanks,
Juan
-
AuthorPosts
- You must be logged in to reply to this topic.