gravity_fusion_algorithm_using_accelerometer.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_DEVICE_GENERIC_SENSOR_GRAVITY_FUSION_ALGORITHM_USING_ACCELEROMETER_H_
  5. #define SERVICES_DEVICE_GENERIC_SENSOR_GRAVITY_FUSION_ALGORITHM_USING_ACCELEROMETER_H_
  6. #include "services/device/generic_sensor/platform_sensor_fusion_algorithm.h"
  7. namespace device {
  8. // Algorithm that obtains gravity values from data provided by
  9. // accelerometer sensor.
  10. class GravityFusionAlgorithmUsingAccelerometer final
  11. : public PlatformSensorFusionAlgorithm {
  12. public:
  13. GravityFusionAlgorithmUsingAccelerometer();
  14. GravityFusionAlgorithmUsingAccelerometer(
  15. const GravityFusionAlgorithmUsingAccelerometer&) = delete;
  16. GravityFusionAlgorithmUsingAccelerometer& operator=(
  17. const GravityFusionAlgorithmUsingAccelerometer&) = delete;
  18. ~GravityFusionAlgorithmUsingAccelerometer() override;
  19. void SetFrequency(double frequency) override;
  20. void Reset() override;
  21. protected:
  22. bool GetFusedDataInternal(mojom::SensorType which_sensor_changed,
  23. SensorReading* fused_reading) override;
  24. private:
  25. unsigned long reading_updates_count_;
  26. // The time constant for low-pass filter.
  27. double time_constant_;
  28. double initial_timestamp_;
  29. double gravity_x_;
  30. double gravity_y_;
  31. double gravity_z_;
  32. };
  33. } // namespace device
  34. #endif // SERVICES_DEVICE_GENERIC_SENSOR_GRAVITY_FUSION_ALGORITHM_USING_ACCELEROMETER_H_