Skip to content

Commit c6e0c4d

Browse files
committed
Extended the Javadoc class-comment.
1 parent fea4233 commit c6e0c4d

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

aima-core/src/main/java/aima/core/robotics/MonteCarloLocalization.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,19 @@
3434
* Figure 25.9 A Monte-Carlo-Localization algorithm using a range-scan sensor model with independent noise.
3535
* The Monte-Carlo-Localization is an extension of a {@link ParticleFiltering} as stated on page 982.
3636
* This is true for the functionality but this implementation can not extend the implementation of the ParticleFiltering
37-
* as both implementations only contain the actual algorithm as a single method.
38-
*
39-
* It is possible to reduce the steps needed for the localization by tweaking the parameters {@code particleCount}, {@code weightCutOff} and {@code maxDistance}.
37+
* as both implementations only contain the actual algorithm as a single method.<br/>
38+
* <br/>
39+
* The update cycle of the algorithm is executed by the method {@code localize} for the given set of samples, move and vector of range readings.
40+
* Before calling this method, a set of samples can be generated through the method {@code generateCloud}, which represents the initialization phase of the pseudocode, for the given size N.
41+
* This removes the need of specifying the size N on every call of {@code localize} as this information is already contained in the set itself.
42+
* The method {@code localize} is divided into these three parts implemented each by a single method:
43+
* <ol>
44+
* <li>{@code applyMove} represents the first line of the update cycle. It moves all samples according to the move / motion model.</li>
45+
* <li>{@code weightSamples} represents the second to second last line of the update cycle. A vector of weights is created by this method for the given range scans by comparing every range scan to a ray cast with the correspondent sample through the range sensor noise model.</li>
46+
* <li>{@code extendedWeightedSampleWithReplacement} represents the last line of the update cycle. It is a WEIGHTED-SAMPLE-WITH-REPLACEMENT with the addition of a cutoff value. All particles having a weight below this cutoff are ignored.</li>
47+
* </ol>
48+
* <br/>
49+
* It is possible to reduce the steps needed for the localization by tweaking the sample count and the parameter {@code cutOff}.
4050
*
4151
* @author Arno von Borries
4252
* @author Jan Phillip Kretzschmar
@@ -130,7 +140,7 @@ protected Set<P> extendedWeightedSampleWithReplacement(Set<P> samples, double[]
130140
Object[] array = samples.toArray(new Object[0]);
131141
for(i=0; i < samples.size(); i++) {
132142
final int selectedSample = (Integer) ProbUtil.sample(randomizer.nextDouble(),sampleIndexes,normalizedW);
133-
newSamples.add(( (P) array[selectedSample]).clone());
143+
newSamples.add(((P) array[selectedSample]).clone());
134144
}
135145
return newSamples;
136146
}
@@ -152,18 +162,17 @@ public Set<P> generateCloud(int N) {
152162
}
153163

154164
/**
155-
* Executes the Monte-Carlo-Localization for the given parameters.
165+
* Executes the update cycle of the Monte-Carlo-Localization for the given parameters.
156166
* @param samples the sample cloud.
157167
* @param move the move to be applied to the cloud.
158168
* @param rangeReadings the range scan that has been performed after the move has ended.
159-
* @return a new Set containing updated samples.
169+
* @return a new Set containing updated samples. {@code null} is returned if {@code samples} is {@code null}.
160170
*/
161171
public Set<P> localize(Set<P> samples, M move, R[] rangeReadings) {
162172
if(samples == null) return null;/*initialization phase = call generateCloud*/
163173
Set<P> newSamples = applyMove(samples, move);/*motion model*/
164174
double[] w = weightSamples(newSamples, rangeReadings);/*range sensor noise model*/
165175
newSamples = extendedWeightedSampleWithReplacement(newSamples, w);
166176
return newSamples;
167-
168177
}
169178
}

0 commit comments

Comments
 (0)