1 /*
2 * Copyright (C) 2018 Alberto Irurueta Carro (alberto@irurueta.com)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.irurueta.navigation.indoor.fingerprint;
17
18 import com.irurueta.geometry.InhomogeneousPoint3D;
19 import com.irurueta.geometry.Point3D;
20 import com.irurueta.navigation.indoor.RadioSource;
21 import com.irurueta.navigation.indoor.RadioSourceLocated;
22 import com.irurueta.navigation.indoor.RssiFingerprint;
23 import com.irurueta.navigation.indoor.RssiFingerprintLocated;
24 import com.irurueta.navigation.indoor.RssiReading;
25
26 import java.util.List;
27
28 /**
29 * 2D position estimator based on located fingerprints containing only RSSI readings and
30 * having as well prior knowledge of the location of radio sources associated to those
31 * readings.
32 * This implementation uses a first-order Taylor approximation over provided located
33 * fingerprints to determine an approximate position for a non-located fingerprint.
34 */
35 public class LinearFingerprintPositionEstimator3D extends LinearFingerprintPositionEstimator<Point3D> {
36
37 /**
38 * Constructor.
39 */
40 public LinearFingerprintPositionEstimator3D() {
41 }
42
43 /**
44 * Constructor.
45 *
46 * @param listener listener in charge of handling events.
47 */
48 public LinearFingerprintPositionEstimator3D(final FingerprintPositionEstimatorListener<Point3D> listener) {
49 super(listener);
50 }
51
52 /**
53 * Constructor.
54 *
55 * @param locatedFingerprints located fingerprints containing RSSI readings.
56 * @param fingerprint fingerprint containing readings at an unknown location
57 * for provided located fingerprints.
58 * @param sources located radio sources.
59 * @throws IllegalArgumentException if provided non located fingerprint is null,
60 * located fingerprints value is null or there are not enough fingerprints or
61 * readings within provided fingerprints (for 3D position estimation 3 located
62 * total readings are required among all fingerprints).
63 */
64 public LinearFingerprintPositionEstimator3D(
65 final List<? extends RssiFingerprintLocated<? extends RadioSource,
66 ? extends RssiReading<? extends RadioSource>, Point3D>> locatedFingerprints,
67 final RssiFingerprint<? extends RadioSource,
68 ? extends RssiReading<? extends RadioSource>> fingerprint,
69 final List<? extends RadioSourceLocated<Point3D>> sources) {
70 super(locatedFingerprints, fingerprint, sources);
71 }
72
73 /**
74 * Constructor.
75 *
76 * @param locatedFingerprints located fingerprints containing RSSI readings.
77 * @param fingerprint fingerprint containing readings at an unknown location
78 * for provided located fingerprints.
79 * @param sources located radio sources.
80 * @param listener listener in charge of handling events.
81 * @throws IllegalArgumentException if provided non located fingerprint is null,
82 * located fingerprints value is null or there are not enough fingerprints or
83 * readings within provided fingerprints (for 3D position estimation 3 located
84 * total readings are required among all fingerprints).
85 */
86 public LinearFingerprintPositionEstimator3D(
87 final List<? extends RssiFingerprintLocated<? extends RadioSource,
88 ? extends RssiReading<? extends RadioSource>, Point3D>> locatedFingerprints,
89 final RssiFingerprint<? extends RadioSource,
90 ? extends RssiReading<? extends RadioSource>> fingerprint,
91 final List<? extends RadioSourceLocated<Point3D>> sources,
92 final FingerprintPositionEstimatorListener<Point3D> listener) {
93 super(locatedFingerprints, fingerprint, sources, listener);
94 }
95
96 /**
97 * Gets number of dimensions of points.
98 *
99 * @return number of dimensions of points.
100 */
101 @Override
102 public int getNumberOfDimensions() {
103 return Point3D.POINT3D_INHOMOGENEOUS_COORDINATES_LENGTH;
104 }
105
106 /**
107 * Gets estimated position or null if not available yet.
108 *
109 * @return estimated position or null.
110 */
111 @Override
112 public Point3D getEstimatedPosition() {
113 if (estimatedPositionCoordinates == null) {
114 return null;
115 }
116
117 final var result = new InhomogeneousPoint3D();
118 getEstimatedPosition(result);
119 return result;
120 }
121 }