From 54eed59e2f0dc5ba2f3d3bd11d5abf0c78f090bc Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Wed, 29 Jun 2016 17:04:20 +0900 Subject: [PATCH 01/16] sensord: fix wrong log in case of setting batch latency Change-Id: I9254577b0ac02b44645578e1680550e7672b3bef Signed-off-by: kibak.yoon --- src/server/physical_sensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/physical_sensor.cpp b/src/server/physical_sensor.cpp index 9bc53ea..96cb7f0 100644 --- a/src/server/physical_sensor.cpp +++ b/src/server/physical_sensor.cpp @@ -147,7 +147,7 @@ bool physical_sensor::set_batch_latency(unsigned long latency) if (!m_sensor_device) return false; - _I("Polling interval is set to %dms", latency); + _I("Batch latency is set to %dms", latency); return m_sensor_device->set_batch_latency(m_info->id, latency); } -- 2.7.4 From c1e1d210100f99c32e78588a71abe9e7babdd1ef Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Thu, 30 Jun 2016 11:29:22 +0900 Subject: [PATCH 02/16] sensord: version 2.0.6 Change-Id: I03bd5c537de1f3ad27d9f5cc6d5f1ce0f72b90c1 Signed-off-by: kibak.yoon --- packaging/sensord.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sensord.spec b/packaging/sensord.spec index 9111df8..8af0b2d 100644 --- a/packaging/sensord.spec +++ b/packaging/sensord.spec @@ -1,6 +1,6 @@ Name: sensord Summary: Sensor daemon -Version: 2.0.5 +Version: 2.0.6 Release: 0 Group: System/Sensor Framework License: Apache-2.0 -- 2.7.4 From 1854e42b3a7a86d03267323a875c30043b470f37 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Thu, 30 Jun 2016 23:02:17 +0900 Subject: [PATCH 03/16] sensord: print errno log when proper errors are returned Change-Id: Ib89d28b1b75fc4ef563536f643633928ab0ec17e Signed-off-by: kibak.yoon --- src/shared/csocket.cpp | 53 ++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/shared/csocket.cpp b/src/shared/csocket.cpp index 09a7d0e..3b55107 100644 --- a/src/shared/csocket.cpp +++ b/src/shared/csocket.cpp @@ -241,29 +241,26 @@ ssize_t csocket::send_for_stream(const void *buffer, size_t size) const do { len = ::send(m_sock_fd, (const void *)((uint8_t *)buffer + total_sent_size), size - total_sent_size, m_send_flags); - if (len >= 0) { - total_sent_size += len; - err = 0; - } else { - _ERRNO(errno, _E, "Failed to send(%d, %#p + %d, %d - %d) = %d for %s", - m_sock_fd, buffer, total_sent_size, size, total_sent_size, - len, get_client_name()); - + if (len < 0) { /* * If socket is not available to use it temporarily, - * EAGAIN(EWOULDBLOCK) is returned by ::send(). + * EAGAIN(EWOULDBLOCK) or EINTR is returned by ::send(). * so in order to prevent that data are omitted, sleep&retry to send it */ - if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { - usleep(1000); + if ((errno == EINTR) || (errno == EAGAIN) || (errno == EWOULDBLOCK)) { + usleep(10000); continue; } - if (errno != EINTR) { - err = errno; - break; - } + _ERRNO(errno, _E, "Failed to send(%d, %#p + %d, %d - %d) = %d for %s", + m_sock_fd, buffer, total_sent_size, size, total_sent_size, + len, get_client_name()); + + err = errno; + break; } + + total_sent_size += len; } while (total_sent_size < size); return err == 0 ? total_sent_size : -err; @@ -278,33 +275,33 @@ ssize_t csocket::recv_for_stream(void* buffer, size_t size) const do { len = ::recv(m_sock_fd, (void *)((uint8_t *)buffer + total_recv_size), size - total_recv_size, m_recv_flags); - if (len > 0) { - total_recv_size += len; - } else if (len == 0) { + if (len == 0) { _E("recv(%d, %#p + %d, %d - %d) = %d, because the peer of %s performed shutdown!", m_sock_fd, buffer, total_recv_size, size, total_recv_size, len, get_client_name()); err = 1; break; - } else { - _ERRNO(errno, _E, "Failed to recv(%d, %#p + %d, %d - %d) = %d for %s", - m_sock_fd, buffer, total_recv_size, size, total_recv_size, - len, get_client_name()); + } + if (len < 0) { /* * If socket is not available to use it temporarily, * EAGAIN(EWOULDBLOCK) is returned by ::recv(). * so in order to prevent that data are omitted, sleep&retry to receive it */ - if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { - usleep(1000); + if ((errno != EINTR) || (errno == EAGAIN) || (errno == EWOULDBLOCK)) { + usleep(10000); continue; } - if (errno != EINTR) { - err = errno; - break; - } + _ERRNO(errno, _E, "Failed to recv(%d, %#p + %d, %d - %d) = %d for %s", + m_sock_fd, buffer, total_recv_size, size, total_recv_size, + len, get_client_name()); + + err = errno; + break; } + + total_recv_size += len; } while (total_recv_size < size); return err == 0 ? total_recv_size : -err; -- 2.7.4 From 61f313be33ef4017cc02f370d5c7018380528363 Mon Sep 17 00:00:00 2001 From: "hs81.go" Date: Fri, 1 Jul 2016 14:05:45 +0900 Subject: [PATCH 04/16] sensord: modify enum values for classification Change-Id: I0db7552f2c29f1805a20f13f47a7d79a73f0adec Signed-off-by: kibak.yoon --- src/hal/sensor_hal_types.h | 6 +++--- src/shared/sensor_types.h | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/hal/sensor_hal_types.h b/src/hal/sensor_hal_types.h index ffa96f1..6c30f47 100644 --- a/src/hal/sensor_hal_types.h +++ b/src/hal/sensor_hal_types.h @@ -92,11 +92,11 @@ typedef enum { SENSOR_DEVICE_GESTURE_WRIST_DOWN, SENSOR_DEVICE_GESTURE_MOVEMENT_STATE, - SENSOR_DEVICE_GPS_BATCH = 0x1A00, - SENSOR_DEVICE_ACTIVITY_TRACKER, + SENSOR_DEVICE_ACTIVITY_TRACKER = 0x1A00, + SENSOR_DEVICE_ACTIVITY_LEVEL_MONITOR, + SENSOR_DEVICE_GPS_BATCH, SENSOR_DEVICE_HRM_CTRL = 0x1A80, - SENSOR_DEVICE_ACTIVITY_LEVEL_MONITOR, SENSOR_DEVICE_WEAR_STATUS = 0x2000, SENSOR_DEVICE_WEAR_ON_MONITOR, diff --git a/src/shared/sensor_types.h b/src/shared/sensor_types.h index 0612f72..277cbc4 100644 --- a/src/shared/sensor_types.h +++ b/src/shared/sensor_types.h @@ -75,12 +75,11 @@ extern "C" DEF_SENSOR(GESTURE_WRIST_DOWN_SENSOR) \ DEF_SENSOR(GESTURE_MOVEMENT_STATE_SENSOR) \ \ - DEF_SENSOR_VALUE(GPS_BATCH_SENSOR, 0x1A00) \ - DEF_SENSOR(ACTIVITY_TRACKER_SENSOR) \ - DEF_SENSOR(EXERCISE_COMPANION_SENSOR) \ + DEF_SENSOR_VALUE(ACTIVITY_TRACKER_SENSOR, 0x1A00) \ + DEF_SENSOR(ACTIVITY_LEVEL_MONITOR_SENSOR) \ + DEF_SENSOR(GPS_BATCH_SENSOR) \ \ DEF_SENSOR_VALUE(HRM_CTRL_SENSOR, 0x1A80) \ - DEF_SENSOR(ACTIVITY_LEVEL_MONITOR_SENSOR) \ \ DEF_SENSOR_VALUE(WEAR_STATUS_SENSOR, 0x2000) \ DEF_SENSOR(WEAR_ON_MONITOR_SENSOR) \ @@ -114,7 +113,6 @@ extern "C" #define STRESS_MONITOR_SENSOR HUMAN_STRESS_MONITOR_SENSOR #define AUTOSESSION_EXERCISE_SENSOR WORKOUT_SENSOR #define EXERCISE_COACH_SENSOR EXERCISE_STANDALONE_SENSOR -#define EXERCISE_SENSOR EXERCISE_COMPANION_SENSOR DECLARE_SENSOR_ENUM(sensor_type_t, SENSOR_TYPE) -- 2.7.4 From d33da5b5ef6e18713c32c371d0714246af6c337b Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Wed, 20 Jul 2016 20:28:46 +0900 Subject: [PATCH 05/16] Set SmackProcessLabel to System Change-Id: Ic6db23e47dfc46aeade072e08a8396b4505774a5 Signed-off-by: Yunjin Lee --- packaging/sensord.service | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/sensord.service b/packaging/sensord.service index 5cb2e72..031b383 100644 --- a/packaging/sensord.service +++ b/packaging/sensord.service @@ -5,6 +5,7 @@ Description=Sensor Daemon User=sensor Group=input Type=notify +SmackProcessLabel=System ExecStart=/usr/bin/sensord MemoryLimit=20M Sockets=sensord_command.socket -- 2.7.4 From 0c00a6c13a8be9ffaf27a7b2e5eba2cbe7abdd7f Mon Sep 17 00:00:00 2001 From: akhilkedia94 Date: Fri, 29 Jul 2016 15:27:17 +0900 Subject: [PATCH 06/16] Porting Sensor Fusion to Tizen 3.0 Change-Id: I8607fea652431cf277d7f9a577686c77318052bc Signed-off-by: akhilkedia94 --- .gitignore | 1 + src/sensor/CMakeLists.txt | 5 +- src/sensor/fusion/fusion_sensor.cpp | 440 --------------------- src/sensor/fusion/fusion_sensor.h | 81 ---- .../documentation}/hardware_fusion_sensor.html | 0 src/sensor/sensor_fusion/fusion.h | 37 ++ src/sensor/sensor_fusion/fusion_base.cpp | 105 +++++ src/sensor/sensor_fusion/fusion_base.h | 60 +++ src/sensor/sensor_fusion/gyro_fusion.cpp | 39 ++ src/sensor/sensor_fusion/gyro_fusion.h | 33 ++ src/sensor/sensor_fusion/gyro_magnetic_fusion.cpp | 40 ++ src/sensor/sensor_fusion/gyro_magnetic_fusion.h | 33 ++ src/sensor/sensor_fusion/magnetic_fusion.cpp | 39 ++ src/sensor/sensor_fusion/magnetic_fusion.h | 33 ++ src/sensor/sensor_fusion/orientation_filter.cpp | 4 +- src/sensor/sensor_fusion/orientation_filter.h | 2 - src/sensor/sensor_fusion/sensor_data.cpp | 9 +- src/sensor/sensor_fusion/sensor_data.h | 2 +- .../sensor_fusion/test/orientation_sensor.cpp | 2 - 19 files changed, 429 insertions(+), 536 deletions(-) delete mode 100644 src/sensor/fusion/fusion_sensor.cpp delete mode 100644 src/sensor/fusion/fusion_sensor.h rename src/sensor/{fusion => sensor_fusion/design/documentation}/hardware_fusion_sensor.html (100%) create mode 100644 src/sensor/sensor_fusion/fusion.h create mode 100644 src/sensor/sensor_fusion/fusion_base.cpp create mode 100644 src/sensor/sensor_fusion/fusion_base.h create mode 100644 src/sensor/sensor_fusion/gyro_fusion.cpp create mode 100644 src/sensor/sensor_fusion/gyro_fusion.h create mode 100644 src/sensor/sensor_fusion/gyro_magnetic_fusion.cpp create mode 100644 src/sensor/sensor_fusion/gyro_magnetic_fusion.h create mode 100644 src/sensor/sensor_fusion/magnetic_fusion.cpp create mode 100644 src/sensor/sensor_fusion/magnetic_fusion.h diff --git a/.gitignore b/.gitignore index 8b1529d..ca9cbd7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .project .cproject .*.swp +nbproject diff --git a/src/sensor/CMakeLists.txt b/src/sensor/CMakeLists.txt index 7328a1d..0547bc8 100644 --- a/src/sensor/CMakeLists.txt +++ b/src/sensor/CMakeLists.txt @@ -14,7 +14,7 @@ ELSE() SET(RV "OFF") SET(ORIENTATION "OFF") ENDIF() -SET(FUSION "OFF") +SET(FUSION "ON") SET(MOTION "OFF") INCLUDE_DIRECTORIES( @@ -64,7 +64,8 @@ IF("${RV}" STREQUAL "ON") SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_ROTATION_VECTOR") ENDIF() IF("${FUSION}" STREQUAL "ON") -add_subdirectory(fusion) +FILE(GLOB SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion/*.cpp) +SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion) ENDIF() IF("${MOTION}" STREQUAL "ON") add_subdirectory(motion) diff --git a/src/sensor/fusion/fusion_sensor.cpp b/src/sensor/fusion/fusion_sensor.cpp deleted file mode 100644 index ff56ead..0000000 --- a/src/sensor/fusion/fusion_sensor.cpp +++ /dev/null @@ -1,440 +0,0 @@ -/* - * sensord - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using std::string; -using std::vector; - -#define SENSOR_NAME "FUSION_SENSOR" -#define SENSOR_TYPE_FUSION "FUSION" - -#define ACCELEROMETER_ENABLED 0x01 -#define GYROSCOPE_ENABLED 0x02 -#define GEOMAGNETIC_ENABLED 0x04 -#define TILT_ENABLED 1 -#define GAMING_RV_ENABLED 3 -#define GEOMAGNETIC_RV_ENABLED 5 -#define ORIENTATION_ENABLED 7 -#define ROTATION_VECTOR_ENABLED 7 -#define GYROSCOPE_UNCAL_ENABLED 7 - -#define INITIAL_VALUE -1 - -#define MS_TO_US 1000 -#define MIN_DELIVERY_DIFF_FACTOR 0.75f - -#define PI 3.141593 -#define AZIMUTH_OFFSET_DEGREES 360 -#define AZIMUTH_OFFSET_RADIANS (2 * PI) - -#define ELEMENT_NAME "NAME" -#define ELEMENT_VENDOR "VENDOR" -#define ELEMENT_RAW_DATA_UNIT "RAW_DATA_UNIT" -#define ELEMENT_DEFAULT_SAMPLING_TIME "DEFAULT_SAMPLING_TIME" -#define ELEMENT_ACCEL_STATIC_BIAS "ACCEL_STATIC_BIAS" -#define ELEMENT_GYRO_STATIC_BIAS "GYRO_STATIC_BIAS" -#define ELEMENT_GEOMAGNETIC_STATIC_BIAS "GEOMAGNETIC_STATIC_BIAS" -#define ELEMENT_ACCEL_ROTATION_DIRECTION_COMPENSATION "ACCEL_ROTATION_DIRECTION_COMPENSATION" -#define ELEMENT_GYRO_ROTATION_DIRECTION_COMPENSATION "GYRO_ROTATION_DIRECTION_COMPENSATION" -#define ELEMENT_GEOMAGNETIC_ROTATION_DIRECTION_COMPENSATION "GEOMAGNETIC_ROTATION_DIRECTION_COMPENSATION" -#define ELEMENT_MAGNETIC_ALIGNMENT_FACTOR "MAGNETIC_ALIGNMENT_FACTOR" -#define ELEMENT_PITCH_ROTATION_COMPENSATION "PITCH_ROTATION_COMPENSATION" -#define ELEMENT_ROLL_ROTATION_COMPENSATION "ROLL_ROTATION_COMPENSATION" -#define ELEMENT_AZIMUTH_ROTATION_COMPENSATION "AZIMUTH_ROTATION_COMPENSATION" - -fusion_sensor::fusion_sensor() -: m_accel_sensor(NULL) -, m_gyro_sensor(NULL) -, m_magnetic_sensor(NULL) -, m_time(0) -{ - virtual_sensor_config &config = virtual_sensor_config::get_instance(); - m_name = string(SENSOR_NAME); - m_enable_fusion = 0; - - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_VENDOR, m_vendor)) { - _E("[VENDOR] is empty\n"); - throw ENXIO; - } - - _I("m_vendor = %s", m_vendor.c_str()); - - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_RAW_DATA_UNIT, m_raw_data_unit)) { - _E("[RAW_DATA_UNIT] is empty\n"); - throw ENXIO; - } - - _I("m_raw_data_unit = %s", m_raw_data_unit.c_str()); - - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_DEFAULT_SAMPLING_TIME, &m_default_sampling_time)) { - _E("[DEFAULT_SAMPLING_TIME] is empty\n"); - throw ENXIO; - } - - _I("m_default_sampling_time = %d", m_default_sampling_time); - - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_ACCEL_STATIC_BIAS, m_accel_static_bias, 3)) { - _E("[ACCEL_STATIC_BIAS] is empty\n"); - throw ENXIO; - } - - _I("m_accel_static_bias = (%f, %f, %f)", m_accel_static_bias[0], m_accel_static_bias[1], m_accel_static_bias[2]); - - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_GYRO_STATIC_BIAS, m_gyro_static_bias, 3)) { - _E("[GYRO_STATIC_BIAS] is empty\n"); - throw ENXIO; - } - - _I("m_gyro_static_bias = (%f, %f, %f)", m_gyro_static_bias[0], m_gyro_static_bias[1], m_gyro_static_bias[2]); - - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_GEOMAGNETIC_STATIC_BIAS, m_geomagnetic_static_bias, 3)) { - _E("[GEOMAGNETIC_STATIC_BIAS] is empty\n"); - throw ENXIO; - } - - _I("m_geomagnetic_static_bias = (%f, %f, %f)", m_geomagnetic_static_bias[0], m_geomagnetic_static_bias[1], m_geomagnetic_static_bias[2]); - - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_ACCEL_ROTATION_DIRECTION_COMPENSATION, m_accel_rotation_direction_compensation, 3)) { - _E("[ACCEL_ROTATION_DIRECTION_COMPENSATION] is empty\n"); - throw ENXIO; - } - - _I("m_accel_rotation_direction_compensation = (%d, %d, %d)", m_accel_rotation_direction_compensation[0], m_accel_rotation_direction_compensation[1], m_accel_rotation_direction_compensation[2]); - - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_GYRO_ROTATION_DIRECTION_COMPENSATION, m_gyro_rotation_direction_compensation, 3)) { - _E("[GYRO_ROTATION_DIRECTION_COMPENSATION] is empty\n"); - throw ENXIO; - } - - _I("m_gyro_rotation_direction_compensation = (%d, %d, %d)", m_gyro_rotation_direction_compensation[0], m_gyro_rotation_direction_compensation[1], m_gyro_rotation_direction_compensation[2]); - - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_GEOMAGNETIC_ROTATION_DIRECTION_COMPENSATION, m_geomagnetic_rotation_direction_compensation, 3)) { - _E("[GEOMAGNETIC_ROTATION_DIRECTION_COMPENSATION] is empty\n"); - throw ENXIO; - } - - _I("m_geomagnetic_rotation_direction_compensation = (%d, %d, %d)", m_geomagnetic_rotation_direction_compensation[0], m_geomagnetic_rotation_direction_compensation[1], m_geomagnetic_rotation_direction_compensation[2]); - - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_MAGNETIC_ALIGNMENT_FACTOR, &m_magnetic_alignment_factor)) { - _E("[MAGNETIC_ALIGNMENT_FACTOR] is empty\n"); - throw ENXIO; - } - - _I("m_magnetic_alignment_factor = %d", m_magnetic_alignment_factor); - - m_interval = m_default_sampling_time * MS_TO_US; - - m_accel_ptr = m_gyro_ptr = m_magnetic_ptr = NULL; -} - -fusion_sensor::~fusion_sensor() -{ - _I("fusion_sensor is destroyed!\n"); -} - -bool fusion_sensor::init(void) -{ - m_accel_sensor = sensor_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR); - m_gyro_sensor = sensor_loader::get_instance().get_sensor(GYROSCOPE_SENSOR); - m_magnetic_sensor = sensor_loader::get_instance().get_sensor(GEOMAGNETIC_SENSOR); - - if (!m_accel_sensor) { - _E("Failed to load accel sensor: %#x", m_accel_sensor); - return false; - } - - if (!m_gyro_sensor) - _I("Failed to load gyro sensor: %#x", m_gyro_sensor); - - if (!m_magnetic_sensor) - _I("Failed to load geomagnetic sensor: %#x", m_magnetic_sensor); - - _I("%s is created!", sensor_base::get_name()); - return true; -} - -void fusion_sensor::get_types(vector &types) -{ - types.push_back(FUSION_SENSOR); -} - -bool fusion_sensor::on_start(void) -{ - AUTOLOCK(m_mutex); - activate(); - return true; -} - -bool fusion_sensor::on_stop(void) -{ - AUTOLOCK(m_mutex); - deactivate(); - return true; -} - -bool fusion_sensor::add_interval(int client_id, unsigned int interval) -{ - bool retval; - - AUTOLOCK(m_mutex); - retval = sensor_base::add_interval(client_id, interval, false); - - m_interval = sensor_base::get_interval(client_id, false); - - if (m_interval != 0) - retval = true; - - return retval; -} - -bool fusion_sensor::delete_interval(int client_id) -{ - bool retval; - - AUTOLOCK(m_mutex); - retval = sensor_base::delete_interval(client_id, false); - - m_interval = sensor_base::get_interval(client_id, false); - - if (m_interval != 0) - retval = true; - - return retval; -} - -void fusion_sensor::synthesize(const sensor_event_t &event, vector &outs) -{ - unsigned long long diff_time; - euler_angles euler_orientation; - - if (event.event_type == ACCELEROMETER_RAW_DATA_EVENT) { - diff_time = event.data.timestamp - m_time; - - if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR)) - return; - - pre_process_data(m_accel, event.data.values, m_accel_static_bias, m_accel_rotation_direction_compensation, ACCEL_SCALE); - - m_accel.m_time_stamp = event.data.timestamp; - - m_accel_ptr = &m_accel; - - m_enable_fusion |= ACCELEROMETER_ENABLED; - } - - if (sensor_base::is_supported(FUSION_ORIENTATION_ENABLED) || - sensor_base::is_supported(FUSION_ROTATION_VECTOR_ENABLED) || - sensor_base::is_supported(FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED) || - sensor_base::is_supported(FUSION_GYROSCOPE_UNCAL_ENABLED)) { - if (event.event_type == GEOMAGNETIC_RAW_DATA_EVENT) { - diff_time = event.data.timestamp - m_time; - - if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR)) - return; - - pre_process_data(m_magnetic, event.data.values, m_geomagnetic_static_bias, m_geomagnetic_rotation_direction_compensation, GEOMAGNETIC_SCALE); - - m_magnetic.m_time_stamp = event.data.timestamp; - - m_magnetic_ptr = &m_magnetic; - - m_enable_fusion |= GEOMAGNETIC_ENABLED; - } - } - - if (sensor_base::is_supported(FUSION_ORIENTATION_ENABLED) || - sensor_base::is_supported(FUSION_ROTATION_VECTOR_ENABLED) || - sensor_base::is_supported(FUSION_GAMING_ROTATION_VECTOR_ENABLED) || - sensor_base::is_supported(FUSION_GYROSCOPE_UNCAL_ENABLED)) { - if (event.event_type == GYROSCOPE_RAW_DATA_EVENT) { - diff_time = event.data.timestamp - m_time; - - if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR)) - return; - - pre_process_data(m_gyro, event.data.values, m_gyro_static_bias, m_gyro_rotation_direction_compensation, GYRO_SCALE); - - m_gyro.m_time_stamp = event.data.timestamp; - - m_gyro_ptr = &m_gyro; - - m_enable_fusion |= GYROSCOPE_ENABLED; - } - } - - if ((m_enable_fusion == TILT_ENABLED && sensor_base::is_supported(FUSION_TILT_ENABLED)) || - (m_enable_fusion == ORIENTATION_ENABLED && sensor_base::is_supported(FUSION_ORIENTATION_ENABLED)) || - (m_enable_fusion == ROTATION_VECTOR_ENABLED && sensor_base::is_supported(FUSION_ROTATION_VECTOR_ENABLED)) || - (m_enable_fusion == GAMING_RV_ENABLED && sensor_base::is_supported(FUSION_GAMING_ROTATION_VECTOR_ENABLED)) || - (m_enable_fusion == GEOMAGNETIC_RV_ENABLED && sensor_base::is_supported(FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED)) || - (m_enable_fusion == GYROSCOPE_UNCAL_ENABLED && sensor_base::is_supported(FUSION_GYROSCOPE_UNCAL_ENABLED))) { - sensor_event_t fusion_event; - - m_orientation_filter.m_magnetic_alignment_factor = m_magnetic_alignment_factor; - - m_orientation_filter.get_device_orientation(m_accel_ptr, m_gyro_ptr, m_magnetic_ptr); - - if (m_enable_fusion == GYROSCOPE_UNCAL_ENABLED && sensor_base::is_supported(FUSION_GYROSCOPE_UNCAL_ENABLED)) { - m_time = get_timestamp(); - fusion_event.sensor_id = get_id(); - fusion_event.data.timestamp = m_time; - fusion_event.data.accuracy = SENSOR_ACCURACY_GOOD; - fusion_event.event_type = FUSION_GYROSCOPE_UNCAL_EVENT; - fusion_event.data.value_count = 3; - fusion_event.data.values[0] = m_orientation_filter.m_gyro_bias.m_vec[0]; - fusion_event.data.values[1] = m_orientation_filter.m_gyro_bias.m_vec[1]; - fusion_event.data.values[2] = m_orientation_filter.m_gyro_bias.m_vec[2]; - - push(fusion_event); - } - - if ((m_enable_fusion == TILT_ENABLED && sensor_base::is_supported(FUSION_TILT_ENABLED)) || - (m_enable_fusion == ORIENTATION_ENABLED && sensor_base::is_supported(FUSION_ORIENTATION_ENABLED)) || - (m_enable_fusion == ROTATION_VECTOR_ENABLED && sensor_base::is_supported(FUSION_ROTATION_VECTOR_ENABLED)) || - (m_enable_fusion == GAMING_RV_ENABLED && sensor_base::is_supported(FUSION_GAMING_ROTATION_VECTOR_ENABLED)) || - (m_enable_fusion == GEOMAGNETIC_RV_ENABLED && sensor_base::is_supported(FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED))) { - m_time = get_timestamp(); - fusion_event.sensor_id = get_id(); - fusion_event.data.timestamp = m_time; - fusion_event.data.accuracy = SENSOR_ACCURACY_GOOD; - fusion_event.event_type = FUSION_EVENT; - fusion_event.data.value_count = 4; - fusion_event.data.values[0] = m_orientation_filter.m_quaternion.m_quat.m_vec[0]; - fusion_event.data.values[1] = m_orientation_filter.m_quaternion.m_quat.m_vec[1]; - fusion_event.data.values[2] = m_orientation_filter.m_quaternion.m_quat.m_vec[2]; - fusion_event.data.values[3] = m_orientation_filter.m_quaternion.m_quat.m_vec[3]; - - push(fusion_event); - } - - m_enable_fusion = 0; - m_accel_ptr = m_gyro_ptr = m_magnetic_ptr = NULL; - } - - return; -} - -int fusion_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t &data) -{ - sensor_data accel; - sensor_data gyro; - sensor_data magnetic; - - sensor_data_t accel_data; - sensor_data_t gyro_data; - sensor_data_t magnetic_data; - - euler_angles euler_orientation; - - if (event_type != FUSION_ORIENTATION_ENABLED && - event_type != FUSION_ROTATION_VECTOR_ENABLED && - event_type != FUSION_GAMING_ROTATION_VECTOR_ENABLED && - event_type != FUSION_TILT_ENABLED && - event_type != FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED && - event_type != FUSION_GYROSCOPE_UNCAL_ENABLED) - return -1; - - m_accel_sensor->get_sensor_data(ACCELEROMETER_RAW_DATA_EVENT, accel_data); - pre_process_data(accel, accel_data.values, m_accel_static_bias, m_accel_rotation_direction_compensation, ACCEL_SCALE); - accel.m_time_stamp = accel_data.timestamp; - - if (event_type == FUSION_ORIENTATION_ENABLED || - event_type == FUSION_ROTATION_VECTOR_ENABLED || - event_type == FUSION_GAMING_ROTATION_VECTOR_ENABLED || - event_type == FUSION_GYROSCOPE_UNCAL_ENABLED) - { - m_gyro_sensor->get_sensor_data(GYROSCOPE_RAW_DATA_EVENT, gyro_data); - pre_process_data(gyro, gyro_data.values, m_gyro_static_bias, m_gyro_rotation_direction_compensation, GYRO_SCALE); - gyro.m_time_stamp = gyro_data.timestamp; - } - - if (event_type == FUSION_ORIENTATION_ENABLED || - event_type == FUSION_ROTATION_VECTOR_ENABLED || - event_type == FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED || - event_type == FUSION_GYROSCOPE_UNCAL_ENABLED) - { - m_magnetic_sensor->get_sensor_data(GEOMAGNETIC_RAW_DATA_EVENT, magnetic_data); - pre_process_data(magnetic, magnetic_data.values, m_geomagnetic_static_bias, m_geomagnetic_rotation_direction_compensation, GEOMAGNETIC_SCALE); - magnetic.m_time_stamp = magnetic_data.timestamp; - } - - m_orientation_filter_poll.m_magnetic_alignment_factor = m_magnetic_alignment_factor; - - if (event_type == FUSION_ORIENTATION_ENABLED || - event_type == FUSION_ROTATION_VECTOR_ENABLED || - event_type == FUSION_GYROSCOPE_UNCAL_ENABLED) - m_orientation_filter_poll.get_device_orientation(&accel, &gyro, &magnetic); - else if (event_type == FUSION_GAMING_ROTATION_VECTOR_ENABLED) - m_orientation_filter_poll.get_device_orientation(&accel, &gyro, NULL); - else if (event_type == FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED) - m_orientation_filter_poll.get_device_orientation(&accel, NULL, &magnetic); - else if (event_type == FUSION_TILT_ENABLED) - m_orientation_filter_poll.get_device_orientation(&accel, NULL, NULL); - - if (event_type == FUSION_GYROSCOPE_UNCAL_ENABLED) { - data.accuracy = SENSOR_ACCURACY_GOOD; - data.timestamp = get_timestamp(); - data.value_count = 3; - data.values[0] = m_orientation_filter_poll.m_gyro_bias.m_vec[0]; - data.values[1] = m_orientation_filter_poll.m_gyro_bias.m_vec[1]; - data.values[2] = m_orientation_filter_poll.m_gyro_bias.m_vec[2]; - } else if (event_type == FUSION_ORIENTATION_ENABLED || - event_type == FUSION_ROTATION_VECTOR_ENABLED || - event_type == FUSION_GAMING_ROTATION_VECTOR_ENABLED || - event_type == FUSION_TILT_ENABLED || - event_type == FUSION_GEOMAGNETIC_ROTATION_VECTOR_ENABLED) { - data.accuracy = SENSOR_ACCURACY_GOOD; - data.timestamp = get_timestamp(); - data.value_count = 4; - data.values[0] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[0]; - data.values[1] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[1]; - data.values[2] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[2]; - data.values[3] = m_orientation_filter_poll.m_quaternion.m_quat.m_vec[3]; - } - - return 0; -} - -bool fusion_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties) -{ - properties.min_range = 0; - properties.max_range = 0; - properties.resolution = 0; - properties.vendor = m_vendor; - properties.name = SENSOR_NAME; - properties.min_interval = 0; - properties.fifo_count = 0; - properties.max_batch_count = 0; - - return true; -} diff --git a/src/sensor/fusion/fusion_sensor.h b/src/sensor/fusion/fusion_sensor.h deleted file mode 100644 index 4985f15..0000000 --- a/src/sensor/fusion/fusion_sensor.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * sensord - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef _FUSION_SENSOR_H_ -#define _FUSION_SENSOR_H_ - -#include -#include -#include - -class fusion_sensor : public virtual_sensor { -public: - fusion_sensor(); - virtual ~fusion_sensor(); - - bool init(void); - - void synthesize(const sensor_event_t &event, vector &outs); - - bool add_interval(int client_id, unsigned int interval); - bool delete_interval(int client_id); - virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties); - virtual void get_types(std::vector &types); - - int get_sensor_data(const unsigned int data_id, sensor_data_t &data); - -private: - sensor_base *m_accel_sensor; - sensor_base *m_gyro_sensor; - sensor_base *m_magnetic_sensor; - - sensor_data m_accel; - sensor_data m_gyro; - sensor_data m_magnetic; - - sensor_data *m_accel_ptr; - sensor_data *m_gyro_ptr; - sensor_data *m_magnetic_ptr; - - cmutex m_value_mutex; - - orientation_filter m_orientation_filter; - orientation_filter m_orientation_filter_poll; - - unsigned int m_enable_fusion; - - unsigned long long m_time; - unsigned int m_interval; - - std::string m_vendor; - std::string m_raw_data_unit; - int m_default_sampling_time; - float m_accel_static_bias[3]; - float m_gyro_static_bias[3]; - float m_geomagnetic_static_bias[3]; - int m_accel_rotation_direction_compensation[3]; - int m_gyro_rotation_direction_compensation[3]; - int m_geomagnetic_rotation_direction_compensation[3]; - int m_magnetic_alignment_factor; - - bool on_start(void); - bool on_stop(void); -}; - -#endif diff --git a/src/sensor/fusion/hardware_fusion_sensor.html b/src/sensor/sensor_fusion/design/documentation/hardware_fusion_sensor.html similarity index 100% rename from src/sensor/fusion/hardware_fusion_sensor.html rename to src/sensor/sensor_fusion/design/documentation/hardware_fusion_sensor.html diff --git a/src/sensor/sensor_fusion/fusion.h b/src/sensor/sensor_fusion/fusion.h new file mode 100644 index 0000000..d53f800 --- /dev/null +++ b/src/sensor/sensor_fusion/fusion.h @@ -0,0 +1,37 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef __FUSION_H__ +#define __FUSION_H__ + +#include + +class fusion { +public: + fusion() {}; + virtual ~fusion() {} ; + + virtual void push_accel(sensor_data_t &data) = 0; + virtual void push_gyro(sensor_data_t &data) = 0; + virtual void push_mag(sensor_data_t &data) = 0; + virtual bool get_rv(unsigned long long timestamp, float &w, float &x, float &y, float &z) = 0; +}; + + + +#endif /* __FUSION_H__ */ diff --git a/src/sensor/sensor_fusion/fusion_base.cpp b/src/sensor/sensor_fusion/fusion_base.cpp new file mode 100644 index 0000000..92e02f6 --- /dev/null +++ b/src/sensor/sensor_fusion/fusion_base.cpp @@ -0,0 +1,105 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fusion_base.h" +#include "orientation_filter.h" + +#define ACCEL_COMPENSATION -1 +#define GYRO_COMPENSATION 1 +#define MAG_COMPENSATION -1 + +fusion_base::fusion_base() +: m_enable_accel(false) +, m_enable_gyro(false) +, m_enable_magnetic(false) +{ + _I("fusion_base is created!"); +} + +fusion_base::~fusion_base() +{ + _I("fusion_sensor is destroyed!"); +} + +void fusion_base::clear(void) +{ + m_enable_accel = false; + m_enable_gyro = false; + m_enable_magnetic = false; +} + +void fusion_base::push_accel(sensor_data_t &data) +{ + //_I("[fusion_sensor] : Pushing accel"); + pre_process_data(m_accel, data.values, ACCEL_COMPENSATION, ACCEL_SCALE); + m_accel.m_time_stamp = data.timestamp; + m_enable_accel = true; + if (get_orientation()) + store_orientation(); +} + +void fusion_base::push_gyro(sensor_data_t &data) +{ + //_I("[fusion_sensor] : Pushing mag"); + pre_process_data(m_gyro, data.values, GYRO_COMPENSATION, GYRO_SCALE); + m_gyro.m_time_stamp = data.timestamp; + m_enable_gyro = true; + if (get_orientation()) + store_orientation(); +} + +void fusion_base::push_mag(sensor_data_t &data) +{ + //_I("[fusion_sensor] : Pushing gyro"); + pre_process_data(m_magnetic, data.values, MAG_COMPENSATION, GEOMAGNETIC_SCALE); + m_magnetic.m_time_stamp = data.timestamp; + m_enable_magnetic = true; + if (get_orientation()) + store_orientation(); + +} + +bool fusion_base::get_rv(unsigned long long timestamp, float &x, float &y, float &z, float &w) +{ + if (m_timestamp == 0) + return false; + timestamp = m_timestamp; + x = m_x; + y = m_y; + z = m_z; + w = m_w; + return true; +} + +void fusion_base::store_orientation(void) +{ + m_x = m_orientation_filter.m_quaternion.m_quat.m_vec[0]; + m_y = m_orientation_filter.m_quaternion.m_quat.m_vec[1]; + m_z = m_orientation_filter.m_quaternion.m_quat.m_vec[2]; + m_w = m_orientation_filter.m_quaternion.m_quat.m_vec[3]; + clear(); +} \ No newline at end of file diff --git a/src/sensor/sensor_fusion/fusion_base.h b/src/sensor/sensor_fusion/fusion_base.h new file mode 100644 index 0000000..2428712 --- /dev/null +++ b/src/sensor/sensor_fusion/fusion_base.h @@ -0,0 +1,60 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef __FUSION_BASE_H__ +#define __FUSION_BASE_H__ + +#include +#include + +class fusion_base : public virtual fusion { +public: + fusion_base(); + virtual ~fusion_base(); + + virtual void push_accel(sensor_data_t &data); + virtual void push_gyro(sensor_data_t &data); + virtual void push_mag(sensor_data_t &data); + virtual bool get_rv(unsigned long long timestamp, float &w, float &x, float &y, float &z); + +protected: + + sensor_data m_accel; + sensor_data m_gyro; + sensor_data m_magnetic; + + orientation_filter m_orientation_filter; + + bool m_enable_accel; + bool m_enable_gyro; + bool m_enable_magnetic; + + float m_x; + float m_y; + float m_z; + float m_w; + float m_timestamp; + + void clear(); + void store_orientation(void); + virtual bool get_orientation(void) = 0; +}; + + + +#endif /* __FUSION_BASE_H__ */ diff --git a/src/sensor/sensor_fusion/gyro_fusion.cpp b/src/sensor/sensor_fusion/gyro_fusion.cpp new file mode 100644 index 0000000..a668e65 --- /dev/null +++ b/src/sensor/sensor_fusion/gyro_fusion.cpp @@ -0,0 +1,39 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "gyro_fusion.h" + +gyro_fusion::gyro_fusion() +{ +} + +gyro_fusion::~gyro_fusion() +{ +} + +bool gyro_fusion::get_orientation(void) +{ + //_I("[fusion_sensor] : enable values are %d %d %d", m_enable_accel, m_enable_gyro, m_enable_magnetic); + if (!m_enable_accel || !m_enable_gyro) + return false; + + m_orientation_filter.get_device_orientation(&m_accel, &m_gyro, NULL); + m_timestamp = fmax(m_accel.m_time_stamp, m_gyro.m_time_stamp); + return true; +} diff --git a/src/sensor/sensor_fusion/gyro_fusion.h b/src/sensor/sensor_fusion/gyro_fusion.h new file mode 100644 index 0000000..0089e0d --- /dev/null +++ b/src/sensor/sensor_fusion/gyro_fusion.h @@ -0,0 +1,33 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __GYRO_FUSION_H__ +#define __GYRO_FUSION_H__ + +#include + +class gyro_fusion : public fusion_base { +public: + gyro_fusion(); + ~gyro_fusion(); +private: + bool get_orientation(); +}; + +#endif /* __GYRO_FUSION_H__ */ diff --git a/src/sensor/sensor_fusion/gyro_magnetic_fusion.cpp b/src/sensor/sensor_fusion/gyro_magnetic_fusion.cpp new file mode 100644 index 0000000..0d1f32d --- /dev/null +++ b/src/sensor/sensor_fusion/gyro_magnetic_fusion.cpp @@ -0,0 +1,40 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "gyro_magnetic_fusion.h" + +gyro_magnetic_fusion::gyro_magnetic_fusion() +{ +} + +gyro_magnetic_fusion::~gyro_magnetic_fusion() +{ +} + +bool gyro_magnetic_fusion::get_orientation(void) +{ + //_I("[fusion_sensor] : enable values are %d %d %d", m_enable_accel, m_enable_gyro, m_enable_magnetic); + if (!m_enable_accel || !m_enable_gyro || !m_enable_magnetic) + return false; + + m_orientation_filter.get_device_orientation(&m_accel, &m_gyro, &m_magnetic); + m_timestamp = fmax(m_accel.m_time_stamp, m_gyro.m_time_stamp); + m_timestamp = fmax(m_timestamp, m_magnetic.m_time_stamp); + return true; +} diff --git a/src/sensor/sensor_fusion/gyro_magnetic_fusion.h b/src/sensor/sensor_fusion/gyro_magnetic_fusion.h new file mode 100644 index 0000000..54bf75c --- /dev/null +++ b/src/sensor/sensor_fusion/gyro_magnetic_fusion.h @@ -0,0 +1,33 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __GYRO_MAGNETIC_FUSION_H__ +#define __GYRO_MAGNETIC_FUSION_H__ + +#include + +class gyro_magnetic_fusion : public fusion_base { +public: + gyro_magnetic_fusion(); + ~gyro_magnetic_fusion(); +private: + bool get_orientation(); +}; + +#endif /* __GYRO_MAGNETIC_FUSION_H__ */ diff --git a/src/sensor/sensor_fusion/magnetic_fusion.cpp b/src/sensor/sensor_fusion/magnetic_fusion.cpp new file mode 100644 index 0000000..89050e5 --- /dev/null +++ b/src/sensor/sensor_fusion/magnetic_fusion.cpp @@ -0,0 +1,39 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "magnetic_fusion.h" + +magnetic_fusion::magnetic_fusion() +{ +} + +magnetic_fusion::~magnetic_fusion() +{ +} + +bool magnetic_fusion::get_orientation(void) +{ + //_I("[fusion_sensor] : enable values are %d %d %d", m_enable_accel, m_enable_magnetic, m_enable_magnetic); + if (!m_enable_accel || !m_enable_magnetic) + return false; + + m_orientation_filter.get_device_orientation(&m_accel, &m_magnetic, NULL); + m_timestamp = fmax(m_accel.m_time_stamp, m_magnetic.m_time_stamp); + return true; +} diff --git a/src/sensor/sensor_fusion/magnetic_fusion.h b/src/sensor/sensor_fusion/magnetic_fusion.h new file mode 100644 index 0000000..41758ea --- /dev/null +++ b/src/sensor/sensor_fusion/magnetic_fusion.h @@ -0,0 +1,33 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __MAGNETIC_FUSION_H__ +#define __MAGNETIC_FUSION_H__ + +#include + +class magnetic_fusion: public fusion_base { +public: + magnetic_fusion(); + ~magnetic_fusion(); +private: + bool get_orientation(); +}; + +#endif /* __MAGNETIC_FUSION_H__ */ diff --git a/src/sensor/sensor_fusion/orientation_filter.cpp b/src/sensor/sensor_fusion/orientation_filter.cpp index 7e1cd8d..be41328 100644 --- a/src/sensor/sensor_fusion/orientation_filter.cpp +++ b/src/sensor/sensor_fusion/orientation_filter.cpp @@ -64,8 +64,6 @@ orientation_filter::orientation_filter() m_var_pitch = vec; m_var_azimuth = vec; - m_magnetic_alignment_factor = 1; - m_gyro.m_time_stamp = 0; } @@ -106,7 +104,7 @@ template inline void orientation_filter::orientation_triad_algorithm() { TYPE arr_acc_e[V1x3S] = {0.0, 0.0, 1.0}; - TYPE arr_mag_e[V1x3S] = {0.0, (TYPE) m_magnetic_alignment_factor, 0.0}; + TYPE arr_mag_e[V1x3S] = {0.0, 1.0, 0.0}; vect acc_e(arr_acc_e); vect mag_e(arr_mag_e); diff --git a/src/sensor/sensor_fusion/orientation_filter.h b/src/sensor/sensor_fusion/orientation_filter.h index d55b7c1..eaea224 100644 --- a/src/sensor/sensor_fusion/orientation_filter.h +++ b/src/sensor/sensor_fusion/orientation_filter.h @@ -73,8 +73,6 @@ public: euler_angles m_euler_error; TYPE m_gyro_dt; - int m_magnetic_alignment_factor; - orientation_filter(void); ~orientation_filter(void); diff --git a/src/sensor/sensor_fusion/sensor_data.cpp b/src/sensor/sensor_fusion/sensor_data.cpp index 9f730cc..abd1181 100644 --- a/src/sensor/sensor_fusion/sensor_data.cpp +++ b/src/sensor/sensor_fusion/sensor_data.cpp @@ -117,12 +117,11 @@ quaternion sensor_data2quat(const sensor_data data, const vect -void pre_process_data(sensor_data &data_out, const T *data_in, T *bias, int *sign, int scale) +void pre_process_data(sensor_data &data_out, const T *data_in, int sign, int scale) { - data_out.m_data.m_vec[0] = sign[0] * (data_in[0] - bias[0]) / scale; - data_out.m_data.m_vec[1] = sign[1] * (data_in[1] - bias[1]) / scale; - data_out.m_data.m_vec[2] = sign[2] * (data_in[2] - bias[2]) / scale; + data_out.m_data.m_vec[0] = sign * data_in[0] / scale; + data_out.m_data.m_vec[1] = sign * data_in[1] / scale; + data_out.m_data.m_vec[2] = sign * data_in[2] / scale; } #endif /* _SENSOR_DATA_H_ */ - diff --git a/src/sensor/sensor_fusion/sensor_data.h b/src/sensor/sensor_fusion/sensor_data.h index 6841369..f266760 100644 --- a/src/sensor/sensor_fusion/sensor_data.h +++ b/src/sensor/sensor_fusion/sensor_data.h @@ -50,7 +50,7 @@ public: template friend quaternion sensor_data2quat(const sensor_data data, const vect ref_vec); template friend void pre_process_data(sensor_data &data_out, - const T *data_in, T *bias, int *sign, int scale); + const T *data_in, int sign, int scale); }; #include "sensor_data.cpp" diff --git a/src/sensor/sensor_fusion/test/orientation_sensor.cpp b/src/sensor/sensor_fusion/test/orientation_sensor.cpp index a67627e..25099e2 100644 --- a/src/sensor/sensor_fusion/test/orientation_sensor.cpp +++ b/src/sensor/sensor_fusion/test/orientation_sensor.cpp @@ -45,8 +45,6 @@ void orientation_sensor::get_device_orientation(sensor_data *accel_data, if (magnetic_data != NULL) { pre_process_data(magnetic_data, magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic); normalize(*magnetic_data); - - orien_filter.m_magnetic_alignment_factor = magnetic_alignment_factor; } orien_filter.get_device_orientation(accel_data, gyro_data, magnetic_data); -- 2.7.4 From 377bab9f669bbbd6646b753de155901870652485 Mon Sep 17 00:00:00 2001 From: akhilkedia94 Date: Tue, 16 Aug 2016 17:37:51 +0900 Subject: [PATCH 07/16] [Bugfix] Timestamp was not being passed by refferencce to sensor_fusion Change-Id: Ifb0ff04689880ede5fe565f85931a49f8bc16e6d Signed-off-by: akhilkedia94 --- src/sensor/sensor_fusion/fusion.h | 2 +- src/sensor/sensor_fusion/fusion_base.cpp | 4 ++-- src/sensor/sensor_fusion/fusion_base.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sensor/sensor_fusion/fusion.h b/src/sensor/sensor_fusion/fusion.h index d53f800..6c14439 100644 --- a/src/sensor/sensor_fusion/fusion.h +++ b/src/sensor/sensor_fusion/fusion.h @@ -29,7 +29,7 @@ public: virtual void push_accel(sensor_data_t &data) = 0; virtual void push_gyro(sensor_data_t &data) = 0; virtual void push_mag(sensor_data_t &data) = 0; - virtual bool get_rv(unsigned long long timestamp, float &w, float &x, float &y, float &z) = 0; + virtual bool get_rv(unsigned long long ×tamp, float &w, float &x, float &y, float &z) = 0; }; diff --git a/src/sensor/sensor_fusion/fusion_base.cpp b/src/sensor/sensor_fusion/fusion_base.cpp index 92e02f6..355a551 100644 --- a/src/sensor/sensor_fusion/fusion_base.cpp +++ b/src/sensor/sensor_fusion/fusion_base.cpp @@ -83,7 +83,7 @@ void fusion_base::push_mag(sensor_data_t &data) } -bool fusion_base::get_rv(unsigned long long timestamp, float &x, float &y, float &z, float &w) +bool fusion_base::get_rv(unsigned long long ×tamp, float &x, float &y, float &z, float &w) { if (m_timestamp == 0) return false; @@ -102,4 +102,4 @@ void fusion_base::store_orientation(void) m_z = m_orientation_filter.m_quaternion.m_quat.m_vec[2]; m_w = m_orientation_filter.m_quaternion.m_quat.m_vec[3]; clear(); -} \ No newline at end of file +} diff --git a/src/sensor/sensor_fusion/fusion_base.h b/src/sensor/sensor_fusion/fusion_base.h index 2428712..1479023 100644 --- a/src/sensor/sensor_fusion/fusion_base.h +++ b/src/sensor/sensor_fusion/fusion_base.h @@ -30,7 +30,7 @@ public: virtual void push_accel(sensor_data_t &data); virtual void push_gyro(sensor_data_t &data); virtual void push_mag(sensor_data_t &data); - virtual bool get_rv(unsigned long long timestamp, float &w, float &x, float &y, float &z); + virtual bool get_rv(unsigned long long ×tamp, float &w, float &x, float &y, float &z); protected: -- 2.7.4 From abf07e43a79795872f24a445928a495ae6c8f42e Mon Sep 17 00:00:00 2001 From: akhilkedia94 Date: Tue, 16 Aug 2016 19:29:01 +0900 Subject: [PATCH 08/16] [Bugfix] Order of parameters passed was incorrect - magnetometer was being passed in place of gyro Change-Id: Id65df1004721f55e76169aaee69d2c7af459569b Signed-off-by: akhilkedia94 --- src/sensor/sensor_fusion/magnetic_fusion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensor/sensor_fusion/magnetic_fusion.cpp b/src/sensor/sensor_fusion/magnetic_fusion.cpp index 89050e5..966a247 100644 --- a/src/sensor/sensor_fusion/magnetic_fusion.cpp +++ b/src/sensor/sensor_fusion/magnetic_fusion.cpp @@ -33,7 +33,7 @@ bool magnetic_fusion::get_orientation(void) if (!m_enable_accel || !m_enable_magnetic) return false; - m_orientation_filter.get_device_orientation(&m_accel, &m_magnetic, NULL); + m_orientation_filter.get_device_orientation(&m_accel, NULL, &m_magnetic); m_timestamp = fmax(m_accel.m_time_stamp, m_magnetic.m_time_stamp); return true; } -- 2.7.4 From e15d1ebe23e1c3cafaed280fa51368bb180739fb Mon Sep 17 00:00:00 2001 From: akhilkedia94 Date: Thu, 18 Aug 2016 13:59:32 +0900 Subject: [PATCH 09/16] Moved Fusion Backed from sensor_fusion folder to rotation_vector folder Change-Id: I45f24c4926b35093ddbbb71f0e048d028a5ece07 Signed-off-by: akhilkedia94 --- .../design/data/100ms/gravity/single_roll_throw/accel.txt | 0 .../design/data/100ms/gravity/single_roll_throw/gyro.txt | 0 .../data/100ms/gravity/single_roll_throw/magnetic.txt | 0 .../data/100ms/linear_acceleration/move_x_y_z/accel.txt | 0 .../data/100ms/linear_acceleration/move_x_y_z/gyro.txt | 0 .../data/100ms/linear_acceleration/move_x_y_z/magnetic.txt | 0 .../design/data/100ms/orientation/roll_pitch_yaw/accel.txt | 0 .../design/data/100ms/orientation/roll_pitch_yaw/gyro.txt | 0 .../data/100ms/orientation/roll_pitch_yaw/magnetic.txt | 0 .../design/data/25ms/pedo/Climb_stairs_down/In_hand/accel | 0 .../design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro | 0 .../data/25ms/pedo/Climb_stairs_down/In_hand/magnetic | 0 .../data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel | 0 .../data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro | 0 .../data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic | 0 .../data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel | 0 .../data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro | 0 .../data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic | 0 .../data/25ms/pedo/Climb_stairs_down/While_talking/accel | 0 .../data/25ms/pedo/Climb_stairs_down/While_talking/gyro | 0 .../data/25ms/pedo/Climb_stairs_down/While_talking/magnetic | 0 .../design/data/25ms/pedo/Climb_stairs_up/In_hand/accel | 0 .../design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro | 0 .../design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic | 0 .../design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel | 0 .../design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro | 0 .../data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic | 0 .../data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel | 0 .../design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro | 0 .../data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic | 0 .../data/25ms/pedo/Climb_stairs_up/While_talking/accel | 0 .../data/25ms/pedo/Climb_stairs_up/While_talking/gyro | 0 .../data/25ms/pedo/Climb_stairs_up/While_talking/magnetic | 0 .../design/data/25ms/pedo/Walk_fast/In_hand/accel | 0 .../design/data/25ms/pedo/Walk_fast/In_hand/gyro | 0 .../design/data/25ms/pedo/Walk_fast/In_hand/magnetic | 0 .../design/data/25ms/pedo/Walk_fast/Pant_pocket/accel | 0 .../design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro | 0 .../design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic | 0 .../design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel | 0 .../design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro | 0 .../design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic | 0 .../design/data/25ms/pedo/Walk_fast/While_talking/accel | 0 .../design/data/25ms/pedo/Walk_fast/While_talking/gyro | 0 .../design/data/25ms/pedo/Walk_fast/While_talking/magnetic | 0 .../design/data/25ms/pedo/Walk_slow/In_hand/accel | 0 .../design/data/25ms/pedo/Walk_slow/In_hand/gyro | 0 .../design/data/25ms/pedo/Walk_slow/In_hand/magnetic | 0 .../design/data/25ms/pedo/Walk_slow/Pant_pocket/accel | 0 .../design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro | 0 .../design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic | 0 .../design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel | 0 .../design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro | 0 .../design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic | 0 .../design/data/25ms/pedo/Walk_slow/While_talking/accel | 0 .../design/data/25ms/pedo/Walk_slow/While_talking/gyro | 0 .../design/data/25ms/pedo/Walk_slow/While_talking/magnetic | 0 .../block_diagram_gravity_and_linear_acceleration.png | Bin .../diagram/block_diagram_orientation_estimation.png | Bin .../design/documentation/diagram/device_orientation.png | Bin .../design/documentation/diagram/kalman_filter_stages.png | Bin .../documentation/diagram/orientation_effect_on_gravity.png | Bin .../diagram/projection_diagram_gravity_computation.png | Bin .../design/documentation/equation/equation_1.png | Bin .../design/documentation/equation/equation_10.png | Bin .../design/documentation/equation/equation_11.png | Bin .../design/documentation/equation/equation_12.png | Bin .../design/documentation/equation/equation_13.png | Bin .../design/documentation/equation/equation_13_updated.png | Bin .../design/documentation/equation/equation_14.png | Bin .../design/documentation/equation/equation_15.png | Bin .../design/documentation/equation/equation_16.png | Bin .../design/documentation/equation/equation_17.png | Bin .../design/documentation/equation/equation_18.png | Bin .../design/documentation/equation/equation_19.png | Bin .../design/documentation/equation/equation_2.png | Bin .../design/documentation/equation/equation_20.png | Bin .../design/documentation/equation/equation_21.png | Bin .../design/documentation/equation/equation_22.png | Bin .../design/documentation/equation/equation_23.png | Bin .../design/documentation/equation/equation_24.png | Bin .../design/documentation/equation/equation_25.png | Bin .../design/documentation/equation/equation_26.png | Bin .../design/documentation/equation/equation_27.png | Bin .../design/documentation/equation/equation_28.png | Bin .../design/documentation/equation/equation_29.png | Bin .../design/documentation/equation/equation_3.png | Bin .../design/documentation/equation/equation_30.png | Bin .../design/documentation/equation/equation_31.png | Bin .../design/documentation/equation/equation_32.png | Bin .../design/documentation/equation/equation_33.png | Bin .../design/documentation/equation/equation_34.png | Bin .../design/documentation/equation/equation_35.png | Bin .../design/documentation/equation/equation_36.png | Bin .../design/documentation/equation/equation_37.png | Bin .../design/documentation/equation/equation_38.png | Bin .../design/documentation/equation/equation_39.png | Bin .../design/documentation/equation/equation_4.png | Bin .../design/documentation/equation/equation_40.png | Bin .../design/documentation/equation/equation_5.png | Bin .../design/documentation/equation/equation_6.png | Bin .../design/documentation/equation/equation_7.png | Bin .../design/documentation/equation/equation_8.png | Bin .../design/documentation/equation/equation_9.png | Bin .../design/documentation/hardware_fusion_sensor.html | 0 .../design/documentation/sensor_fusion.htm | 0 .../design/lib/axis_rot2quat.m | 0 .../design/lib/estimate_gaming_rv.m | 0 .../design/lib/estimate_geomagnetic_rv.m | 0 .../design/lib/estimate_gravity.m | 0 .../design/lib/estimate_linear_acceleration.m | 0 .../design/lib/estimate_orientation.m | 0 .../design/lib/euler2quat.m | 0 .../design/lib/quat2euler.m | 0 .../design/lib/quat2rot_mat.m | 0 .../design/lib/quat_prod.m | 0 .../design/lib/rot_mat2quat.m | 0 .../design/lib/sf_pedometer.m | 0 src/sensor/{sensor_fusion => rotation_vector}/design/readme | 0 .../design/sf_gaming_rv.m | 0 .../design/sf_geomagnetic_rv.m | 0 .../{sensor_fusion => rotation_vector}/design/sf_gravity.m | 0 .../design/sf_linear_acceleration.m | 0 .../design/sf_orientation.m | 0 src/sensor/{sensor_fusion => rotation_vector}/fusion.h | 0 .../{sensor_fusion => rotation_vector}/fusion_base.cpp | 0 src/sensor/{sensor_fusion => rotation_vector}/fusion_base.h | 0 .../fusion_utils}/euler_angles.cpp | 0 .../fusion_utils}/euler_angles.h | 0 .../fusion_utils}/matrix.cpp | 0 .../fusion_utils}/matrix.h | 0 .../fusion_utils}/orientation_filter.cpp | 0 .../fusion_utils}/orientation_filter.h | 0 .../fusion_utils}/quaternion.cpp | 0 .../fusion_utils}/quaternion.h | 0 .../fusion_utils}/rotation_matrix.cpp | 0 .../fusion_utils}/rotation_matrix.h | 0 .../fusion_utils}/sensor_data.cpp | 0 .../fusion_utils}/sensor_data.h | 0 .../fusion_utils}/vector.cpp | 0 .../fusion_utils}/vector.h | 0 .../{sensor_fusion => rotation_vector}/gyro_fusion.cpp | 0 src/sensor/{sensor_fusion => rotation_vector}/gyro_fusion.h | 0 .../gyro_magnetic_fusion.cpp | 0 .../gyro_magnetic_fusion.h | 0 .../{sensor_fusion => rotation_vector}/magnetic_fusion.cpp | 0 .../{sensor_fusion => rotation_vector}/magnetic_fusion.h | 0 .../test/gravity_sensor.cpp | 0 .../test/gravity_sensor.h | 0 .../test/linear_acceleration_sensor.cpp | 0 .../test/linear_acceleration_sensor.h | 0 .../test/orientation_sensor.cpp | 0 .../test/orientation_sensor.h | 0 .../test_projects/euler_angles_test/euler_angles_main.cpp | 0 .../gravity_sensor_test/gravity_sensor_main.cpp | 0 .../linear_acceleration_sensor_main.cpp | 0 .../test/test_projects/matrix_test/matrix_main.cpp | 0 .../orientation_sensor_test/orientation_sensor_main.cpp | 0 .../test/test_projects/quaternion_test/quaternion_main.cpp | 0 .../rotation_matrix_test/rotation_matrix_main.cpp | 0 .../test_projects/sensor_data_test/sensor_data_main.cpp | 0 .../test/test_projects/vector_test/vector_main.cpp | 0 162 files changed, 0 insertions(+), 0 deletions(-) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/100ms/gravity/single_roll_throw/accel.txt (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/100ms/gravity/single_roll_throw/gyro.txt (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/100ms/gravity/single_roll_throw/magnetic.txt (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/100ms/linear_acceleration/move_x_y_z/accel.txt (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/100ms/linear_acceleration/move_x_y_z/gyro.txt (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/100ms/linear_acceleration/move_x_y_z/magnetic.txt (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/100ms/orientation/roll_pitch_yaw/accel.txt (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/100ms/orientation/roll_pitch_yaw/gyro.txt (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/100ms/orientation/roll_pitch_yaw/magnetic.txt (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/In_hand/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/In_hand/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/While_talking/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/While_talking/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_down/While_talking/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/In_hand/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/While_talking/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/While_talking/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Climb_stairs_up/While_talking/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/In_hand/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/In_hand/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/In_hand/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/Pant_pocket/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/While_talking/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/While_talking/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_fast/While_talking/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/In_hand/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/In_hand/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/In_hand/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/Pant_pocket/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/While_talking/accel (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/While_talking/gyro (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/data/25ms/pedo/Walk_slow/While_talking/magnetic (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/diagram/block_diagram_gravity_and_linear_acceleration.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/diagram/block_diagram_orientation_estimation.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/diagram/device_orientation.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/diagram/kalman_filter_stages.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/diagram/orientation_effect_on_gravity.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/diagram/projection_diagram_gravity_computation.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_1.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_10.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_11.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_12.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_13.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_13_updated.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_14.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_15.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_16.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_17.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_18.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_19.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_2.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_20.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_21.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_22.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_23.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_24.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_25.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_26.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_27.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_28.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_29.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_3.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_30.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_31.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_32.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_33.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_34.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_35.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_36.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_37.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_38.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_39.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_4.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_40.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_5.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_6.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_7.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_8.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/equation/equation_9.png (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/hardware_fusion_sensor.html (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/documentation/sensor_fusion.htm (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/axis_rot2quat.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/estimate_gaming_rv.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/estimate_geomagnetic_rv.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/estimate_gravity.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/estimate_linear_acceleration.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/estimate_orientation.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/euler2quat.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/quat2euler.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/quat2rot_mat.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/quat_prod.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/rot_mat2quat.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/lib/sf_pedometer.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/readme (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/sf_gaming_rv.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/sf_geomagnetic_rv.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/sf_gravity.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/sf_linear_acceleration.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/design/sf_orientation.m (100%) rename src/sensor/{sensor_fusion => rotation_vector}/fusion.h (100%) rename src/sensor/{sensor_fusion => rotation_vector}/fusion_base.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/fusion_base.h (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/euler_angles.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/euler_angles.h (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/matrix.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/matrix.h (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/orientation_filter.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/orientation_filter.h (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/quaternion.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/quaternion.h (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/rotation_matrix.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/rotation_matrix.h (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/sensor_data.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/sensor_data.h (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/vector.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector/fusion_utils}/vector.h (100%) rename src/sensor/{sensor_fusion => rotation_vector}/gyro_fusion.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/gyro_fusion.h (100%) rename src/sensor/{sensor_fusion => rotation_vector}/gyro_magnetic_fusion.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/gyro_magnetic_fusion.h (100%) rename src/sensor/{sensor_fusion => rotation_vector}/magnetic_fusion.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/magnetic_fusion.h (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/gravity_sensor.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/gravity_sensor.h (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/linear_acceleration_sensor.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/linear_acceleration_sensor.h (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/orientation_sensor.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/orientation_sensor.h (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/test_projects/euler_angles_test/euler_angles_main.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/test_projects/matrix_test/matrix_main.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/test_projects/quaternion_test/quaternion_main.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/test_projects/rotation_matrix_test/rotation_matrix_main.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/test_projects/sensor_data_test/sensor_data_main.cpp (100%) rename src/sensor/{sensor_fusion => rotation_vector}/test/test_projects/vector_test/vector_main.cpp (100%) diff --git a/src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/accel.txt b/src/sensor/rotation_vector/design/data/100ms/gravity/single_roll_throw/accel.txt similarity index 100% rename from src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/accel.txt rename to src/sensor/rotation_vector/design/data/100ms/gravity/single_roll_throw/accel.txt diff --git a/src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/gyro.txt b/src/sensor/rotation_vector/design/data/100ms/gravity/single_roll_throw/gyro.txt similarity index 100% rename from src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/gyro.txt rename to src/sensor/rotation_vector/design/data/100ms/gravity/single_roll_throw/gyro.txt diff --git a/src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/magnetic.txt b/src/sensor/rotation_vector/design/data/100ms/gravity/single_roll_throw/magnetic.txt similarity index 100% rename from src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/magnetic.txt rename to src/sensor/rotation_vector/design/data/100ms/gravity/single_roll_throw/magnetic.txt diff --git a/src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/accel.txt b/src/sensor/rotation_vector/design/data/100ms/linear_acceleration/move_x_y_z/accel.txt similarity index 100% rename from src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/accel.txt rename to src/sensor/rotation_vector/design/data/100ms/linear_acceleration/move_x_y_z/accel.txt diff --git a/src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/gyro.txt b/src/sensor/rotation_vector/design/data/100ms/linear_acceleration/move_x_y_z/gyro.txt similarity index 100% rename from src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/gyro.txt rename to src/sensor/rotation_vector/design/data/100ms/linear_acceleration/move_x_y_z/gyro.txt diff --git a/src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/magnetic.txt b/src/sensor/rotation_vector/design/data/100ms/linear_acceleration/move_x_y_z/magnetic.txt similarity index 100% rename from src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/magnetic.txt rename to src/sensor/rotation_vector/design/data/100ms/linear_acceleration/move_x_y_z/magnetic.txt diff --git a/src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/accel.txt b/src/sensor/rotation_vector/design/data/100ms/orientation/roll_pitch_yaw/accel.txt similarity index 100% rename from src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/accel.txt rename to src/sensor/rotation_vector/design/data/100ms/orientation/roll_pitch_yaw/accel.txt diff --git a/src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/gyro.txt b/src/sensor/rotation_vector/design/data/100ms/orientation/roll_pitch_yaw/gyro.txt similarity index 100% rename from src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/gyro.txt rename to src/sensor/rotation_vector/design/data/100ms/orientation/roll_pitch_yaw/gyro.txt diff --git a/src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/magnetic.txt b/src/sensor/rotation_vector/design/data/100ms/orientation/roll_pitch_yaw/magnetic.txt similarity index 100% rename from src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/magnetic.txt rename to src/sensor/rotation_vector/design/data/100ms/orientation/roll_pitch_yaw/magnetic.txt diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/In_hand/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/In_hand/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/In_hand/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/In_hand/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/While_talking/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/While_talking/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/While_talking/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/While_talking/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/While_talking/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_down/While_talking/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/In_hand/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/In_hand/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/While_talking/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/While_talking/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/While_talking/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/While_talking/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/While_talking/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Climb_stairs_up/While_talking/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/In_hand/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/In_hand/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/In_hand/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/In_hand/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/In_hand/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/In_hand/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Pant_pocket/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Pant_pocket/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/While_talking/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/While_talking/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/While_talking/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/While_talking/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/While_talking/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_fast/While_talking/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/In_hand/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/In_hand/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/In_hand/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/In_hand/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/In_hand/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/In_hand/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Pant_pocket/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Pant_pocket/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/accel b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/While_talking/accel similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/accel rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/While_talking/accel diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/gyro b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/While_talking/gyro similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/gyro rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/While_talking/gyro diff --git a/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/magnetic b/src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/While_talking/magnetic similarity index 100% rename from src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/magnetic rename to src/sensor/rotation_vector/design/data/25ms/pedo/Walk_slow/While_talking/magnetic diff --git a/src/sensor/sensor_fusion/design/documentation/diagram/block_diagram_gravity_and_linear_acceleration.png b/src/sensor/rotation_vector/design/documentation/diagram/block_diagram_gravity_and_linear_acceleration.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/diagram/block_diagram_gravity_and_linear_acceleration.png rename to src/sensor/rotation_vector/design/documentation/diagram/block_diagram_gravity_and_linear_acceleration.png diff --git a/src/sensor/sensor_fusion/design/documentation/diagram/block_diagram_orientation_estimation.png b/src/sensor/rotation_vector/design/documentation/diagram/block_diagram_orientation_estimation.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/diagram/block_diagram_orientation_estimation.png rename to src/sensor/rotation_vector/design/documentation/diagram/block_diagram_orientation_estimation.png diff --git a/src/sensor/sensor_fusion/design/documentation/diagram/device_orientation.png b/src/sensor/rotation_vector/design/documentation/diagram/device_orientation.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/diagram/device_orientation.png rename to src/sensor/rotation_vector/design/documentation/diagram/device_orientation.png diff --git a/src/sensor/sensor_fusion/design/documentation/diagram/kalman_filter_stages.png b/src/sensor/rotation_vector/design/documentation/diagram/kalman_filter_stages.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/diagram/kalman_filter_stages.png rename to src/sensor/rotation_vector/design/documentation/diagram/kalman_filter_stages.png diff --git a/src/sensor/sensor_fusion/design/documentation/diagram/orientation_effect_on_gravity.png b/src/sensor/rotation_vector/design/documentation/diagram/orientation_effect_on_gravity.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/diagram/orientation_effect_on_gravity.png rename to src/sensor/rotation_vector/design/documentation/diagram/orientation_effect_on_gravity.png diff --git a/src/sensor/sensor_fusion/design/documentation/diagram/projection_diagram_gravity_computation.png b/src/sensor/rotation_vector/design/documentation/diagram/projection_diagram_gravity_computation.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/diagram/projection_diagram_gravity_computation.png rename to src/sensor/rotation_vector/design/documentation/diagram/projection_diagram_gravity_computation.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_1.png b/src/sensor/rotation_vector/design/documentation/equation/equation_1.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_1.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_1.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_10.png b/src/sensor/rotation_vector/design/documentation/equation/equation_10.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_10.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_10.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_11.png b/src/sensor/rotation_vector/design/documentation/equation/equation_11.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_11.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_11.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_12.png b/src/sensor/rotation_vector/design/documentation/equation/equation_12.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_12.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_12.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_13.png b/src/sensor/rotation_vector/design/documentation/equation/equation_13.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_13.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_13.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_13_updated.png b/src/sensor/rotation_vector/design/documentation/equation/equation_13_updated.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_13_updated.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_13_updated.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_14.png b/src/sensor/rotation_vector/design/documentation/equation/equation_14.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_14.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_14.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_15.png b/src/sensor/rotation_vector/design/documentation/equation/equation_15.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_15.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_15.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_16.png b/src/sensor/rotation_vector/design/documentation/equation/equation_16.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_16.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_16.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_17.png b/src/sensor/rotation_vector/design/documentation/equation/equation_17.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_17.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_17.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_18.png b/src/sensor/rotation_vector/design/documentation/equation/equation_18.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_18.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_18.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_19.png b/src/sensor/rotation_vector/design/documentation/equation/equation_19.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_19.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_19.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_2.png b/src/sensor/rotation_vector/design/documentation/equation/equation_2.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_2.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_2.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_20.png b/src/sensor/rotation_vector/design/documentation/equation/equation_20.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_20.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_20.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_21.png b/src/sensor/rotation_vector/design/documentation/equation/equation_21.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_21.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_21.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_22.png b/src/sensor/rotation_vector/design/documentation/equation/equation_22.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_22.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_22.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_23.png b/src/sensor/rotation_vector/design/documentation/equation/equation_23.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_23.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_23.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_24.png b/src/sensor/rotation_vector/design/documentation/equation/equation_24.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_24.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_24.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_25.png b/src/sensor/rotation_vector/design/documentation/equation/equation_25.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_25.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_25.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_26.png b/src/sensor/rotation_vector/design/documentation/equation/equation_26.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_26.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_26.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_27.png b/src/sensor/rotation_vector/design/documentation/equation/equation_27.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_27.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_27.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_28.png b/src/sensor/rotation_vector/design/documentation/equation/equation_28.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_28.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_28.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_29.png b/src/sensor/rotation_vector/design/documentation/equation/equation_29.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_29.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_29.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_3.png b/src/sensor/rotation_vector/design/documentation/equation/equation_3.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_3.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_3.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_30.png b/src/sensor/rotation_vector/design/documentation/equation/equation_30.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_30.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_30.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_31.png b/src/sensor/rotation_vector/design/documentation/equation/equation_31.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_31.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_31.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_32.png b/src/sensor/rotation_vector/design/documentation/equation/equation_32.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_32.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_32.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_33.png b/src/sensor/rotation_vector/design/documentation/equation/equation_33.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_33.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_33.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_34.png b/src/sensor/rotation_vector/design/documentation/equation/equation_34.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_34.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_34.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_35.png b/src/sensor/rotation_vector/design/documentation/equation/equation_35.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_35.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_35.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_36.png b/src/sensor/rotation_vector/design/documentation/equation/equation_36.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_36.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_36.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_37.png b/src/sensor/rotation_vector/design/documentation/equation/equation_37.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_37.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_37.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_38.png b/src/sensor/rotation_vector/design/documentation/equation/equation_38.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_38.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_38.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_39.png b/src/sensor/rotation_vector/design/documentation/equation/equation_39.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_39.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_39.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_4.png b/src/sensor/rotation_vector/design/documentation/equation/equation_4.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_4.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_4.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_40.png b/src/sensor/rotation_vector/design/documentation/equation/equation_40.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_40.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_40.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_5.png b/src/sensor/rotation_vector/design/documentation/equation/equation_5.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_5.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_5.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_6.png b/src/sensor/rotation_vector/design/documentation/equation/equation_6.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_6.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_6.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_7.png b/src/sensor/rotation_vector/design/documentation/equation/equation_7.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_7.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_7.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_8.png b/src/sensor/rotation_vector/design/documentation/equation/equation_8.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_8.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_8.png diff --git a/src/sensor/sensor_fusion/design/documentation/equation/equation_9.png b/src/sensor/rotation_vector/design/documentation/equation/equation_9.png similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/equation/equation_9.png rename to src/sensor/rotation_vector/design/documentation/equation/equation_9.png diff --git a/src/sensor/sensor_fusion/design/documentation/hardware_fusion_sensor.html b/src/sensor/rotation_vector/design/documentation/hardware_fusion_sensor.html similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/hardware_fusion_sensor.html rename to src/sensor/rotation_vector/design/documentation/hardware_fusion_sensor.html diff --git a/src/sensor/sensor_fusion/design/documentation/sensor_fusion.htm b/src/sensor/rotation_vector/design/documentation/sensor_fusion.htm similarity index 100% rename from src/sensor/sensor_fusion/design/documentation/sensor_fusion.htm rename to src/sensor/rotation_vector/design/documentation/sensor_fusion.htm diff --git a/src/sensor/sensor_fusion/design/lib/axis_rot2quat.m b/src/sensor/rotation_vector/design/lib/axis_rot2quat.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/axis_rot2quat.m rename to src/sensor/rotation_vector/design/lib/axis_rot2quat.m diff --git a/src/sensor/sensor_fusion/design/lib/estimate_gaming_rv.m b/src/sensor/rotation_vector/design/lib/estimate_gaming_rv.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/estimate_gaming_rv.m rename to src/sensor/rotation_vector/design/lib/estimate_gaming_rv.m diff --git a/src/sensor/sensor_fusion/design/lib/estimate_geomagnetic_rv.m b/src/sensor/rotation_vector/design/lib/estimate_geomagnetic_rv.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/estimate_geomagnetic_rv.m rename to src/sensor/rotation_vector/design/lib/estimate_geomagnetic_rv.m diff --git a/src/sensor/sensor_fusion/design/lib/estimate_gravity.m b/src/sensor/rotation_vector/design/lib/estimate_gravity.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/estimate_gravity.m rename to src/sensor/rotation_vector/design/lib/estimate_gravity.m diff --git a/src/sensor/sensor_fusion/design/lib/estimate_linear_acceleration.m b/src/sensor/rotation_vector/design/lib/estimate_linear_acceleration.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/estimate_linear_acceleration.m rename to src/sensor/rotation_vector/design/lib/estimate_linear_acceleration.m diff --git a/src/sensor/sensor_fusion/design/lib/estimate_orientation.m b/src/sensor/rotation_vector/design/lib/estimate_orientation.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/estimate_orientation.m rename to src/sensor/rotation_vector/design/lib/estimate_orientation.m diff --git a/src/sensor/sensor_fusion/design/lib/euler2quat.m b/src/sensor/rotation_vector/design/lib/euler2quat.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/euler2quat.m rename to src/sensor/rotation_vector/design/lib/euler2quat.m diff --git a/src/sensor/sensor_fusion/design/lib/quat2euler.m b/src/sensor/rotation_vector/design/lib/quat2euler.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/quat2euler.m rename to src/sensor/rotation_vector/design/lib/quat2euler.m diff --git a/src/sensor/sensor_fusion/design/lib/quat2rot_mat.m b/src/sensor/rotation_vector/design/lib/quat2rot_mat.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/quat2rot_mat.m rename to src/sensor/rotation_vector/design/lib/quat2rot_mat.m diff --git a/src/sensor/sensor_fusion/design/lib/quat_prod.m b/src/sensor/rotation_vector/design/lib/quat_prod.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/quat_prod.m rename to src/sensor/rotation_vector/design/lib/quat_prod.m diff --git a/src/sensor/sensor_fusion/design/lib/rot_mat2quat.m b/src/sensor/rotation_vector/design/lib/rot_mat2quat.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/rot_mat2quat.m rename to src/sensor/rotation_vector/design/lib/rot_mat2quat.m diff --git a/src/sensor/sensor_fusion/design/lib/sf_pedometer.m b/src/sensor/rotation_vector/design/lib/sf_pedometer.m similarity index 100% rename from src/sensor/sensor_fusion/design/lib/sf_pedometer.m rename to src/sensor/rotation_vector/design/lib/sf_pedometer.m diff --git a/src/sensor/sensor_fusion/design/readme b/src/sensor/rotation_vector/design/readme similarity index 100% rename from src/sensor/sensor_fusion/design/readme rename to src/sensor/rotation_vector/design/readme diff --git a/src/sensor/sensor_fusion/design/sf_gaming_rv.m b/src/sensor/rotation_vector/design/sf_gaming_rv.m similarity index 100% rename from src/sensor/sensor_fusion/design/sf_gaming_rv.m rename to src/sensor/rotation_vector/design/sf_gaming_rv.m diff --git a/src/sensor/sensor_fusion/design/sf_geomagnetic_rv.m b/src/sensor/rotation_vector/design/sf_geomagnetic_rv.m similarity index 100% rename from src/sensor/sensor_fusion/design/sf_geomagnetic_rv.m rename to src/sensor/rotation_vector/design/sf_geomagnetic_rv.m diff --git a/src/sensor/sensor_fusion/design/sf_gravity.m b/src/sensor/rotation_vector/design/sf_gravity.m similarity index 100% rename from src/sensor/sensor_fusion/design/sf_gravity.m rename to src/sensor/rotation_vector/design/sf_gravity.m diff --git a/src/sensor/sensor_fusion/design/sf_linear_acceleration.m b/src/sensor/rotation_vector/design/sf_linear_acceleration.m similarity index 100% rename from src/sensor/sensor_fusion/design/sf_linear_acceleration.m rename to src/sensor/rotation_vector/design/sf_linear_acceleration.m diff --git a/src/sensor/sensor_fusion/design/sf_orientation.m b/src/sensor/rotation_vector/design/sf_orientation.m similarity index 100% rename from src/sensor/sensor_fusion/design/sf_orientation.m rename to src/sensor/rotation_vector/design/sf_orientation.m diff --git a/src/sensor/sensor_fusion/fusion.h b/src/sensor/rotation_vector/fusion.h similarity index 100% rename from src/sensor/sensor_fusion/fusion.h rename to src/sensor/rotation_vector/fusion.h diff --git a/src/sensor/sensor_fusion/fusion_base.cpp b/src/sensor/rotation_vector/fusion_base.cpp similarity index 100% rename from src/sensor/sensor_fusion/fusion_base.cpp rename to src/sensor/rotation_vector/fusion_base.cpp diff --git a/src/sensor/sensor_fusion/fusion_base.h b/src/sensor/rotation_vector/fusion_base.h similarity index 100% rename from src/sensor/sensor_fusion/fusion_base.h rename to src/sensor/rotation_vector/fusion_base.h diff --git a/src/sensor/sensor_fusion/euler_angles.cpp b/src/sensor/rotation_vector/fusion_utils/euler_angles.cpp similarity index 100% rename from src/sensor/sensor_fusion/euler_angles.cpp rename to src/sensor/rotation_vector/fusion_utils/euler_angles.cpp diff --git a/src/sensor/sensor_fusion/euler_angles.h b/src/sensor/rotation_vector/fusion_utils/euler_angles.h similarity index 100% rename from src/sensor/sensor_fusion/euler_angles.h rename to src/sensor/rotation_vector/fusion_utils/euler_angles.h diff --git a/src/sensor/sensor_fusion/matrix.cpp b/src/sensor/rotation_vector/fusion_utils/matrix.cpp similarity index 100% rename from src/sensor/sensor_fusion/matrix.cpp rename to src/sensor/rotation_vector/fusion_utils/matrix.cpp diff --git a/src/sensor/sensor_fusion/matrix.h b/src/sensor/rotation_vector/fusion_utils/matrix.h similarity index 100% rename from src/sensor/sensor_fusion/matrix.h rename to src/sensor/rotation_vector/fusion_utils/matrix.h diff --git a/src/sensor/sensor_fusion/orientation_filter.cpp b/src/sensor/rotation_vector/fusion_utils/orientation_filter.cpp similarity index 100% rename from src/sensor/sensor_fusion/orientation_filter.cpp rename to src/sensor/rotation_vector/fusion_utils/orientation_filter.cpp diff --git a/src/sensor/sensor_fusion/orientation_filter.h b/src/sensor/rotation_vector/fusion_utils/orientation_filter.h similarity index 100% rename from src/sensor/sensor_fusion/orientation_filter.h rename to src/sensor/rotation_vector/fusion_utils/orientation_filter.h diff --git a/src/sensor/sensor_fusion/quaternion.cpp b/src/sensor/rotation_vector/fusion_utils/quaternion.cpp similarity index 100% rename from src/sensor/sensor_fusion/quaternion.cpp rename to src/sensor/rotation_vector/fusion_utils/quaternion.cpp diff --git a/src/sensor/sensor_fusion/quaternion.h b/src/sensor/rotation_vector/fusion_utils/quaternion.h similarity index 100% rename from src/sensor/sensor_fusion/quaternion.h rename to src/sensor/rotation_vector/fusion_utils/quaternion.h diff --git a/src/sensor/sensor_fusion/rotation_matrix.cpp b/src/sensor/rotation_vector/fusion_utils/rotation_matrix.cpp similarity index 100% rename from src/sensor/sensor_fusion/rotation_matrix.cpp rename to src/sensor/rotation_vector/fusion_utils/rotation_matrix.cpp diff --git a/src/sensor/sensor_fusion/rotation_matrix.h b/src/sensor/rotation_vector/fusion_utils/rotation_matrix.h similarity index 100% rename from src/sensor/sensor_fusion/rotation_matrix.h rename to src/sensor/rotation_vector/fusion_utils/rotation_matrix.h diff --git a/src/sensor/sensor_fusion/sensor_data.cpp b/src/sensor/rotation_vector/fusion_utils/sensor_data.cpp similarity index 100% rename from src/sensor/sensor_fusion/sensor_data.cpp rename to src/sensor/rotation_vector/fusion_utils/sensor_data.cpp diff --git a/src/sensor/sensor_fusion/sensor_data.h b/src/sensor/rotation_vector/fusion_utils/sensor_data.h similarity index 100% rename from src/sensor/sensor_fusion/sensor_data.h rename to src/sensor/rotation_vector/fusion_utils/sensor_data.h diff --git a/src/sensor/sensor_fusion/vector.cpp b/src/sensor/rotation_vector/fusion_utils/vector.cpp similarity index 100% rename from src/sensor/sensor_fusion/vector.cpp rename to src/sensor/rotation_vector/fusion_utils/vector.cpp diff --git a/src/sensor/sensor_fusion/vector.h b/src/sensor/rotation_vector/fusion_utils/vector.h similarity index 100% rename from src/sensor/sensor_fusion/vector.h rename to src/sensor/rotation_vector/fusion_utils/vector.h diff --git a/src/sensor/sensor_fusion/gyro_fusion.cpp b/src/sensor/rotation_vector/gyro_fusion.cpp similarity index 100% rename from src/sensor/sensor_fusion/gyro_fusion.cpp rename to src/sensor/rotation_vector/gyro_fusion.cpp diff --git a/src/sensor/sensor_fusion/gyro_fusion.h b/src/sensor/rotation_vector/gyro_fusion.h similarity index 100% rename from src/sensor/sensor_fusion/gyro_fusion.h rename to src/sensor/rotation_vector/gyro_fusion.h diff --git a/src/sensor/sensor_fusion/gyro_magnetic_fusion.cpp b/src/sensor/rotation_vector/gyro_magnetic_fusion.cpp similarity index 100% rename from src/sensor/sensor_fusion/gyro_magnetic_fusion.cpp rename to src/sensor/rotation_vector/gyro_magnetic_fusion.cpp diff --git a/src/sensor/sensor_fusion/gyro_magnetic_fusion.h b/src/sensor/rotation_vector/gyro_magnetic_fusion.h similarity index 100% rename from src/sensor/sensor_fusion/gyro_magnetic_fusion.h rename to src/sensor/rotation_vector/gyro_magnetic_fusion.h diff --git a/src/sensor/sensor_fusion/magnetic_fusion.cpp b/src/sensor/rotation_vector/magnetic_fusion.cpp similarity index 100% rename from src/sensor/sensor_fusion/magnetic_fusion.cpp rename to src/sensor/rotation_vector/magnetic_fusion.cpp diff --git a/src/sensor/sensor_fusion/magnetic_fusion.h b/src/sensor/rotation_vector/magnetic_fusion.h similarity index 100% rename from src/sensor/sensor_fusion/magnetic_fusion.h rename to src/sensor/rotation_vector/magnetic_fusion.h diff --git a/src/sensor/sensor_fusion/test/gravity_sensor.cpp b/src/sensor/rotation_vector/test/gravity_sensor.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/gravity_sensor.cpp rename to src/sensor/rotation_vector/test/gravity_sensor.cpp diff --git a/src/sensor/sensor_fusion/test/gravity_sensor.h b/src/sensor/rotation_vector/test/gravity_sensor.h similarity index 100% rename from src/sensor/sensor_fusion/test/gravity_sensor.h rename to src/sensor/rotation_vector/test/gravity_sensor.h diff --git a/src/sensor/sensor_fusion/test/linear_acceleration_sensor.cpp b/src/sensor/rotation_vector/test/linear_acceleration_sensor.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/linear_acceleration_sensor.cpp rename to src/sensor/rotation_vector/test/linear_acceleration_sensor.cpp diff --git a/src/sensor/sensor_fusion/test/linear_acceleration_sensor.h b/src/sensor/rotation_vector/test/linear_acceleration_sensor.h similarity index 100% rename from src/sensor/sensor_fusion/test/linear_acceleration_sensor.h rename to src/sensor/rotation_vector/test/linear_acceleration_sensor.h diff --git a/src/sensor/sensor_fusion/test/orientation_sensor.cpp b/src/sensor/rotation_vector/test/orientation_sensor.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/orientation_sensor.cpp rename to src/sensor/rotation_vector/test/orientation_sensor.cpp diff --git a/src/sensor/sensor_fusion/test/orientation_sensor.h b/src/sensor/rotation_vector/test/orientation_sensor.h similarity index 100% rename from src/sensor/sensor_fusion/test/orientation_sensor.h rename to src/sensor/rotation_vector/test/orientation_sensor.h diff --git a/src/sensor/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp b/src/sensor/rotation_vector/test/test_projects/euler_angles_test/euler_angles_main.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp rename to src/sensor/rotation_vector/test/test_projects/euler_angles_test/euler_angles_main.cpp diff --git a/src/sensor/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp b/src/sensor/rotation_vector/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp rename to src/sensor/rotation_vector/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp diff --git a/src/sensor/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp b/src/sensor/rotation_vector/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp rename to src/sensor/rotation_vector/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp diff --git a/src/sensor/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp b/src/sensor/rotation_vector/test/test_projects/matrix_test/matrix_main.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp rename to src/sensor/rotation_vector/test/test_projects/matrix_test/matrix_main.cpp diff --git a/src/sensor/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp b/src/sensor/rotation_vector/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp rename to src/sensor/rotation_vector/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp diff --git a/src/sensor/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp b/src/sensor/rotation_vector/test/test_projects/quaternion_test/quaternion_main.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp rename to src/sensor/rotation_vector/test/test_projects/quaternion_test/quaternion_main.cpp diff --git a/src/sensor/sensor_fusion/test/test_projects/rotation_matrix_test/rotation_matrix_main.cpp b/src/sensor/rotation_vector/test/test_projects/rotation_matrix_test/rotation_matrix_main.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/test_projects/rotation_matrix_test/rotation_matrix_main.cpp rename to src/sensor/rotation_vector/test/test_projects/rotation_matrix_test/rotation_matrix_main.cpp diff --git a/src/sensor/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp b/src/sensor/rotation_vector/test/test_projects/sensor_data_test/sensor_data_main.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp rename to src/sensor/rotation_vector/test/test_projects/sensor_data_test/sensor_data_main.cpp diff --git a/src/sensor/sensor_fusion/test/test_projects/vector_test/vector_main.cpp b/src/sensor/rotation_vector/test/test_projects/vector_test/vector_main.cpp similarity index 100% rename from src/sensor/sensor_fusion/test/test_projects/vector_test/vector_main.cpp rename to src/sensor/rotation_vector/test/test_projects/vector_test/vector_main.cpp -- 2.7.4 From 707e40b6ca3d5e8a2c3eb8fdcf7dc308e7330f10 Mon Sep 17 00:00:00 2001 From: akhilkedia94 Date: Thu, 18 Aug 2016 14:48:33 +0900 Subject: [PATCH 10/16] Rotation Vector Sensor Created a rv_sensor using Sensor Fusion. Change-Id: Ie7b3f2585621d724f0f3bd2e956e1bab4d3bfdfc Signed-off-by: akhilkedia94 --- src/sensor/CMakeLists.txt | 8 +- src/sensor/rotation_vector/fusion_base.cpp | 1 - src/sensor/rotation_vector/fusion_base.h | 2 +- .../{rotation_vector_sensor.cpp => rv_sensor.cpp} | 145 ++++++++------------- .../{rotation_vector_sensor.h => rv_sensor.h} | 15 +-- src/server/sensor_loader.cpp | 4 +- 6 files changed, 69 insertions(+), 106 deletions(-) rename src/sensor/rotation_vector/{rotation_vector_sensor.cpp => rv_sensor.cpp} (58%) rename src/sensor/rotation_vector/{rotation_vector_sensor.h => rv_sensor.h} (90%) diff --git a/src/sensor/CMakeLists.txt b/src/sensor/CMakeLists.txt index 0547bc8..3cbd1a7 100644 --- a/src/sensor/CMakeLists.txt +++ b/src/sensor/CMakeLists.txt @@ -14,7 +14,6 @@ ELSE() SET(RV "OFF") SET(ORIENTATION "OFF") ENDIF() -SET(FUSION "ON") SET(MOTION "OFF") INCLUDE_DIRECTORIES( @@ -59,13 +58,10 @@ IF("${ORIENTATION}" STREQUAL "ON") SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_ORIENTATION") ENDIF() IF("${RV}" STREQUAL "ON") - FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/*.cpp) + FILE(GLOB SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/*.cpp) SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector) SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_ROTATION_VECTOR") -ENDIF() -IF("${FUSION}" STREQUAL "ON") -FILE(GLOB SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion/*.cpp) -SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion) + FILE(GLOB SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/fusion_utils/*.cpp) ENDIF() IF("${MOTION}" STREQUAL "ON") add_subdirectory(motion) diff --git a/src/sensor/rotation_vector/fusion_base.cpp b/src/sensor/rotation_vector/fusion_base.cpp index 355a551..51e45d3 100644 --- a/src/sensor/rotation_vector/fusion_base.cpp +++ b/src/sensor/rotation_vector/fusion_base.cpp @@ -26,7 +26,6 @@ #include #include #include "fusion_base.h" -#include "orientation_filter.h" #define ACCEL_COMPENSATION -1 #define GYRO_COMPENSATION 1 diff --git a/src/sensor/rotation_vector/fusion_base.h b/src/sensor/rotation_vector/fusion_base.h index 1479023..3af7c91 100644 --- a/src/sensor/rotation_vector/fusion_base.h +++ b/src/sensor/rotation_vector/fusion_base.h @@ -20,7 +20,7 @@ #define __FUSION_BASE_H__ #include -#include +#include "fusion_utils/orientation_filter.h" class fusion_base : public virtual fusion { public: diff --git a/src/sensor/rotation_vector/rotation_vector_sensor.cpp b/src/sensor/rotation_vector/rv_sensor.cpp similarity index 58% rename from src/sensor/rotation_vector/rotation_vector_sensor.cpp rename to src/sensor/rotation_vector/rv_sensor.cpp index 93c03db..0e9db8e 100644 --- a/src/sensor/rotation_vector/rotation_vector_sensor.cpp +++ b/src/sensor/rotation_vector/rv_sensor.cpp @@ -31,40 +31,38 @@ #include #include -#include +#include #include #include #define SENSOR_NAME "SENSOR_ROTATION_VECTOR" -#define NORM(x, y, z) sqrt((x)*(x) + (y)*(y) + (z)*(z)) -#define STATE_ACCEL 0x1 -#define STATE_MAGNETIC 0x2 - -rotation_vector_sensor::rotation_vector_sensor() +rv_sensor::rv_sensor() : m_accel_sensor(NULL) +, m_gyro_sensor(NULL) , m_mag_sensor(NULL) , m_x(-1) , m_y(-1) , m_z(-1) , m_w(-1) , m_time(0) -, m_state(0) +, m_accuracy(SENSOR_ACCURACY_UNDEFINED) { } -rotation_vector_sensor::~rotation_vector_sensor() +rv_sensor::~rv_sensor() { _I("%s is destroyed!", SENSOR_NAME); } -bool rotation_vector_sensor::init(void) +bool rv_sensor::init(void) { m_accel_sensor = sensor_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR); + m_gyro_sensor = sensor_loader::get_instance().get_sensor(GYROSCOPE_SENSOR); m_mag_sensor = sensor_loader::get_instance().get_sensor(GEOMAGNETIC_SENSOR); - if (!m_accel_sensor || !m_mag_sensor) { + if (!m_accel_sensor || !m_gyro_sensor|| !m_mag_sensor) { _E("cannot load sensors[%s]", SENSOR_NAME); return false; } @@ -73,22 +71,22 @@ bool rotation_vector_sensor::init(void) return true; } -sensor_type_t rotation_vector_sensor::get_type(void) +sensor_type_t rv_sensor::get_type(void) { return ROTATION_VECTOR_SENSOR; } -unsigned int rotation_vector_sensor::get_event_type(void) +unsigned int rv_sensor::get_event_type(void) { return CONVERT_TYPE_EVENT(ROTATION_VECTOR_SENSOR); } -const char* rotation_vector_sensor::get_name(void) +const char* rv_sensor::get_name(void) { return SENSOR_NAME; } -bool rotation_vector_sensor::get_sensor_info(sensor_info &info) +bool rv_sensor::get_sensor_info(sensor_info &info) { info.set_type(get_type()); info.set_id(get_id()); @@ -107,47 +105,34 @@ bool rotation_vector_sensor::get_sensor_info(sensor_info &info) return true; } -void rotation_vector_sensor::synthesize(const sensor_event_t& event) +void rv_sensor::synthesize(const sensor_event_t& event) { sensor_event_t *rotation_vector_event; - float R[9]; - float I[9]; - float quat[4]; - int error; if (event.event_type != GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME && - event.event_type != ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) + event.event_type != ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME && + event.event_type != GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME) return; - if (event.event_type == GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME) { - m_mag[0] = event.data->values[0]; - m_mag[1] = event.data->values[1]; - m_mag[2] = event.data->values[2]; - m_accuracy = event.data->accuracy; - - m_state |= STATE_MAGNETIC; - } - - if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) { - m_acc[0] = event.data->values[0]; - m_acc[1] = event.data->values[1]; - m_acc[2] = event.data->values[2]; + if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) + m_fusion.push_accel(*(event.data)); + else if (event.event_type == GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME) + m_fusion.push_mag(*(event.data)); + else if (event.event_type == GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME) + m_fusion.push_gyro(*(event.data)); - m_state |= STATE_ACCEL; - } + if (m_accuracy == SENSOR_ACCURACY_UNDEFINED) + m_accuracy = event.data->accuracy; + else if (m_accuracy > event.data->accuracy) + m_accuracy = event.data->accuracy; - if (m_state != (STATE_ACCEL | STATE_MAGNETIC)) + unsigned long long timestamp; + if (!m_fusion.get_rv(timestamp, m_w, m_x, m_y, m_z)) return; - m_state = 0; - - unsigned long long timestamp = event.data->timestamp; - - error = calculate_rotation_matrix(m_acc, m_mag, R, I); - ret_if(error < 0); - - error = matrix_to_quat(R, quat); - ret_if(error < 0); + if (timestamp == m_time) + return; + m_time = timestamp; rotation_vector_event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); if (!rotation_vector_event) { @@ -165,25 +150,19 @@ void rotation_vector_sensor::synthesize(const sensor_event_t& event) rotation_vector_event->event_type = CONVERT_TYPE_EVENT(ROTATION_VECTOR_SENSOR); rotation_vector_event->data_length = sizeof(sensor_data_t); rotation_vector_event->data->accuracy = m_accuracy; - rotation_vector_event->data->timestamp = timestamp; + rotation_vector_event->data->timestamp = m_time; rotation_vector_event->data->value_count = 4; - rotation_vector_event->data->values[0] = quat[0]; - rotation_vector_event->data->values[1] = quat[1]; - rotation_vector_event->data->values[2] = quat[2]; - rotation_vector_event->data->values[3] = quat[3]; + rotation_vector_event->data->values[0] = m_w; + rotation_vector_event->data->values[1] = m_x; + rotation_vector_event->data->values[2] = m_y; + rotation_vector_event->data->values[3] = m_z; push(rotation_vector_event); - - m_time = timestamp; - m_x = quat[0]; - m_y = quat[1]; - m_z = quat[2]; - m_w = quat[3]; - m_accuracy = event.data->accuracy; + m_accuracy = SENSOR_ACCURACY_UNDEFINED; _D("[rotation_vector] : [%10f] [%10f] [%10f] [%10f]", m_x, m_y, m_z, m_w); } -int rotation_vector_sensor::get_data(sensor_data_t **data, int *length) +int rv_sensor::get_data(sensor_data_t **data, int *length) { sensor_data_t *sensor_data; sensor_data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); @@ -201,61 +180,51 @@ int rotation_vector_sensor::get_data(sensor_data_t **data, int *length) return 0; } -bool rotation_vector_sensor::set_interval(unsigned long interval) +bool rv_sensor::set_interval(unsigned long interval) { m_interval = interval; return true; } -bool rotation_vector_sensor::set_batch_latency(unsigned long latency) +bool rv_sensor::set_batch_latency(unsigned long latency) { return false; } -bool rotation_vector_sensor::on_start(void) +bool rv_sensor::on_start(void) { - if (m_accel_sensor) - m_accel_sensor->start(); - - if (m_mag_sensor) - m_mag_sensor->start(); - + m_accel_sensor->start(); + m_gyro_sensor->start(); + m_mag_sensor->start(); m_time = 0; + m_accuracy = SENSOR_ACCURACY_UNDEFINED; return activate(); } -bool rotation_vector_sensor::on_stop(void) +bool rv_sensor::on_stop(void) { - if (m_accel_sensor) - m_accel_sensor->stop(); - - if (m_mag_sensor) - m_mag_sensor->stop(); - + m_accel_sensor->stop(); + m_gyro_sensor->stop(); + m_mag_sensor->stop(); m_time = 0; - m_state = 0; - + m_accuracy = SENSOR_ACCURACY_UNDEFINED; return deactivate(); } -bool rotation_vector_sensor::add_interval(int client_id, unsigned int interval, bool is_processor) +bool rv_sensor::add_interval(int client_id, unsigned int interval, bool is_processor) { - if (m_accel_sensor) - m_accel_sensor->add_interval(client_id, interval, true); - - if (m_mag_sensor) - m_mag_sensor->add_interval(client_id, interval, true); + m_accel_sensor->add_interval(client_id, interval, true); + m_gyro_sensor->add_interval(client_id, interval, true); + m_mag_sensor->add_interval(client_id, interval, true); return sensor_base::add_interval(client_id, interval, is_processor); } -bool rotation_vector_sensor::delete_interval(int client_id, bool is_processor) +bool rv_sensor::delete_interval(int client_id, bool is_processor) { - if (m_accel_sensor) - m_accel_sensor->delete_interval(client_id, true); - - if (m_mag_sensor) - m_mag_sensor->delete_interval(client_id, true); + m_accel_sensor->delete_interval(client_id, true); + m_gyro_sensor->delete_interval(client_id, true); + m_mag_sensor->delete_interval(client_id, true); return sensor_base::delete_interval(client_id, is_processor); } diff --git a/src/sensor/rotation_vector/rotation_vector_sensor.h b/src/sensor/rotation_vector/rv_sensor.h similarity index 90% rename from src/sensor/rotation_vector/rotation_vector_sensor.h rename to src/sensor/rotation_vector/rv_sensor.h index fcd4a4b..2a984c7 100644 --- a/src/sensor/rotation_vector/rotation_vector_sensor.h +++ b/src/sensor/rotation_vector/rv_sensor.h @@ -22,11 +22,12 @@ #include #include +#include -class rotation_vector_sensor : public virtual_sensor { +class rv_sensor : public virtual_sensor { public: - rotation_vector_sensor(); - virtual ~rotation_vector_sensor(); + rv_sensor(); + virtual ~rv_sensor(); /* initialize sensor */ bool init(void); @@ -49,18 +50,16 @@ public: private: sensor_base *m_accel_sensor; sensor_base *m_mag_sensor; + sensor_base *m_gyro_sensor; + gyro_magnetic_fusion m_fusion; float m_x; float m_y; float m_z; float m_w; - int m_accuracy; unsigned long long m_time; unsigned long m_interval; - - float m_acc[3]; - float m_mag[3]; - int m_state; + int m_accuracy; virtual bool set_interval(unsigned long interval); virtual bool set_batch_latency(unsigned long latency); diff --git a/src/server/sensor_loader.cpp b/src/server/sensor_loader.cpp index 0d12915..5b69da0 100644 --- a/src/server/sensor_loader.cpp +++ b/src/server/sensor_loader.cpp @@ -46,7 +46,7 @@ #include #endif #ifdef ENABLE_ROTATION_VECTOR -#include +#include #endif using std::vector; @@ -171,7 +171,7 @@ void sensor_loader::create_sensors(void) create_virtual_sensors("Auto Rotation"); #endif #ifdef ENABLE_ROTATION_VECTOR - create_virtual_sensors("Rotation Vector"); + create_virtual_sensors("Rotation Vector"); #endif #ifdef ENABLE_GRAVITY create_virtual_sensors("Gravity"); -- 2.7.4 From 5934d9ea1345ca495e2d9b9f42c7fc2cbf0a0eac Mon Sep 17 00:00:00 2001 From: akhilkedia94 Date: Tue, 16 Aug 2016 20:33:00 +0900 Subject: [PATCH 11/16] Magnetic RV Sensor Change-Id: I7a0586952f69404573d5ae974d6dc3c8cf1b7055 Signed-off-by: akhilkedia94 --- src/sensor/rotation_vector/magnetic_rv_sensor.cpp | 220 ++++++++++++++++++++++ src/sensor/rotation_vector/magnetic_rv_sensor.h | 70 +++++++ src/server/sensor_loader.cpp | 2 + 3 files changed, 292 insertions(+) create mode 100644 src/sensor/rotation_vector/magnetic_rv_sensor.cpp create mode 100644 src/sensor/rotation_vector/magnetic_rv_sensor.h diff --git a/src/sensor/rotation_vector/magnetic_rv_sensor.cpp b/src/sensor/rotation_vector/magnetic_rv_sensor.cpp new file mode 100644 index 0000000..6700230 --- /dev/null +++ b/src/sensor/rotation_vector/magnetic_rv_sensor.cpp @@ -0,0 +1,220 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#define SENSOR_NAME "SENSOR_MAGNETIC_ROTATION_VECTOR" + + +magnetic_rv_sensor::magnetic_rv_sensor() +: m_accel_sensor(NULL) +, m_mag_sensor(NULL) +, m_x(-1) +, m_y(-1) +, m_z(-1) +, m_w(-1) +, m_time(0) +, m_accuracy(SENSOR_ACCURACY_UNDEFINED) +{ +} + +magnetic_rv_sensor::~magnetic_rv_sensor() +{ + _I("%s is destroyed!", SENSOR_NAME); +} + +bool magnetic_rv_sensor::init(void) +{ + m_accel_sensor = sensor_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR); + m_mag_sensor = sensor_loader::get_instance().get_sensor(GEOMAGNETIC_SENSOR); + + if (!m_accel_sensor || !m_mag_sensor) { + _E("cannot load sensors[%s]", SENSOR_NAME); + return false; + } + + _I("%s is created!", SENSOR_NAME); + return true; +} + +sensor_type_t magnetic_rv_sensor::get_type(void) +{ + return GEOMAGNETIC_RV_SENSOR; +} + +unsigned int magnetic_rv_sensor::get_event_type(void) +{ + return CONVERT_TYPE_EVENT(GEOMAGNETIC_RV_SENSOR); +} + +const char* magnetic_rv_sensor::get_name(void) +{ + return SENSOR_NAME; +} + +bool magnetic_rv_sensor::get_sensor_info(sensor_info &info) +{ + info.set_type(get_type()); + info.set_id(get_id()); + info.set_privilege(SENSOR_PRIVILEGE_PUBLIC); + info.set_name(get_name()); + info.set_vendor("Samsung Electronics"); + info.set_min_range(0); + info.set_max_range(1); + info.set_resolution(1); + info.set_min_interval(1); + info.set_fifo_count(0); + info.set_max_batch_count(0); + info.set_supported_event(get_event_type()); + info.set_wakeup_supported(false); + + return true; +} + +void magnetic_rv_sensor::synthesize(const sensor_event_t& event) +{ + sensor_event_t *rotation_vector_event; + + if (event.event_type != ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME && + event.event_type != GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME) + return; + + if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) + m_fusion.push_accel(*(event.data)); + else if (event.event_type == GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME) + m_fusion.push_mag(*(event.data)); + + if (m_accuracy == SENSOR_ACCURACY_UNDEFINED) + m_accuracy = event.data->accuracy; + else if (m_accuracy > event.data->accuracy) + m_accuracy = event.data->accuracy; + + unsigned long long timestamp; + if (!m_fusion.get_rv(timestamp, m_w, m_x, m_y, m_z)) + return; + + if (timestamp == m_time) + return; + m_time = timestamp; + + rotation_vector_event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); + if (!rotation_vector_event) { + _E("Failed to allocate memory"); + return; + } + rotation_vector_event->data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); + if (!rotation_vector_event->data) { + _E("Failed to allocate memory"); + free(rotation_vector_event); + return; + } + + rotation_vector_event->sensor_id = get_id(); + rotation_vector_event->event_type = CONVERT_TYPE_EVENT(GEOMAGNETIC_RV_SENSOR); + rotation_vector_event->data_length = sizeof(sensor_data_t); + rotation_vector_event->data->accuracy = m_accuracy; + rotation_vector_event->data->timestamp = m_time; + rotation_vector_event->data->value_count = 4; + rotation_vector_event->data->values[0] = m_w; + rotation_vector_event->data->values[1] = m_x; + rotation_vector_event->data->values[2] = m_y; + rotation_vector_event->data->values[3] = m_z; + push(rotation_vector_event); + m_accuracy = SENSOR_ACCURACY_UNDEFINED; + + _D("[rotation_vector] : [%10f] [%10f] [%10f] [%10f]", m_x, m_y, m_z, m_w); +} + +int magnetic_rv_sensor::get_data(sensor_data_t **data, int *length) +{ + sensor_data_t *sensor_data; + sensor_data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); + + sensor_data->accuracy = m_accuracy; + sensor_data->timestamp = m_time; + sensor_data->value_count = 3; + sensor_data->values[0] = m_x; + sensor_data->values[1] = m_y; + sensor_data->values[2] = m_z; + + *data = sensor_data; + *length = sizeof(sensor_data_t); + + return 0; +} + +bool magnetic_rv_sensor::set_interval(unsigned long interval) +{ + m_interval = interval; + return true; +} + +bool magnetic_rv_sensor::set_batch_latency(unsigned long latency) +{ + return false; +} + +bool magnetic_rv_sensor::on_start(void) +{ + m_accel_sensor->start(); + m_mag_sensor->start(); + m_time = 0; + m_accuracy = SENSOR_ACCURACY_UNDEFINED; + return activate(); +} + +bool magnetic_rv_sensor::on_stop(void) +{ + m_accel_sensor->stop(); + m_mag_sensor->stop(); + m_time = 0; + m_accuracy = SENSOR_ACCURACY_UNDEFINED; + return deactivate(); +} + +bool magnetic_rv_sensor::add_interval(int client_id, unsigned int interval, bool is_processor) +{ + m_accel_sensor->add_interval(client_id, interval, true); + m_mag_sensor->add_interval(client_id, interval, true); + + return sensor_base::add_interval(client_id, interval, is_processor); +} + +bool magnetic_rv_sensor::delete_interval(int client_id, bool is_processor) +{ + m_accel_sensor->delete_interval(client_id, true); + m_mag_sensor->delete_interval(client_id, true); + + return sensor_base::delete_interval(client_id, is_processor); +} diff --git a/src/sensor/rotation_vector/magnetic_rv_sensor.h b/src/sensor/rotation_vector/magnetic_rv_sensor.h new file mode 100644 index 0000000..34b5d49 --- /dev/null +++ b/src/sensor/rotation_vector/magnetic_rv_sensor.h @@ -0,0 +1,70 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __MAGNETIC_RV_SENSOR_H__ +#define __MAGNETIC_RV_SENSOR_H__ + +#include +#include +#include + +class magnetic_rv_sensor : public virtual_sensor { +public: + magnetic_rv_sensor(); + virtual ~magnetic_rv_sensor(); + + /* initialize sensor */ + bool init(void); + + /* sensor info */ + virtual sensor_type_t get_type(void); + virtual unsigned int get_event_type(void); + virtual const char* get_name(void); + + virtual bool get_sensor_info(sensor_info &info); + + /* synthesize event */ + virtual void synthesize(const sensor_event_t& event); + + bool add_interval(int client_id, unsigned int interval, bool is_processor); + bool delete_interval(int client_id, bool is_processor); + + /* get data */ + virtual int get_data(sensor_data_t **data, int *length); +private: + sensor_base *m_accel_sensor; + sensor_base *m_mag_sensor; + magnetic_fusion m_fusion; + + float m_x; + float m_y; + float m_z; + float m_w; + unsigned long long m_time; + unsigned long m_interval; + int m_accuracy; + + virtual bool set_interval(unsigned long interval); + virtual bool set_batch_latency(unsigned long latency); + + virtual bool on_start(void); + virtual bool on_stop(void); +}; + +#endif /* __MAGNETIC_SENSOR_H__ */ diff --git a/src/server/sensor_loader.cpp b/src/server/sensor_loader.cpp index 5b69da0..5c44f95 100644 --- a/src/server/sensor_loader.cpp +++ b/src/server/sensor_loader.cpp @@ -47,6 +47,7 @@ #endif #ifdef ENABLE_ROTATION_VECTOR #include +#include #endif using std::vector; @@ -172,6 +173,7 @@ void sensor_loader::create_sensors(void) #endif #ifdef ENABLE_ROTATION_VECTOR create_virtual_sensors("Rotation Vector"); + create_virtual_sensors("Magnetic Rotation Vector"); #endif #ifdef ENABLE_GRAVITY create_virtual_sensors("Gravity"); -- 2.7.4 From fd20718e52379e8ccb0de0b727c5f85862aad182 Mon Sep 17 00:00:00 2001 From: akhilkedia94 Date: Tue, 16 Aug 2016 20:40:06 +0900 Subject: [PATCH 12/16] Gyroscope RV Sensor Created a Rotation Vector Sensor which uses only accel and gyro Note - In lines 288-290 of src/sensor/rotation_vector/fusion_utils/ orientation_filter.cpp, the fusion backend does not update the quaternion if acceleration and gyroscope values are higher than a very low threshold. While this may improve performance in high noise situations, doing so causes the sensor to not update its values in most common-use scenarios. I would hence recommend to remove the 3 if conditions in the lines above. Change-Id: I0b96e6235c52f76195529b918bd54e29bf946631 Signed-off-by: akhilkedia94 --- src/sensor/rotation_vector/gyro_rv_sensor.cpp | 220 ++++++++++++++++++++++++++ src/sensor/rotation_vector/gyro_rv_sensor.h | 70 ++++++++ src/server/sensor_loader.cpp | 2 + 3 files changed, 292 insertions(+) create mode 100644 src/sensor/rotation_vector/gyro_rv_sensor.cpp create mode 100644 src/sensor/rotation_vector/gyro_rv_sensor.h diff --git a/src/sensor/rotation_vector/gyro_rv_sensor.cpp b/src/sensor/rotation_vector/gyro_rv_sensor.cpp new file mode 100644 index 0000000..1af3da1 --- /dev/null +++ b/src/sensor/rotation_vector/gyro_rv_sensor.cpp @@ -0,0 +1,220 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#define SENSOR_NAME "SENSOR_GYROSCOPE_ROTATION_VECTOR" + + +gyro_rv_sensor::gyro_rv_sensor() +: m_accel_sensor(NULL) +, m_gyro_sensor(NULL) +, m_x(-1) +, m_y(-1) +, m_z(-1) +, m_w(-1) +, m_time(0) +, m_accuracy(SENSOR_ACCURACY_UNDEFINED) +{ +} + +gyro_rv_sensor::~gyro_rv_sensor() +{ + _I("%s is destroyed!", SENSOR_NAME); +} + +bool gyro_rv_sensor::init(void) +{ + m_accel_sensor = sensor_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR); + m_gyro_sensor = sensor_loader::get_instance().get_sensor(GYROSCOPE_SENSOR); + + if (!m_accel_sensor || !m_gyro_sensor) { + _E("cannot load sensors[%s]", SENSOR_NAME); + return false; + } + + _I("%s is created!", SENSOR_NAME); + return true; +} + +sensor_type_t gyro_rv_sensor::get_type(void) +{ + return GYROSCOPE_RV_SENSOR; +} + +unsigned int gyro_rv_sensor::get_event_type(void) +{ + return CONVERT_TYPE_EVENT(GYROSCOPE_RV_SENSOR); +} + +const char* gyro_rv_sensor::get_name(void) +{ + return SENSOR_NAME; +} + +bool gyro_rv_sensor::get_sensor_info(sensor_info &info) +{ + info.set_type(get_type()); + info.set_id(get_id()); + info.set_privilege(SENSOR_PRIVILEGE_PUBLIC); + info.set_name(get_name()); + info.set_vendor("Samsung Electronics"); + info.set_min_range(0); + info.set_max_range(1); + info.set_resolution(1); + info.set_min_interval(1); + info.set_fifo_count(0); + info.set_max_batch_count(0); + info.set_supported_event(get_event_type()); + info.set_wakeup_supported(false); + + return true; +} + +void gyro_rv_sensor::synthesize(const sensor_event_t& event) +{ + sensor_event_t *rotation_vector_event; + + if (event.event_type != ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME && + event.event_type != GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME) + return; + + if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) + m_fusion.push_accel(*(event.data)); + else if (event.event_type == GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME) + m_fusion.push_gyro(*(event.data)); + + if (m_accuracy == SENSOR_ACCURACY_UNDEFINED) + m_accuracy = event.data->accuracy; + else if (m_accuracy > event.data->accuracy) + m_accuracy = event.data->accuracy; + + unsigned long long timestamp; + if (!m_fusion.get_rv(timestamp, m_w, m_x, m_y, m_z)) + return; + + if(timestamp == m_time) + return; + m_time = timestamp; + + rotation_vector_event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); + if (!rotation_vector_event) { + _E("Failed to allocate memory"); + return; + } + rotation_vector_event->data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); + if (!rotation_vector_event->data) { + _E("Failed to allocate memory"); + free(rotation_vector_event); + return; + } + + rotation_vector_event->sensor_id = get_id(); + rotation_vector_event->event_type = CONVERT_TYPE_EVENT(GYROSCOPE_RV_SENSOR); + rotation_vector_event->data_length = sizeof(sensor_data_t); + rotation_vector_event->data->accuracy = m_accuracy; + rotation_vector_event->data->timestamp = m_time; + rotation_vector_event->data->value_count = 4; + rotation_vector_event->data->values[0] = m_w; + rotation_vector_event->data->values[1] = m_x; + rotation_vector_event->data->values[2] = m_y; + rotation_vector_event->data->values[3] = m_z; + push(rotation_vector_event); + m_accuracy = SENSOR_ACCURACY_UNDEFINED; + + _D("[rotation_vector] : [%10f] [%10f] [%10f] [%10f]", m_x, m_y, m_z, m_w); +} + +int gyro_rv_sensor::get_data(sensor_data_t **data, int *length) +{ + sensor_data_t *sensor_data; + sensor_data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); + + sensor_data->accuracy = m_accuracy; + sensor_data->timestamp = m_time; + sensor_data->value_count = 3; + sensor_data->values[0] = m_x; + sensor_data->values[1] = m_y; + sensor_data->values[2] = m_z; + + *data = sensor_data; + *length = sizeof(sensor_data_t); + + return 0; +} + +bool gyro_rv_sensor::set_interval(unsigned long interval) +{ + m_interval = interval; + return true; +} + +bool gyro_rv_sensor::set_batch_latency(unsigned long latency) +{ + return false; +} + +bool gyro_rv_sensor::on_start(void) +{ + m_accel_sensor->start(); + m_gyro_sensor->start(); + m_time = 0; + m_accuracy = SENSOR_ACCURACY_UNDEFINED; + return activate(); +} + +bool gyro_rv_sensor::on_stop(void) +{ + m_accel_sensor->stop(); + m_gyro_sensor->stop(); + m_time = 0; + m_accuracy = SENSOR_ACCURACY_UNDEFINED; + return deactivate(); +} + +bool gyro_rv_sensor::add_interval(int client_id, unsigned int interval, bool is_processor) +{ + m_accel_sensor->add_interval(client_id, interval, true); + m_gyro_sensor->add_interval(client_id, interval, true); + + return sensor_base::add_interval(client_id, interval, is_processor); +} + +bool gyro_rv_sensor::delete_interval(int client_id, bool is_processor) +{ + m_accel_sensor->delete_interval(client_id, true); + m_gyro_sensor->delete_interval(client_id, true); + + return sensor_base::delete_interval(client_id, is_processor); +} diff --git a/src/sensor/rotation_vector/gyro_rv_sensor.h b/src/sensor/rotation_vector/gyro_rv_sensor.h new file mode 100644 index 0000000..052f0e3 --- /dev/null +++ b/src/sensor/rotation_vector/gyro_rv_sensor.h @@ -0,0 +1,70 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __GYRO_RV_SENSOR_H__ +#define __GYRO_RV_SENSOR_H__ + +#include +#include +#include + +class gyro_rv_sensor : public virtual_sensor { +public: + gyro_rv_sensor(); + virtual ~gyro_rv_sensor(); + + /* initialize sensor */ + bool init(void); + + /* sensor info */ + virtual sensor_type_t get_type(void); + virtual unsigned int get_event_type(void); + virtual const char* get_name(void); + + virtual bool get_sensor_info(sensor_info &info); + + /* synthesize event */ + virtual void synthesize(const sensor_event_t& event); + + bool add_interval(int client_id, unsigned int interval, bool is_processor); + bool delete_interval(int client_id, bool is_processor); + + /* get data */ + virtual int get_data(sensor_data_t **data, int *length); +private: + sensor_base *m_accel_sensor; + sensor_base *m_gyro_sensor; + gyro_fusion m_fusion; + + float m_x; + float m_y; + float m_z; + float m_w; + unsigned long long m_time; + unsigned long m_interval; + int m_accuracy; + + virtual bool set_interval(unsigned long interval); + virtual bool set_batch_latency(unsigned long latency); + + virtual bool on_start(void); + virtual bool on_stop(void); +}; + +#endif /* __GYRO_SENSOR_H__ */ diff --git a/src/server/sensor_loader.cpp b/src/server/sensor_loader.cpp index 5c44f95..0db7f6b 100644 --- a/src/server/sensor_loader.cpp +++ b/src/server/sensor_loader.cpp @@ -48,6 +48,7 @@ #ifdef ENABLE_ROTATION_VECTOR #include #include +#include #endif using std::vector; @@ -174,6 +175,7 @@ void sensor_loader::create_sensors(void) #ifdef ENABLE_ROTATION_VECTOR create_virtual_sensors("Rotation Vector"); create_virtual_sensors("Magnetic Rotation Vector"); + create_virtual_sensors("Gyroscope Rotation Vector"); #endif #ifdef ENABLE_GRAVITY create_virtual_sensors("Gravity"); -- 2.7.4 From 226c4193197442b9a1a462f75377023f6d501290 Mon Sep 17 00:00:00 2001 From: akhilkedia94 Date: Fri, 29 Jul 2016 16:53:35 +0900 Subject: [PATCH 13/16] Face Down Gesture Sensor Detects the face down gesture defined as - The phone being face up (<20 degrees from screen pointing vertically upwards) and then face down (<20 degrees from vertically downwards) in 2 second. Change-Id: I8045109a3266baaa11ab0316e07857474a5b1e8b Signed-off-by: akhilkedia94 --- src/sensor/CMakeLists.txt | 6 + src/sensor/gesture/face_down_alg.h | 32 +++++ src/sensor/gesture/face_down_alg_impl.cpp | 88 ++++++++++++ src/sensor/gesture/face_down_alg_impl.h | 44 ++++++ src/sensor/gesture/face_down_sensor.cpp | 204 +++++++++++++++++++++++++++ src/sensor/gesture/face_down_sensor.h | 66 +++++++++ src/server/sensor_loader.cpp | 6 + src/shared/sensor_deprecated.h | 6 +- src/shared/sensor_types.h | 1 + src/test/src/api-test.c | 3 + src/test/src/check-sensor.c | 10 ++ src/test/src/multi-thread-performance-test.c | 1 + src/test/src/sensor-test.c | 5 + 13 files changed, 471 insertions(+), 1 deletion(-) create mode 100644 src/sensor/gesture/face_down_alg.h create mode 100644 src/sensor/gesture/face_down_alg_impl.cpp create mode 100644 src/sensor/gesture/face_down_alg_impl.h create mode 100644 src/sensor/gesture/face_down_sensor.cpp create mode 100644 src/sensor/gesture/face_down_sensor.h diff --git a/src/sensor/CMakeLists.txt b/src/sensor/CMakeLists.txt index 3cbd1a7..33c3fe0 100644 --- a/src/sensor/CMakeLists.txt +++ b/src/sensor/CMakeLists.txt @@ -15,6 +15,7 @@ SET(RV "OFF") SET(ORIENTATION "OFF") ENDIF() SET(MOTION "OFF") +SET(FACE_DOWN "ON") INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/shared @@ -63,6 +64,11 @@ IF("${RV}" STREQUAL "ON") SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_ROTATION_VECTOR") FILE(GLOB SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/fusion_utils/*.cpp) ENDIF() +IF("${FACE_DOWN}" STREQUAL "ON") + FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/gesture/*.cpp) + SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/gesture) + SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_FACE_DOWN") +ENDIF() IF("${MOTION}" STREQUAL "ON") add_subdirectory(motion) ENDIF() diff --git a/src/sensor/gesture/face_down_alg.h b/src/sensor/gesture/face_down_alg.h new file mode 100644 index 0000000..16ab460 --- /dev/null +++ b/src/sensor/gesture/face_down_alg.h @@ -0,0 +1,32 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __FACE_DOWN_ALG_H__ +#define __FACE_DOWN_ALG_H__ + +#include + +class face_down_alg { +public: + virtual ~face_down_alg() {}; + virtual void push_event(const sensor_event_t & event) = 0; + virtual bool get_face_down(void) = 0; +}; + +#endif /* __FACE_DOWN_ALG_H __ */ diff --git a/src/sensor/gesture/face_down_alg_impl.cpp b/src/sensor/gesture/face_down_alg_impl.cpp new file mode 100644 index 0000000..051fd3b --- /dev/null +++ b/src/sensor/gesture/face_down_alg_impl.cpp @@ -0,0 +1,88 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#include +#include +#include +#include +#include +#define GRAVITY 9.80665 +#define TWENTY_DEGREES 0.349066 +#define ONE_SIXTY_DEGREES 2.79253 +#define WINDOW_SIZE (2000*100) + +face_down_alg_impl::face_down_alg_impl() +{ + m_current_time = 0; + m_last_event_time = 0; + m_latest_down_time = 0; +} + +face_down_alg_impl::~face_down_alg_impl() +{ +} + +void face_down_alg_impl::push_event(const sensor_event_t & event) +{ + //_I("face_down_alg: %llu acc[2]: %f",event.data->timestamp,event.data->values[2]); + m_current_time = event.data->timestamp; + remove_old_up_time(); + + if (event.data->values[2] < (GRAVITY * cos(ONE_SIXTY_DEGREES))) + m_latest_down_time = event.data->timestamp; + + if (event.data->values[2] > (GRAVITY * cos(TWENTY_DEGREES))) + m_oldest_up_time.push(event.data->timestamp); +} + +void face_down_alg_impl::remove_old_up_time(void) +{ + while (m_oldest_up_time.size() > 0 && (m_current_time - m_oldest_up_time.front() > WINDOW_SIZE)) + m_oldest_up_time.pop(); +} + +bool face_down_alg_impl::get_face_down(void) +{ + unsigned long long down = is_facing_down(); + unsigned long long up = was_facing_up(); + //_I("face_down_alg: down: %llu, up: %llu", down, up); + + if (down < up) + return false; + + if (m_current_time - m_last_event_time < WINDOW_SIZE) + return false; + + m_last_event_time = m_current_time; + return true; +} + +unsigned long long face_down_alg_impl::is_facing_down(void) +{ + if (m_current_time - m_latest_down_time < WINDOW_SIZE) + return m_latest_down_time; + return 0; +} + +unsigned long long face_down_alg_impl::was_facing_up(void) +{ + remove_old_up_time(); + if (m_oldest_up_time.size() == 0) + return ULLONG_MAX; + return m_oldest_up_time.front(); +} diff --git a/src/sensor/gesture/face_down_alg_impl.h b/src/sensor/gesture/face_down_alg_impl.h new file mode 100644 index 0000000..4afa3bb --- /dev/null +++ b/src/sensor/gesture/face_down_alg_impl.h @@ -0,0 +1,44 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __FACE_DOWN_ALG_IMPL_H__ +#define __FACE_DOWN_ALG_IMPL_H__ + +#include +#include +#include + +class face_down_alg_impl : public virtual face_down_alg { +public: + face_down_alg_impl(); + ~face_down_alg_impl(); + void push_event(const sensor_event_t & event); + bool get_face_down(void); +private: + unsigned long long m_current_time; + unsigned long long m_last_event_time; + unsigned long long m_latest_down_time; + std::queue m_oldest_up_time; + void remove_old_up_time(void); + unsigned long long is_facing_down(); + unsigned long long was_facing_up(); + +}; + +#endif /* __FACE_DOWN_ALG_IMPL_H__ */ diff --git a/src/sensor/gesture/face_down_sensor.cpp b/src/sensor/gesture/face_down_sensor.cpp new file mode 100644 index 0000000..9aca0f4 --- /dev/null +++ b/src/sensor/gesture/face_down_sensor.cpp @@ -0,0 +1,204 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#define SENSOR_NAME "SENSOR_FACE_DOWN" + +#define SENSOR_FREQUENCY 50 + +face_down_sensor::face_down_sensor() +: m_gravity_sensor(NULL) +, m_time(0) +, m_state(false) +{ +} + +face_down_sensor::~face_down_sensor() +{ + _I("%s is destroyed!", SENSOR_NAME); +} + +bool face_down_sensor::init(void) +{ + m_gravity_sensor = sensor_loader::get_instance().get_sensor(GRAVITY_SENSOR); + + if (!m_gravity_sensor) { + _E("cannot load gravity sensor sensor[%s]", SENSOR_NAME); + return false; + } + + m_alg = get_alg(); + if (!m_alg) + return false; + + _I("%s is created!", SENSOR_NAME); + return true; +} + +sensor_type_t face_down_sensor::get_type(void) +{ + return GESTURE_FACE_DOWN_SENSOR; +} + +unsigned int face_down_sensor::get_event_type(void) +{ + return CONVERT_TYPE_EVENT(GESTURE_FACE_DOWN_SENSOR); +} + +const char *face_down_sensor::get_name(void) +{ + return SENSOR_NAME; +} + +bool face_down_sensor::get_sensor_info(sensor_info & info) +{ + info.set_type(get_type()); + info.set_id(get_id()); + info.set_privilege(SENSOR_PRIVILEGE_PUBLIC); + info.set_name(get_name()); + info.set_vendor("Samsung Electronics"); + info.set_min_range(0); + info.set_max_range(1); + info.set_resolution(1); + info.set_min_interval(1); + info.set_fifo_count(0); + info.set_max_batch_count(0); + info.set_supported_event(get_event_type()); + info.set_wakeup_supported(false); + + return true; +} + +void face_down_sensor::synthesize(const sensor_event_t & event) +{ + if (event.event_type != GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME) + return; + + m_time = event.data->timestamp; + m_alg->push_event(event); + m_state = m_alg->get_face_down(); + if (!m_state) + return; + + sensor_event_t *face_down_event; + sensor_data_t *face_down_data; + int data_length; + + face_down_event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); + if (!face_down_event) { + _E("Failed to allocate memory"); + return; + } + + get_data(&face_down_data, &data_length); + face_down_event->sensor_id = get_id(); + face_down_event->event_type = FACE_DOWN_RAW_DATA_EVENT; + face_down_event->data_length = data_length; + face_down_event->data = face_down_data; + + push(face_down_event); + + _I("[face_down_sensor] : True"); +} + +int face_down_sensor::get_data(sensor_data_t ** data, int *length) +{ + sensor_data_t *sensor_data; + sensor_data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); + + sensor_data->accuracy = SENSOR_ACCURACY_GOOD; + sensor_data->timestamp = m_time; + sensor_data->value_count = 1; + sensor_data->values[0] = m_state; + + *data = sensor_data; + *length = sizeof(sensor_data_t); + + return 0; +} + +bool face_down_sensor::set_interval(unsigned long interval) +{ + m_interval = interval; + return true; +} + +bool face_down_sensor::set_batch_latency(unsigned long latency) +{ + return false; +} + +bool face_down_sensor::on_start(void) +{ + if (m_gravity_sensor) + m_gravity_sensor->start(); + + m_time = 0; + m_state = false; + return activate(); +} + +bool face_down_sensor::on_stop(void) +{ + if (m_gravity_sensor) + m_gravity_sensor->stop(); + + m_time = 0; + m_state = false; + + return deactivate(); +} + +bool face_down_sensor::add_interval(int client_id, unsigned int interval, bool is_processor) +{ + m_gravity_sensor->add_interval(client_id, interval, true); + return sensor_base::add_interval(client_id, interval, is_processor); +} + +bool face_down_sensor::delete_interval(int client_id, bool is_processor) +{ + m_gravity_sensor->delete_interval(client_id, true); + return sensor_base::delete_interval(client_id, is_processor); +} + +face_down_alg_impl *face_down_sensor::get_alg(void) +{ + face_down_alg_impl *alg = new(std::nothrow) face_down_alg_impl(); + retvm_if(!alg, NULL, "Failed to allocate memory"); + + return alg; +} diff --git a/src/sensor/gesture/face_down_sensor.h b/src/sensor/gesture/face_down_sensor.h new file mode 100644 index 0000000..7bb0809 --- /dev/null +++ b/src/sensor/gesture/face_down_sensor.h @@ -0,0 +1,66 @@ +/* + * sensord + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __FACE_DOWN_SENSOR_H__ +#define __FACE_DOWN_SENSOR_H__ + +#include +#include +#include + +class face_down_sensor : public virtual_sensor { +public: + face_down_sensor(); + ~face_down_sensor(); + + /* initialize sensor */ + bool init(void); + + /* sensor info */ + sensor_type_t get_type(void); + unsigned int get_event_type(void); + const char *get_name(void); + + bool get_sensor_info(sensor_info & info); + + /* synthesize event */ + void synthesize(const sensor_event_t & event); + + bool add_interval(int client_id, unsigned int interval, bool is_processor); + bool delete_interval(int client_id, bool is_processor); + + /* get data */ + int get_data(sensor_data_t ** data, int *length); +private: + sensor_base * m_gravity_sensor; + face_down_alg_impl *m_alg; + + unsigned long long m_time; + bool m_state; + unsigned int m_interval; + + bool set_interval(unsigned long interval); + bool set_batch_latency(unsigned long latency); + + bool on_start(void); + bool on_stop(void); + face_down_alg_impl *get_alg(void); +}; + +#endif /* __FACE_DOWN_SENSOR_H__ */ diff --git a/src/server/sensor_loader.cpp b/src/server/sensor_loader.cpp index 0db7f6b..21694c8 100644 --- a/src/server/sensor_loader.cpp +++ b/src/server/sensor_loader.cpp @@ -50,6 +50,9 @@ #include #include #endif +#ifdef ENABLE_FACE_DOWN +#include +#endif using std::vector; using std::string; @@ -186,6 +189,9 @@ void sensor_loader::create_sensors(void) #ifdef ENABLE_ORIENTATION create_virtual_sensors("Orientation"); #endif +#ifdef ENABLE_FACE_DOWN + create_virtual_sensors("Face Down"); +#endif } template diff --git a/src/shared/sensor_deprecated.h b/src/shared/sensor_deprecated.h index 41a4092..c81e2d1 100644 --- a/src/shared/sensor_deprecated.h +++ b/src/shared/sensor_deprecated.h @@ -50,6 +50,8 @@ enum event_types_t { ROTATION_VECTOR_RAW_DATA_EVENT = (ROTATION_VECTOR_SENSOR << 16) | 0x0001, + FACE_DOWN_RAW_DATA_EVENT = (GESTURE_FACE_DOWN_SENSOR << 16) | 0x0001, + RV_RAW_RAW_DATA_EVENT = (RV_RAW_SENSOR << 16) | 0x0001, ULTRAVIOLET_RAW_DATA_EVENT = (ULTRAVIOLET_SENSOR << 16) | 0x0001, @@ -161,6 +163,9 @@ enum event_types_t { #define CONTEXT_BASE_DATA_SET CONTEXT_REPORT_EVENT #define CONTEXT_EVENT_REPORT CONTEXT_REPORT_EVENT +#define FACE_DOWN_BASE_DATA_SET FACE_DOWN_RAW_DATA_EVENT +#define FACE_DOWN_EVENT_RAW_DATA_REPORT_ON_TIME FACE_DOWN_RAW_DATA_EVENT + enum accelerometer_rotate_state { ROTATION_UNKNOWN = 0, ROTATION_LANDSCAPE_LEFT = 1, @@ -258,4 +263,3 @@ enum motion_no_move_t { #endif #endif //__SENSOR_DEPRECATED_H__ - diff --git a/src/shared/sensor_types.h b/src/shared/sensor_types.h index 277cbc4..18e40f4 100644 --- a/src/shared/sensor_types.h +++ b/src/shared/sensor_types.h @@ -74,6 +74,7 @@ extern "C" DEF_SENSOR(GESTURE_WRIST_UP_SENSOR) \ DEF_SENSOR(GESTURE_WRIST_DOWN_SENSOR) \ DEF_SENSOR(GESTURE_MOVEMENT_STATE_SENSOR) \ + DEF_SENSOR(GESTURE_FACE_DOWN_SENSOR) \ \ DEF_SENSOR_VALUE(ACTIVITY_TRACKER_SENSOR, 0x1A00) \ DEF_SENSOR(ACTIVITY_LEVEL_MONITOR_SENSOR) \ diff --git a/src/test/src/api-test.c b/src/test/src/api-test.c index bdeec6a..2a1ff11 100644 --- a/src/test/src/api-test.c +++ b/src/test/src/api-test.c @@ -262,6 +262,9 @@ int main(int argc, char **argv) result = check_sensor_api(BIO_LED_RED_RAW_DATA_EVENT, interval); fprintf(fp, "BIO_LED_RED - RAW_DATA_REPORT_ON_TIME - %d\n", result); + result = check_sensor_api(FACE_DOWN_RAW_DATA_EVENT, interval); + fprintf(fp, "Face Down - RAW_DATA_REPORT_ON_TIME - %d\n", result); + printf("Logs printed in ./auto_test.output\n"); fclose(fp); return 0; diff --git a/src/test/src/check-sensor.c b/src/test/src/check-sensor.c index 406008a..04ea726 100644 --- a/src/test/src/check-sensor.c +++ b/src/test/src/check-sensor.c @@ -84,6 +84,9 @@ void printpollinglogs(sensor_type_t type,sensor_data_t data) case(GYROSCOPE_UNCAL_SENSOR): printf("Gyroscope Uncal [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2], data.values[3], data.values[4], data.values[5]); break; + case(GESTURE_FACE_DOWN_SENSOR): + printf("Face Down [%lld] [%6.6f]\n\n", data.timestamp, data.values[0]); + break; default: return; } @@ -164,6 +167,10 @@ int get_event(sensor_type_t sensor_type, char str[]) if (strcmp(str, "RAW_DATA_EVENT") == 0) return GYROSCOPE_UNCAL_RAW_DATA_EVENT; break; + case GESTURE_FACE_DOWN_SENSOR: + if (strcmp(str, "RAW_DATA_EVENT") == 0) + return FACE_DOWN_RAW_DATA_EVENT; + break; default: return -1; @@ -230,6 +237,9 @@ void callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, voi case GYROSCOPE_UNCAL_SENSOR: printf("Gyroscope Uncal [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3], data->values[4], data->values[5]); break; + case GESTURE_FACE_DOWN_SENSOR: + printf("Face Down [%lld] [%6.6f] \n", data->timestamp, data->values[0]); + break; default: return; diff --git a/src/test/src/multi-thread-performance-test.c b/src/test/src/multi-thread-performance-test.c index 9130d47..588c0e7 100644 --- a/src/test/src/multi-thread-performance-test.c +++ b/src/test/src/multi-thread-performance-test.c @@ -53,6 +53,7 @@ void usage() printf("[ultraviolet] "); printf("[light]\n"); printf("[gyro_uncal]"); + printf("[face_down]"); } diff --git a/src/test/src/sensor-test.c b/src/test/src/sensor-test.c index 823f246..ff2b005 100644 --- a/src/test/src/sensor-test.c +++ b/src/test/src/sensor-test.c @@ -49,6 +49,7 @@ void usage() printf("[bio_led_red] "); printf("[light]\n"); printf("[gyroscope_uncal]"); + printf("[face_down]"); printf("event:"); printf("[RAW_DATA_EVENT]\n"); printf("-p: [polling]\n"); @@ -148,6 +149,10 @@ int main(int argc, char **argv) sensor_type = BIO_LED_RED_SENSOR; event = BIO_LED_RED_RAW_DATA_EVENT; } + else if (strcmp(argv[1], "face_down") == 0) { + sensor_type = GESTURE_FACE_DOWN_SENSOR; + event = FACE_DOWN_RAW_DATA_EVENT; + } else { usage(); return -1; -- 2.7.4 From dd00cc8444588fe373f09bd8bfb76f1578d593b0 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 6 Sep 2016 12:59:04 +0900 Subject: [PATCH 14/16] Remove unnecessary header inclusion from face_down_alg_impl Change-Id: I3d5ec7e8673498d16e06c830e70964829b8b9d8f Signed-off-by: Mu-Woong Lee --- src/sensor/gesture/face_down_alg_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensor/gesture/face_down_alg_impl.cpp b/src/sensor/gesture/face_down_alg_impl.cpp index 051fd3b..93e3762 100644 --- a/src/sensor/gesture/face_down_alg_impl.cpp +++ b/src/sensor/gesture/face_down_alg_impl.cpp @@ -20,7 +20,7 @@ #include #include #include -#include + #define GRAVITY 9.80665 #define TWENTY_DEGREES 0.349066 #define ONE_SIXTY_DEGREES 2.79253 -- 2.7.4 From 0ea1a44203daba3252cd98d0172d21e313477982 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 6 Sep 2016 12:47:39 +0900 Subject: [PATCH 15/16] Fix the external sensor worker to handle NULL payload properly Change-Id: If425d87b5cae885ee972fdb16edd9b30c9987182 Signed-off-by: Mu-Woong Lee --- src/server/external_sensor_worker.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/server/external_sensor_worker.cpp b/src/server/external_sensor_worker.cpp index 9bc46fb..67bb4d7 100644 --- a/src/server/external_sensor_worker.cpp +++ b/src/server/external_sensor_worker.cpp @@ -79,25 +79,22 @@ bool external_sensor_worker::working(void *ctx) return false; } - if (header.size > 0) { - payload = new(std::nothrow) char[header.size]; - retvm_if(!payload, false, "Failed to allocate memory"); - - if (inst->m_socket.recv(payload, header.size) <= 0) { - string info; - inst->get_info(info); - _D("%s failed to receive data of packet", info.c_str()); - delete[] payload; - return false; - } - } else { - payload = NULL; + retvm_if(header.size == 0, false, "Invalid header size"); + + payload = new(std::nothrow) char[header.size]; + retvm_if(!payload, false, "Failed to allocate memory"); + + if (inst->m_socket.recv(payload, header.size) <= 0) { + string info; + inst->get_info(info); + _D("%s failed to receive data of packet", info.c_str()); + delete[] payload; + return false; } ret = inst->dispatch_command(header.cmd, payload); - if (payload) - delete[] payload; + delete[] payload; return ret; } -- 2.7.4 From 85fdc1fb0aa3aa2b17e783ab1b114a7d74d70f2b Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Wed, 7 Sep 2016 15:55:11 +0900 Subject: [PATCH 16/16] Version 2.0.7 Change-Id: Id06dd0f98fb13a37c405c07d88237af1c62ae557 Signed-off-by: Mu-Woong Lee --- packaging/sensord.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/sensord.spec b/packaging/sensord.spec index 8af0b2d..0aa4f0f 100644 --- a/packaging/sensord.spec +++ b/packaging/sensord.spec @@ -1,6 +1,6 @@ Name: sensord Summary: Sensor daemon -Version: 2.0.6 +Version: 2.0.7 Release: 0 Group: System/Sensor Framework License: Apache-2.0 -- 2.7.4