eFLL - Arduino using two fuzzy systems in the same program

I'm trying to write a program but I encounter some issues. I try to define 2 fuzzy controllers in the same set-up of a program. Both share an input and have one more input different from each other. This is the initialization of the input/output. The second controller, fuzzydist output returns 0.00. It should not. I am using the eFLL library Did anybody do that? How I am supposed do to it?

Fuzzy *fuzzy = new Fuzzy();
Fuzzy *fuzzydist = new Fuzzy();
void setup() {
FuzzyInput *velocity = new FuzzyInput(1);
  fuzzy->addFuzzyInput(velocity);
  fuzzydist-> addFuzzyInput(velocity);
FuzzyInput *weather = new FuzzyInput(2);
  fuzzy->addFuzzyInput(weather);
FuzzyInput *road = new FuzzyInput(3);
  fuzzydist->addFuzzyInput(road);
FuzzyOutput *reaction = new FuzzyOutput(1);
   fuzzy->addFuzzyOutput(reaction);
FuzzyOutput *reaction = new FuzzyOutput(1);
   fuzzy->addFuzzyOutput(reaction);
}
void loop (){
  fuzzy->setInput(1, velocity); 
  fuzzy->setInput(2, road); 
  fuzzy->fuzzify();
  float tau1 = fuzzy->defuzzify(1);

  fuzzydist->setInput(1, velocity); 
  fuzzydist->setInput(3, road); 
  fuzzydist->fuzzify();
  float a = fuzzydist->defuzzify(2);
}

I am expecting that the second controller should return a float <10, >0. I tried to write the program in which the FLL won't share the input but it dosen't work either, it returns 0.00 also.

How would that snippet of code even compile? You declaring local variables velocity, road inside of setup() and then referencing them in loop()? They would not be in scope.

This is a great example why you need to post a complete sketch that others can copy and compile.

I did declare the variables. The systems I made work fine by themselves, but don't when put together. I was wondering only about these lines of code. In more detail, what the initialization of two FLLs would look like? Maybe there is an example I didn't see. Thank you for your response!

Post your complete sketch. If you declare a variable like velocity with global scope and then declare another variable called velocity inside setup(), they are 2 unique variables that have nothing to do with each other.

Of course, I'm just guessing since you haven't posted your code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.