Commit de8b9fb8 authored by Mostyn Bramley-Moore's avatar Mostyn Bramley-Moore Committed by Commit Bot

[jumbo] avoid kEpsilon collisions in //services/device/generic_sensor

There are several kEpsilon constants defined in //services/device/generic_sensor
which conflict in jumbo builds. To avoid this, we can move the definition
to generic_sensor_consts.h.

BUG=794692

Change-Id: Ib31f20957fc8cccab59abb36779fccff9491239e
Reviewed-on: https://chromium-review.googlesource.com/826062Reviewed-by: default avatarMikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
Commit-Queue: Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
Cr-Commit-Position: refs/heads/master@{#524043}
parent 28d762e8
......@@ -17,8 +17,6 @@ namespace device {
namespace {
constexpr double kEpsilon = 1e-8;
class
AbsoluteOrientationEulerAnglesFusionAlgorithmUsingAccelerometerAndMagnetometerTest
: public DeviceServiceTestBase {
......
......@@ -7,6 +7,10 @@
namespace device {
// If two doubles differ by less than this amount, we can consider them
// to be effectively equal.
constexpr double kEpsilon = 1e-8;
// Required for conversion from G/s^2 to m/s^2
constexpr double kMeanGravity = 9.80665;
......
......@@ -7,14 +7,13 @@
#include "base/memory/ref_counted.h"
#include "services/device/device_service_test_base.h"
#include "services/device/generic_sensor/fake_platform_sensor_fusion.h"
#include "services/device/generic_sensor/generic_sensor_consts.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
namespace {
constexpr double kEpsilon = 1e-8;
class LinearAccelerationFusionAlgorithmUsingAccelerometerTest
: public DeviceServiceTestBase {
public:
......
......@@ -7,17 +7,12 @@
#include "base/memory/ref_counted.h"
#include "services/device/device_service_test_base.h"
#include "services/device/generic_sensor/fake_platform_sensor_fusion.h"
#include "services/device/generic_sensor/generic_sensor_consts.h"
#include "services/device/generic_sensor/orientation_test_data.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
namespace {
constexpr double kEpsilon = 1e-8;
} // namespace
class OrientationEulerAnglesFusionAlgorithmUsingQuaternionTest
: public DeviceServiceTestBase {
public:
......
......@@ -7,17 +7,12 @@
#include "base/memory/ref_counted.h"
#include "services/device/device_service_test_base.h"
#include "services/device/generic_sensor/fake_platform_sensor_fusion.h"
#include "services/device/generic_sensor/generic_sensor_consts.h"
#include "services/device/generic_sensor/orientation_test_data.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
namespace {
constexpr double kEpsilon = 1e-8;
} // namespace
class OrientationQuaternionFusionAlgorithmUsingEulerAnglesTest
: public DeviceServiceTestBase {
public:
......
......@@ -13,8 +13,6 @@
namespace {
const double kEpsilon = 1e-8;
// Returns orientation angles from a rotation matrix, such that the angles are
// according to spec http://dev.w3.org/geo/api/spec-source-orientation.html}.
//
......@@ -53,11 +51,12 @@ void ComputeOrientationEulerAnglesInRadiansFromRotationMatrix(
DCHECK_EQ(9u, r.size());
// Since |r| contains double, directly compare it with 0 won't be accurate,
// so here |kEpsilon| is used to check if r[8] and r[6] is close to 0. And
// this needs to be done before checking if it is greater or less than 0
// since a number close to 0 can be either a positive or negative number.
if (std::abs(r[8]) < kEpsilon) { // r[8] == 0
if (std::abs(r[6]) < kEpsilon) { // r[6] == 0, cos(beta) == 0
// so here |device::kEpsilon| is used to check if r[8] and r[6] is close to
// 0. And // this needs to be done before checking if it is greater or less
// than 0 since a number close to 0 can be either a positive or negative
// number.
if (std::abs(r[8]) < device::kEpsilon) { // r[8] == 0
if (std::abs(r[6]) < device::kEpsilon) { // r[6] == 0, cos(beta) == 0
// gimbal lock discontinuity
*alpha_in_radians = std::atan2(r[3], r[0]);
*beta_in_radians = (r[7] > 0) ? base::kPiDouble / 2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment