Merge lp:~oontvoo/kalmanfilterimpl/point_comparable into lp:kalmanfilterimpl

Proposed by Vy Nguyen
Status: Merged
Approved by: Vy Nguyen
Approved revision: 3
Merged at revision: 3
Proposed branch: lp:~oontvoo/kalmanfilterimpl/point_comparable
Merge into: lp:kalmanfilterimpl
Diff against target: 39 lines (+10/-1)
1 file modified
src/kalmanfilter/RunFilter.java (+10/-1)
To merge this branch: bzr merge lp:~oontvoo/kalmanfilterimpl/point_comparable
Reviewer Review Type Date Requested Status
Vy Nguyen Pending
Review via email: mp+112463@code.launchpad.net

Description of the change

Make Point comparable to ensure the input Points are sorted in time order

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/kalmanfilter/RunFilter.java'
--- src/kalmanfilter/RunFilter.java 2012-06-27 01:47:04 +0000
+++ src/kalmanfilter/RunFilter.java 2012-06-28 00:23:18 +0000
@@ -23,6 +23,7 @@
23import Jama.Matrix;23import Jama.Matrix;
24import java.util.ArrayList;24import java.util.ArrayList;
25import java.util.Arrays;25import java.util.Arrays;
26import java.util.Collections;
26import java.util.List;27import java.util.List;
2728
28/**29/**
@@ -31,7 +32,7 @@
31 */32 */
32public class RunFilter 33public class RunFilter
33{34{
34 public static class Point35 public static class Point implements Comparable<Point>
35 {36 {
36 final double x; // x coord37 final double x; // x coord
37 final double y; // y coord38 final double y; // y coord
@@ -42,10 +43,18 @@
42 this.y = y;43 this.y = y;
43 this.t = t;44 this.t = t;
44 }45 }
46 @Override
47 public int compareTo(Point o)
48 {
49 return Double.compare(t, o.t);
50 }
45 }51 }
46 52
47 public static List<Point> filter(List<Point> inputs, double sensorNoise)53 public static List<Point> filter(List<Point> inputs, double sensorNoise)
48 {54 {
55 // sort the points in time order
56 Collections.sort(inputs);
57
49 List<Point> output = new ArrayList<>(inputs.size());58 List<Point> output = new ArrayList<>(inputs.size());
50 59
51 //(Matrix X, Matrix P, Matrix Q, Matrix H, Matrix A, Matrix R)60 //(Matrix X, Matrix P, Matrix Q, Matrix H, Matrix A, Matrix R)

Subscribers

People subscribed via source and target branches

to all changes: