View Javadoc

1   package SteeringProperties;
2   
3   import SteeringStuff.SteeringType;
4   import XMLSteeringProperties.XMLWallFollowingProperties;
5   
6   /**
7    * The steering properties of the Wall Following steering.
8    * @author Marki
9    */
10  public class WallFollowingProperties extends SteeringProperties {
11  
12      /** The force of the wall. Reasonable value is around 100. */
13      private int wallForce;
14      /** The order of the force in the range 1-10. */
15      private int forceOrder;
16      /**The weight of the arractive force. Default value is 1.*/
17      private double attractiveForceWeight;
18      /**The weight of the repulsive force. Default value is 1.*/
19      private double repulsiveForceWeight;
20      /**The weight of the force of the convex edges. Default value is 1.*/
21      private double convexEdgesForceWeight;
22      /**The weight of the force of the concave edges. Default value is 1.*/
23      private double concaveEdgesForceWeight;
24      /**This parameter causes, that just the forces from the actual side will be noticed. The bot goes more fluently then. Recommended value is true.*/
25      private boolean justMySide;
26      /**The special detection of the convex edges, helps for fluent motion. Recommended value is true.*/
27      private boolean specialDetection;
28      /**The good solution of the front collisions. Recommended value is true.*/
29      private boolean frontCollisions;
30  
31  
32      public WallFollowingProperties() {
33          super(SteeringType.WALL_FOLLOWING);
34          wallForce = 100; //73
35          forceOrder = 1;
36          attractiveForceWeight = 1;
37          repulsiveForceWeight = 1;
38          concaveEdgesForceWeight = 1;
39          convexEdgesForceWeight = 1;
40          justMySide = true;
41          specialDetection = true;
42          frontCollisions = true;
43      }
44  
45      public WallFollowingProperties(BehaviorType behaviorType) {
46          super(SteeringType.WALL_FOLLOWING, behaviorType);
47          wallForce = 100;
48          forceOrder = 1;
49          attractiveForceWeight = 1;
50          repulsiveForceWeight = 1;
51          concaveEdgesForceWeight = 1;
52          convexEdgesForceWeight = 1;
53          justMySide = true;
54          specialDetection = true;
55          frontCollisions = true;
56          setNewBehaviorType(behaviorType);
57      }
58  
59      public WallFollowingProperties(XMLWallFollowingProperties xml) {
60          super(SteeringType.WALL_FOLLOWING, xml.active, xml.weight, xml.behavior);
61          wallForce = xml.wallForce;
62          forceOrder = xml.forceOrder;
63          attractiveForceWeight = xml.attractiveForceWeight;
64          repulsiveForceWeight = xml.repulsiveForceWeight;
65          concaveEdgesForceWeight = xml.concaveEdgesForceWeight;
66          convexEdgesForceWeight = xml.convexEdgesForceWeight;
67          justMySide = xml.justMySide;
68          specialDetection = xml.specialDetection;
69          frontCollisions = xml.frontCollisions;
70      }
71  
72      public WallFollowingProperties(int wallForce, int orderOfTheForce, int attractiveForceWeight,
73              int repulsiveForceWeight,  int concaveEdgesForceWeight,  int convexEdgesForceWeight,
74              boolean justMySide, boolean specialDetection, boolean frontCollisions) {
75          super(SteeringType.WALL_FOLLOWING);
76          this.wallForce = wallForce;
77          this.forceOrder = orderOfTheForce;
78          this.attractiveForceWeight = attractiveForceWeight;
79          this.repulsiveForceWeight = repulsiveForceWeight;
80          this.concaveEdgesForceWeight = concaveEdgesForceWeight;
81          this.convexEdgesForceWeight = convexEdgesForceWeight;
82          this.justMySide = justMySide;
83          this.specialDetection = specialDetection;
84          this.frontCollisions = frontCollisions;
85      }
86  
87      protected void setNewBehaviorType(BehaviorType behaviorType) {
88          if (behaviorType.equals(BehaviorType.BASIC)) {
89              attractiveForceWeight = 1;
90              repulsiveForceWeight = 1;
91              concaveEdgesForceWeight = 1;
92              convexEdgesForceWeight = 1;
93              justMySide = false;
94              specialDetection = false;
95              frontCollisions = false;
96          } else if (behaviorType.equals(BehaviorType.ADVANCED)) {
97              justMySide = true;
98              specialDetection = true;
99              frontCollisions = true;
100         }
101     }
102 
103     public int getWallForce() {
104         return wallForce;
105     }
106 
107     public void setWallForce(int force) {
108         this.wallForce = force;
109     }
110 
111     public int getOrderOfTheForce() {
112         return forceOrder;
113     }
114 
115     public void setOrderOfTheForce(int orderOfTheForce) {
116         this.forceOrder = orderOfTheForce;
117     }
118 
119     public double getAttractiveForceWeight() {
120         return attractiveForceWeight;
121     }
122 
123     public void setAttractiveForceWeight(double attractiveForceWeight) {
124         this.attractiveForceWeight = attractiveForceWeight;
125     }
126 
127     public double getConcaveEdgesForceWeight() {
128         return concaveEdgesForceWeight;
129     }
130 
131     public void setConcaveEdgesForceWeight(double concaveEdgesForceWeight) {
132         this.concaveEdgesForceWeight = concaveEdgesForceWeight;
133     }
134 
135     public double getConvexEdgesForceWeight() {
136         return convexEdgesForceWeight;
137     }
138 
139     public void setConvexEdgesForceWeight(double convexEdgesForceWeight) {
140         this.convexEdgesForceWeight = convexEdgesForceWeight;
141     }
142 
143     public double getRepulsiveForceWeight() {
144         return repulsiveForceWeight;
145     }
146 
147     public void setRepulsiveForceWeight(double repulsiveForceWeight) {
148         this.repulsiveForceWeight = repulsiveForceWeight;
149     }
150 
151     public boolean isFrontCollisions() {
152         return frontCollisions;
153     }
154 
155     public void setFrontCollisions(boolean frontCollisions) {
156         this.frontCollisions = frontCollisions;
157     }
158 
159     public boolean isJustMySide() {
160         return justMySide;
161     }
162 
163     public void setJustMySide(boolean justMySide) {
164         this.justMySide = justMySide;
165     }
166 
167     public boolean isSpecialDetection() {
168         return specialDetection;
169     }
170 
171     public void setSpecialDetection(boolean specialDetection) {
172         this.specialDetection = specialDetection;
173     }
174 
175     @Override
176     public String getSpecialText() {
177         String text = "";
178         text += "  * Wall Force: " + wallForce + "\n";
179         text += "  * Attractive Weight: " + attractiveForceWeight + "\n";
180         text += "  * Repulsive Weight: " + repulsiveForceWeight + "\n";
181         text += "  * Concave Weight: " + concaveEdgesForceWeight + "\n";
182         text += "  * Convex Weight: " + convexEdgesForceWeight + "\n";
183         text += "  * Just My Side: " + justMySide + "\n";
184         text += "  * Special Detection: " + specialDetection + "\n";
185         text += "  * Front Collisions: " + frontCollisions + "\n";
186         return text;
187     }
188 
189     @Override
190     public void setProperties(SteeringProperties newProperties) {
191         this.wallForce = ((WallFollowingProperties)newProperties).getWallForce();
192         this.forceOrder = ((WallFollowingProperties)newProperties).getOrderOfTheForce();
193         this.attractiveForceWeight = ((WallFollowingProperties)newProperties).getAttractiveForceWeight();
194         this.repulsiveForceWeight = ((WallFollowingProperties)newProperties).getRepulsiveForceWeight();
195         this.concaveEdgesForceWeight = ((WallFollowingProperties)newProperties).getConcaveEdgesForceWeight();
196         this.convexEdgesForceWeight = ((WallFollowingProperties)newProperties).getConvexEdgesForceWeight();
197         this.justMySide = ((WallFollowingProperties)newProperties).isJustMySide();
198         this.specialDetection = ((WallFollowingProperties)newProperties).isSpecialDetection();
199         this.frontCollisions = ((WallFollowingProperties)newProperties).isFrontCollisions();
200     }
201 
202     public XMLWallFollowingProperties getXMLProperties() {
203         XMLWallFollowingProperties xmlProp = new XMLWallFollowingProperties();
204         xmlProp.wallForce = wallForce;
205         xmlProp.forceOrder = forceOrder;
206         xmlProp.attractiveForceWeight = attractiveForceWeight;
207         xmlProp.repulsiveForceWeight = repulsiveForceWeight;
208         xmlProp.concaveEdgesForceWeight = concaveEdgesForceWeight;
209         xmlProp.convexEdgesForceWeight = convexEdgesForceWeight;
210         xmlProp.justMySide = justMySide;
211         xmlProp.specialDetection = specialDetection;
212         xmlProp.frontCollisions = frontCollisions;
213         xmlProp.active = active;
214         xmlProp.weight = weight;
215         xmlProp.behavior = behaviorType;
216         return xmlProp;
217     }
218 }
219 
220 
221 
222     /*public int getDistanceFromTheWall() {
223         return distanceFromTheWall;
224     }
225 
226     public void setDistanceFromTheWall(int distanceFromTheWall) {
227         this.distanceFromTheWall = distanceFromTheWall;
228     }*/