1/*
2 * Copyright (C) 2024 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
17syntax = "proto3";
18
19package com.android.ranging.generic.proto;
20
21option java_package = "com.android.ranging.generic.proto";
22option java_multiple_files = true;
23
24enum ConfidenceLevel {
25CL_UNSPECIFIED = 0;
26CL_95 = 1;    // 95 %
27CL_97P5 = 2;  // 97.5 %
28CL_99 = 3;    // 99 %
29}
30
31// Configuration for MultiSensorFinder including the configuration of sub
32// components.
33message MultiSensorFinderConfig {
34// If unset, default values will be used.
35ParticleFilterConfig particle_filter_config = 1;
36
37// If enabled, the filter will use UWB measurements.
38bool use_uwb_measurements = 2;
39
40// If enabled, the filter will use Wi-Fi RTT measurements.
41bool use_wifi_rtt_measurements = 3;
42
43// If unset, default values will be used.
44RangeMeasurementConfig uwb_range_measurement_config = 4;
45
46// If unset, default values will be used.
47RangeMeasurementConfig wifi_rtt_range_measurement_config = 5;
48
49// If unset, default values will be used.
50FuzzyUpdateSchedulerConfig fuzzy_update_scheduler_configuration = 6;
51
52double default_xy_update_process_noise_stddev_m = 7;
53
54// If unset, default values will be used.
55OdometryNoiseAdderConfig odometry_noise_adder_config = 8;
56
57// If unset, trilateration measurement updater will not be used.
58TrilaterationMeasurementUpdaterConfig
59trilateration_measurement_updater_config = 9;
60
61// The rate at which finder will poll the odometry provider, which is also
62// the maximum rate at which finder will generate estimates.
63uint32 odometry_polling_rate_hz = 10;
64
65// If unset, odometry throttler will not be used.
66OdometryThrottlerConfig odometry_throttler_config = 11;
67
68// If unset, OBEP will not be used.
69OdometryBasedEstimatePropagatorConfig
70odometry_based_estimate_propagator_config = 12;
71
72// If unset, the NIS divergence detector will not be used.
73NisDivergenceDetectorConfig nis_divergence_detector_config = 13;
74
75InitialStateSamplerConfig uwb_initial_state_sampler_config = 14;
76
77InitialStateSamplerConfig wifi_rtt_initial_state_sampler_config = 15;
78
79// Used to input and output logs for development and debugging. If unset,
80// the debug logger will not be used.
81DebugLoggerConfiguration debug_logger_configuration = 16;
82}
83
84// Configuration for the generic sensor model, which is simply a combination of
85// a Gaussian and a Uniform distribution.
86message GenericRangeSensorModelConfig {
87double gaussian_std_dev_m = 1;
88double max_sensor_range_m = 2;
89}
90
91// Configuration for the trilateration measurement updater, which uses
92// trilateration on a set of UWB range measurements to determine if the incoming
93// range measurements are consistent over some spatial region.
94message TrilaterationMeasurementUpdaterConfig {
95int32 num_measurements_for_trilateration = 2;
96double max_trilateration_rmse_m = 3;
97}
98
99// Configuration for the sensor model associated with a range measurement and
100// any additional checks/modifiers. Currently, only the GenericRangeSensorModel
101// is supported.
102message RangeMeasurementConfig {
103// Currently supported models for a range sensor. If unspecified, the generic
104// model will be used.
105enum RangeSensorModelType {
106UNSPECIFIED = 0;
107// A generic model that consists of a Gaussian + Uniform distribution.
108// The configuration message associated with this model is
109// GenericRangeSensorModelConfig.
110GENERIC = 1;
111// Switches the measurement model based on the variance heuristic.
112VARIANCE_BASED_SWITCHING = 2;
113}
114RangeSensorModelType sensor_model_type = 1;
115GenericRangeSensorModelConfig generic_range_sensor_model_configuration = 2;
116VarianceBasedSwitchingMeasurementModelConfig
117variance_based_switching_measurement_model_config = 4;
118// If unset, the distance traveled check will not be used.
119DistanceTraveledCheckConfig distance_traveled_check_config = 3;
120}
121
122// Configuration for a scheduler which determines when a motion + measurement
123// update should be done.
124//
125// For each odometry sample, it creates a frame (or window) of +-
126// max_frame_size_nanos, and waits max_wait_time_nanos for all data to show up
127// in this frame.
128//
129// max_wait_time_nanos is directly proportional to the filter latency.
130// Increasing max_frame_size_nanos will increase the number of measurements
131// used, but can decrease accuracy because of a greater tolerance on the
132// mismatch in timestamps between odometry and range sensor data.
133message FuzzyUpdateSchedulerConfig {
134uint64 max_wait_time_nanos = 1;
135uint64 max_frame_size_nanos = 2;
136int32 max_buffer_size = 3;
137}
138
139// The distance traveled check blocks measurements from being continually
140// absorbed if a user stands still. It's a simple way to prevent particle
141// depletion.
142message DistanceTraveledCheckConfig {
143double distance_traveled_threshold_m = 2;
144}
145
146message ParticleFilterConfig {
147int32 number_of_particles = 1;
148}
149
150// The odometry noise adder adds noise during a motion update based on the speed
151// of the user.
152//
153// The mapping from speed to noise stays flat at min_noise_std_dev until the
154// speed reaches min_speed_mps, after which it ramps linearly up to
155// max_speed_mps. For speed greater than max_speed_mps, it stays at
156// max_noise_std_dev.
157//
158//
159//                    max_speed_mps
160//                    /
161//         ^          *
162//         |          ------------ max_noise_std_dev
163// sigma m |         /
164//         |        /
165//         | ------/  min_noise_std_dev
166//         ----------------------------------> Speed m/s`
167//                 *
168//                /
169//    min_speed_mps
170message OdometryNoiseAdderConfig {
171int32 num_speed_filter_taps = 2;
172double min_noise_std_dev_m = 3;
173double max_noise_std_dev_m = 4;
174double min_speed_mps = 5;
175double max_speed_mps = 6;
176}
177
178message OdometryThrottlerConfig {
179int64 throttling_dt_nanos = 1;
180}
181
182message OdometryBasedEstimatePropagatorConfig {
183// The size of the odometry buffer. Set this based on the odometry polling
184// rate.
185int32 buffer_size = 1;
186}
187
188// Uses the Normalized Innovation Squared criteria to determine if the filter
189// has diverged. The Filter will reset if divergence is detected.
190message NisDivergenceDetectorConfig {
191// A larger buffer reduces sensitivity to noisy measurements.
192int32 nis_buffer_size = 1;
193
194// A higher level yields fewer false positives.
195ConfidenceLevel confidence_level = 2;
196
197// Caps the NIS score to reduce sensitivity to outliers. For example, a value
198// of 1 sigma will cap the NIS score to the 68.3 % Gaussian interval about the
199// mean.
200double nis_sigma_bound = 3;
201
202// The detector will only be active if the std dev of the filter's error in
203// the estimated beacon position is below this threshold.
204double activation_threshold_m = 4;
205
206// The default noise covariance used when computing the NIS for UWB if an
207// online computed value is not provided to the detector.
208double default_uwb_noise_covariance = 5;
209
210// The default noise covariance used when computing the NIS for Wi-Fi RTT if
211// an online computed value is not provided to the detector.
212double default_wifi_rtt_noise_covariance = 6;
213}
214
215message UniformModelConfig {
216double min_value = 1;
217double max_value = 2;
218}
219
220message GaussianModelConfig {
221double loc = 1;
222double scale = 2;
223}
224
225message ExponentiallyWeightedGaussianModelConfig {
226double lambda_scaled = 1;
227double loc = 2;
228double scale = 3;
229}
230
231message ModelConfigContainer {
232oneof model {
233UniformModelConfig uniform_model_config = 1;
234GaussianModelConfig gaussian_model_config = 2;
235ExponentiallyWeightedGaussianModelConfig
236exponentially_weighted_gaussian_model_config = 3;
237}
238}
239
240// Configuration for the variance based switching model.
241message VarianceBasedSwitchingMeasurementModelConfig {
242double switching_threshold = 1;
243
244ModelConfigContainer low_variance_model_config = 2;
245
246// If unset, measurement updates will not be done while the sensor range
247// variance is above the variance_threshold.
248ModelConfigContainer high_variance_model_config = 3;
249
250// The size of the window over which the variance used by this model is
251// computed.
252int32 variance_window_size = 4;
253}
254
255// Configuration for an initial state sampler.
256//
257// Please note that the mean of the distribution specified in the sampler
258// configs are about the measured value; if a Gaussian sampler is used with loc
259// = 0.1 and scale = 10, then the samples will be generated using:
260//
261// measured_range + Gaussian(loc, scale).
262//
263// Additionally, note that the exponential distribution will be flipped such
264// that it is skewed towardes -ve axis rather than the standard which is skewed
265// towardes the +ve axis.
266message InitialStateSamplerConfig {
267ModelConfigContainer range_sampler_config = 1;
268ModelConfigContainer bearing_sampler_config = 2;
269}
270
271message DebugLoggerConfiguration {
272// Debug logs will be automatically emitted to the sink when they exceed this
273// size.
274int32 autodump_size_threshold_bytes = 1;
275// The rate at which odometry inputs will be throttled. Throttling is disabled
276// if set to 0.
277int64 odometry_throttling_nanos = 2;
278// The rate at which UWB range measurements will be throttled. Throttling is
279// disabled if set to 0.
280int64 uwb_throttling_nanos = 3;
281// The rate at which output estimates will be throttled. Throttling is
282// disabled if set to 0.
283int64 estimate_throttling_nanos = 4;
284}
285