4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #ifdef _ORIENTATION_SENSOR_H_
22 float bias_accel[] = {0.098586, 0.18385, (10.084 - GRAVITY)};
23 float bias_gyro[] = {-5.3539, 0.24325, 2.3391};
24 float bias_magnetic[] = {0, 0, 0};
25 int sign_accel[] = {+1, +1, +1};
26 int sign_gyro[] = {+1, +1, +1};
27 int sign_magnetic[] = {+1, +1, +1};
28 float scale_accel = 1;
29 float scale_gyro = 1150;
30 float scale_magnetic = 1;
31 int magnetic_alignment_factor = -1;
33 void orientation_sensor::get_device_orientation(sensor_data<float> *accel_data,
34 sensor_data<float> *gyro_data, sensor_data<float> *magnetic_data)
36 vect<float, 3> vec_bias_gyro(bias_gyro);
38 pre_process_data(accel_data, accel_data, bias_accel, sign_accel, scale_accel);
39 normalize(*accel_data);
41 if (gyro_data != NULL) {
42 pre_process_data(gyro_data, gyro_data, bias_gyro, sign_gyro, scale_gyro);
45 if (magnetic_data != NULL) {
46 pre_process_data(magnetic_data, magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic);
47 normalize(*magnetic_data);
50 orien_filter.get_device_orientation(accel_data, gyro_data, magnetic_data);
53 #endif /* _ORIENTATION_SENSOR_H_ */