summaryrefslogtreecommitdiff
path: root/examples/takagi-sugeno/ObstacleAvoidance.java
blob: c7c7f67e118c2641d62b140c636f328061dcebc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import com.fuzzylite.*;
import com.fuzzylite.activation.*
import com.fuzzylite.defuzzifier.*;
import com.fuzzylite.factory.*;
import com.fuzzylite.hedge.*;
import com.fuzzylite.imex.*;
import com.fuzzylite.norm.*;
import com.fuzzylite.norm.s.*;
import com.fuzzylite.norm.t.*;
import com.fuzzylite.rule.*;
import com.fuzzylite.term.*;
import com.fuzzylite.variable.*;

public class ObstacleAvoidance{
public static void main(String[] args){
//Code automatically generated with fuzzylite 6.0.

Engine engine = new Engine();
engine.setName("ObstacleAvoidance");
engine.setDescription("");

InputVariable obstacle = new InputVariable();
obstacle.setName("obstacle");
obstacle.setDescription("");
obstacle.setEnabled(true);
obstacle.setRange(0.000, 1.000);
obstacle.setLockValueInRange(false);
obstacle.addTerm(new Ramp("left", 1.000, 0.000));
obstacle.addTerm(new Ramp("right", 0.000, 1.000));
engine.addInputVariable(obstacle);

OutputVariable tsSteer = new OutputVariable();
tsSteer.setName("tsSteer");
tsSteer.setDescription("");
tsSteer.setEnabled(true);
tsSteer.setRange(0.000, 1.000);
tsSteer.setLockValueInRange(false);
tsSteer.setAggregation(new Maximum());
tsSteer.setDefuzzifier(new WeightedAverage("Automatic"));
tsSteer.setDefaultValue(Double.NaN);
tsSteer.setLockPreviousValue(false);
tsSteer.addTerm(new Constant("left", 0.333));
tsSteer.addTerm(new Constant("right", 0.666));
engine.addOutputVariable(tsSteer);

RuleBlock takagiSugeno = new RuleBlock();
takagiSugeno.setName("takagiSugeno");
takagiSugeno.setDescription("");
takagiSugeno.setEnabled(true);
takagiSugeno.setConjunction(null);
takagiSugeno.setDisjunction(null);
takagiSugeno.setImplication(null);
takagiSugeno.setActivation(new General());
takagiSugeno.addRule(Rule.parse("if obstacle is left then tsSteer is right", engine));
takagiSugeno.addRule(Rule.parse("if obstacle is right then tsSteer is left", engine));
engine.addRuleBlock(takagiSugeno);


}
}