home Forums # Technical Support Error when running application Reply To: Error when running application

#2312
Unknown
Member

Thank you Juan. I have removed all spaces but still getting the error;

E/ERROR: [syntax error] expected variable or logical operator, but found <ZAXISACCELERATION>

Can you guide me as to what else needs to be changed please?

public void fuzzyMethod(double carspeed, double acceleration){
Engine engine = new Engine();
engine.setName(“DriverClassifier”);

/*Speed input value
Speed range set between 0 and 95km/hr
Three terms – slow, normal, fast
*/
InputVariable speed = new InputVariable();
speed.setEnabled(true);
speed.setName(“SPEED”);
speed.setRange(0.000,95.000);
speed.addTerm(new Triangle(“SLOW”,0.000,25.000,50.000 ));
speed.addTerm(new Triangle(“NORMAL”,45.000,55.000,65.000));
speed.addTerm(new Triangle(“FAST”, 55.000, 75.000,95.000));
engine.addInputVariable(speed);

/*
Accelerometer values in z-axis direction – left to right
*/
InputVariable zaxis = new InputVariable();
zaxis.setEnabled(true);
zaxis.setName(“ZAxisAcceleration”);
zaxis.setRange(-4.500,4.500);

//Deceleration
zaxis.addTerm(new Triangle(“HARDDECELERATION”,1.500,3.00,4.500 ));
zaxis.addTerm(new Triangle(“DECELERATION”,0.500,1.5,2.5));

//Calm/Neutral
zaxis.addTerm(new Triangle(“NEUTRAL”,-0.5,0,0.5));

//Acceleration
zaxis.addTerm(new Triangle(“ACCELERATION”,-0.500,-1.250,-2.000));
zaxis.addTerm(new Triangle(“HARDACCELERATION”,-1.500,-3.000,-4.500));
engine.addInputVariable(zaxis);

OutputVariable drivingStyle = new OutputVariable();
drivingStyle.setName(“DRIVINGSTYLE”);
drivingStyle.addTerm(new Triangle(“CALM”,0,0.5,1));
drivingStyle.addTerm(new Triangle(“NORMAL”,1,1.5,2));
drivingStyle.addTerm(new Triangle(“AGGRESSIVE”,2, 2.5, 3));
engine.addOutputVariable(drivingStyle);

//Set Rules
RuleBlock ruleBlock = new RuleBlock();
//SLOW SPEED
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and ZAXISACCELERATION is HARD DECELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and ZAXISACCELERATION is DECELERATION then DRIVINGSTYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and ZAXISACCELERATION is NEUTRAL then DRIVINGSTYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and ZAXISACCELERATION is ACCELERATION then DRIVINGSTYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is SLOW and ZAXISACCELERATION is HARD ACCELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));

//NORMAL SPEED
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and ZAXISACCELERATION is HARD DECELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and ZAXISACCELERATION is DECELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and ZAXISACCELERATION is NEUTRAL then DRIVINGSTYLE is NORMAL”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and ZAXISACCELERATION is ACCELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is NORMAL and ZAXISACCELERATION is HARD ACCELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));

//TOO FAST
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and ZAXISACCELERATION is HARD DECELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and ZAXISACCELERATION is DECELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and ZAXISACCELERATION is NEUTRAL then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and ZAXISACCELERATION is ACCELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
ruleBlock.addRule(Rule.parse(“if SPEED is FAST and ZAXISACCELERATION is HARD ACCELERATION then DRIVINGSTYLE is AGGRESSIVE”, engine));
engine.addRuleBlock(ruleBlock);

speed.setInputValue(carspeed);
zaxis.setInputValue(acceleration);
engine.process();
Log.d(“fuzzy”,drivingStyle.getOutputValue()+ ” “);
//FuzzyLite.logger().info(Op.str(drivingStyle.getOutputValue()));
}