1 /*
2  * Copyright (C) 2023 The Android Open Source Project
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.android.server.uwb.correction.primers;
17 
18 import androidx.annotation.NonNull;
19 import androidx.annotation.Nullable;
20 
21 import com.android.server.uwb.correction.math.SphericalVector;
22 import com.android.server.uwb.correction.pose.IPoseSource;
23 
24 /**
25  * Given known data about a UWB reading, applies corrections that correct for nonlinearities,
26  * missing data or other hardware limitations.
27  */
28 public interface IPrimer {
29     /** How quickly the FOM falls when readings are predicted. Use by implementing classes. */
30     double FALLOFF_FOM_PER_SEC = 0.2f;
31     /** The worst possible FOM from falloff. */
32     double MINIMUM_FOM = 0.1f;
33 
34     /**
35      * Applies corrections to a raw position.
36      *
37      * @param input The original UWB reading.
38      * @param prediction The previous filtered UWB result adjusted by the pose change since then.
39      * @param poseSource A pose source that may indicate phone orientation.
40      * @param timeMs When the input occurred, in ms since boot.
41      * @return A replacement value for the UWB input that has been corrected for  the situation.
42      */
prime( @onNull SphericalVector.Annotated input, @Nullable SphericalVector prediction, @Nullable IPoseSource poseSource, long timeMs )43     SphericalVector.Annotated prime(
44             @NonNull SphericalVector.Annotated input,
45             @Nullable SphericalVector prediction,
46             @Nullable IPoseSource poseSource,
47             long timeMs
48     );
49 }
50