From f4513df8861c168a2b8124c56da839df83395749 Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Wed, 25 Feb 2015 10:18:07 +0530 Subject: [PATCH 01/16] Replacing mul() with operator *() after rebase mul() method has been replaced with *() in one of the other commits. Rebasing according to the change. Change-Id: I1f332dbe3413f2b08e1107783c59cdca48f54c71 --- src/sensor_fusion/orientation_filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensor_fusion/orientation_filter.cpp b/src/sensor_fusion/orientation_filter.cpp index 0b316ee..68f0431 100644 --- a/src/sensor_fusion/orientation_filter.cpp +++ b/src/sensor_fusion/orientation_filter.cpp @@ -304,7 +304,7 @@ inline void orientation_filter::time_update_gaming_rv() m_measure_mat.m_mat[2][2] = 1; if (is_initialized(m_state_old)) - m_state_new = transpose(mul(m_tran_mat, transpose(m_state_old))); + m_state_new = transpose(m_tran_mat * transpose(m_state_old)); m_pred_cov = (m_tran_mat * m_pred_cov * tran(m_tran_mat)) + m_driv_cov; -- 2.7.4 From e63090288ba1b678b99e455590dbad5131b4d506 Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Wed, 25 Feb 2015 17:36:20 +0530 Subject: [PATCH 02/16] Adding different RD-PQ hardware virtual sensor xml configuration The sensor hardware behavior has been found to be different for 2 different variants of the RD-PQ hardware used for development. Adding the virtual sensor xml configuration for the 2nd RD-PQ hardware that is tested. Change-Id: Ic1c13b7a5da7cb9802d07c5401e04151d56a89e9 --- virtual_sensors.xml | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/virtual_sensors.xml b/virtual_sensors.xml index cfb9f81..42ea53d 100755 --- a/virtual_sensors.xml +++ b/virtual_sensors.xml @@ -81,12 +81,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.7.4 From e6e15c490afa0360438cfb2123af4939a5a3fb1c Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Thu, 26 Feb 2015 11:33:25 +0530 Subject: [PATCH 03/16] Updating configuration file for loading missing so files - Updating sensor_plugins.xml configuration file for loading missing geomagnetic rotation vector and gaming rotation vector plugins. Change-Id: I4bfec9344f30e2b13b0a9b908454e90cd7e517c2 --- sensor_plugins.xml.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sensor_plugins.xml.in b/sensor_plugins.xml.in index aca8a81..eb469c1 100755 --- a/sensor_plugins.xml.in +++ b/sensor_plugins.xml.in @@ -21,5 +21,7 @@ + + -- 2.7.4 From a6689f5545620ae9c050db2de30f432838fb9354 Mon Sep 17 00:00:00 2001 From: Ankur Date: Thu, 26 Feb 2015 17:30:27 +0530 Subject: [PATCH 04/16] Removing redundant auto_rotation events AUTO_ROTATION_BASE_DATA_SET and AUTO_ROTATION_EVENT_CHANGE_STATE were the same AUTO_ROTATION_BASE_DATA_SET has been removed. AUTO_ROTATION_BASE_DATA_SET was used for polling events and AUTO_ROTATION__EVENT_CHANGE_STATE was used for event driven Since both these represent the same auto_rotation sensor event, DATA_SET type has been removed. And AUTO_ROTATION_EVENT_CHANGE_STATE has been renamed to AUTO_ROTATION_CHANGE_STATE_EVENT to make it simpler. Change-Id: I8523af6c00dd2919bb6b9f0606c48d5df37ff0c9 --- src/auto_rotation/auto_rotation_sensor.cpp | 6 +++--- src/libsensord/client_common.cpp | 5 ++--- src/libsensord/sensor_auto_rotation.h | 6 +----- src/libsensord/sensor_deprecated.h | 3 +++ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/auto_rotation/auto_rotation_sensor.cpp b/src/auto_rotation/auto_rotation_sensor.cpp index cdf7609..381e861 100755 --- a/src/auto_rotation/auto_rotation_sensor.cpp +++ b/src/auto_rotation/auto_rotation_sensor.cpp @@ -49,7 +49,7 @@ auto_rotation_sensor::auto_rotation_sensor() { m_name = string(SENSOR_NAME); - register_supported_event(AUTO_ROTATION_EVENT_CHANGE_STATE); + register_supported_event(AUTO_ROTATION_CHANGE_STATE_EVENT); } auto_rotation_sensor::~auto_rotation_sensor() @@ -146,7 +146,7 @@ void auto_rotation_sensor::synthesize(const sensor_event_t& event, vector Date: Tue, 24 Feb 2015 19:02:25 +0530 Subject: [PATCH 05/16] Removing redundant Light sensor events LIGHT_LUX_DATA_SET and LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME were the same LIGHT_LUX_DATA_SET has been removed. LIGHT_LUX_DATA_SET was used for polling events and LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME was used for event driven Since both these represent the same light sensor event, DATA_SET type has been removed. And LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME has been renamed to LIGHT_LUX_DATA_EVENT to make it simpler. The change has been tested on rd-pq device for all sensord API and all API were found to be working. Change-Id: I44a761251a6fc9e78333f022b131c2562d65ccb9 --- src/libsensord/client_common.cpp | 14 ++++++-------- src/libsensord/sensor_deprecated.h | 6 ++++++ src/libsensord/sensor_light.h | 11 +++-------- src/light/light_sensor.cpp | 22 +++++++++++----------- test/src/auto_test.c | 2 +- test/src/tc-common.c | 4 ++-- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/libsensord/client_common.cpp b/src/libsensord/client_common.cpp index 6e5bfe7..1b0cc59 100755 --- a/src/libsensord/client_common.cpp +++ b/src/libsensord/client_common.cpp @@ -46,7 +46,7 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_CALIBRATION_NEEDED_EVENT, 0, 1), FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_CHANGE_STATE_EVENT, 0,1), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_EVENT_CHANGE_LEVEL, 0, 1), + FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_CHANGE_LEVEL_EVENT, 0, 1), FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_STATE_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_DISTANCE_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, CONTEXT_EVENT_REPORT, 0, 1), @@ -55,8 +55,8 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, GYROSCOPE_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, PRESSURE_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME, 0, 10), + FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LEVEL_DATA_EVENT, 0, 10), + FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LUX_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), @@ -66,8 +66,6 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_RV_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GAMING_RV_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_DATA, LIGHT_BASE_DATA_SET, 0, 25), - FILL_LOG_ELEMENT(LOG_ID_DATA, LIGHT_LUX_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, CONTEXT_BASE_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, GRAVITY_BASE_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, LINEAR_ACCEL_BASE_DATA_SET, 0, 25), @@ -149,9 +147,9 @@ bool is_ontime_event(unsigned int event_type) case ACCELEROMETER_RAW_DATA_EVENT: case PROXIMITY_STATE_EVENT: case GYROSCOPE_RAW_DATA_EVENT: - case LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME: + case LIGHT_LEVEL_DATA_EVENT: case GEOMAGNETIC_RAW_DATA_EVENT: - case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME: + case LIGHT_LUX_DATA_EVENT: case PROXIMITY_DISTANCE_DATA_EVENT: case GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME: case LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME: @@ -173,7 +171,7 @@ bool is_single_state_event(unsigned int event_type) { switch (event_type) { case GEOMAGNETIC_CALIBRATION_NEEDED_EVENT: - case LIGHT_EVENT_CHANGE_LEVEL: + case LIGHT_CHANGE_LEVEL_EVENT: case PROXIMITY_CHANGE_STATE_EVENT: case AUTO_ROTATION_CHANGE_STATE_EVENT: return true; diff --git a/src/libsensord/sensor_deprecated.h b/src/libsensord/sensor_deprecated.h index da7fd94..5ebedfe 100644 --- a/src/libsensord/sensor_deprecated.h +++ b/src/libsensord/sensor_deprecated.h @@ -67,6 +67,12 @@ extern "C" #define AUTO_ROTATION_BASE_DATA_SET AUTO_ROTATION_CHANGE_STATE_EVENT #define AUTO_ROTATION_EVENT_CHANGE_STATE AUTO_ROTATION_CHANGE_STATE_EVENT +#define LIGHT_LUX_DATA_SET LIGHT_LUX_DATA_EVENT +#define LIGHT_BASE_DATA_SET LIGHT_LEVEL_DATA_EVENT +#define LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME LIGHT_LUX_DATA_EVENT +#define LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME LIGHT_LEVEL_DATA_EVENT +#define LIGHT_EVENT_CHANGE_LEVEL LIGHT_CHANGE_LEVEL_EVENT + enum accelerometer_rotate_state { ROTATION_UNKNOWN = 0, ROTATION_LANDSCAPE_LEFT = 1, diff --git a/src/libsensord/sensor_light.h b/src/libsensord/sensor_light.h index bd35fb3..1f476b6 100755 --- a/src/libsensord/sensor_light.h +++ b/src/libsensord/sensor_light.h @@ -36,15 +36,10 @@ extern "C" * @{ */ -enum light_data_id { - LIGHT_LUX_DATA_SET = (LIGHT_SENSOR << 16) | 0x0001, - LIGHT_BASE_DATA_SET = (LIGHT_SENSOR << 16) | 0x0002, -}; - enum light_event_type { - LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME = (LIGHT_SENSOR << 16) | 0x0001, - LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME = (LIGHT_SENSOR << 16) | 0x0002, - LIGHT_EVENT_CHANGE_LEVEL = (LIGHT_SENSOR << 16) | 0x0004, + LIGHT_LUX_DATA_EVENT = (LIGHT_SENSOR << 16) | 0x0001, + LIGHT_LEVEL_DATA_EVENT = (LIGHT_SENSOR << 16) | 0x0002, + LIGHT_CHANGE_LEVEL_EVENT = (LIGHT_SENSOR << 16) | 0x0004, }; enum light_property_id { diff --git a/src/light/light_sensor.cpp b/src/light/light_sensor.cpp index fbffb23..73e45cc 100755 --- a/src/light/light_sensor.cpp +++ b/src/light/light_sensor.cpp @@ -38,9 +38,9 @@ light_sensor::light_sensor() m_name = string(SENSOR_NAME); vector supported_events = { - LIGHT_EVENT_CHANGE_LEVEL, - LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME, - LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME, + LIGHT_CHANGE_LEVEL_EVENT, + LIGHT_LEVEL_DATA_EVENT, + LIGHT_LUX_DATA_EVENT, }; for_each(supported_events.begin(), supported_events.end(), @@ -92,13 +92,13 @@ bool light_sensor::process_event(void) AUTOLOCK(m_client_info_mutex); event.sensor_id = get_id(); - if (get_client_cnt(LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME)) { - event.event_type = LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME; + if (get_client_cnt(LIGHT_LUX_DATA_EVENT)) { + event.event_type = LIGHT_LUX_DATA_EVENT; push(event); } - if (get_client_cnt(LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME)) { - event.event_type = LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME; + if (get_client_cnt(LIGHT_LEVEL_DATA_EVENT)) { + event.event_type = LIGHT_LEVEL_DATA_EVENT; raw_to_level(event.data); push(event); } @@ -106,8 +106,8 @@ bool light_sensor::process_event(void) if (m_level != level) { m_level = level; - if (get_client_cnt(LIGHT_EVENT_CHANGE_LEVEL)) { - event.event_type = LIGHT_EVENT_CHANGE_LEVEL; + if (get_client_cnt(LIGHT_CHANGE_LEVEL_EVENT)) { + event.event_type = LIGHT_CHANGE_LEVEL_EVENT; raw_to_level(event.data); push(event); } @@ -162,10 +162,10 @@ int light_sensor::get_sensor_data(unsigned int type, sensor_data_t &data) if (ret < 0) return -1; - if (type == LIGHT_LUX_DATA_SET) + if (type == LIGHT_LUX_DATA_EVENT) return 0; - if (type == LIGHT_BASE_DATA_SET) { + if (type == LIGHT_LEVEL_DATA_EVENT) { raw_to_level(data); return 0; } diff --git a/test/src/auto_test.c b/test/src/auto_test.c index 971b171..64857db 100644 --- a/test/src/auto_test.c +++ b/test/src/auto_test.c @@ -211,7 +211,7 @@ int main(int argc, char **argv) result = check_sensor_api(GYROSCOPE_RAW_DATA_EVENT, interval); fprintf(fp, "Gyroscope - RAW_DATA_REPORT_ON_TIME - %d\n", result); - result = check_sensor_api(LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME, interval); + result = check_sensor_api(LIGHT_LUX_DATA_EVENT, interval); fprintf(fp, "Light - RAW_DATA_REPORT_ON_TIME - %d\n", result); result = check_sensor_api(LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME, interval); diff --git a/test/src/tc-common.c b/test/src/tc-common.c index 2d1f263..defded2 100644 --- a/test/src/tc-common.c +++ b/test/src/tc-common.c @@ -80,7 +80,7 @@ unsigned int get_event_driven(sensor_type_t sensor_type, char str[]) break; case LIGHT_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) - return LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME; + return LIGHT_LUX_DATA_EVENT; break; case TEMPERATURE_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) @@ -229,7 +229,7 @@ int main(int argc, char **argv) } else if (strcmp(argv[1], "light") == 0) { sensor_type = LIGHT_SENSOR; - event = LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME; + event = LIGHT_LUX_DATA_EVENT; } else if (strcmp(argv[1], "proximity") == 0) { sensor_type = PROXIMITY_SENSOR; -- 2.7.4 From 95ca9d883b594f5ddb75c1bd932a464ad2e1954f Mon Sep 17 00:00:00 2001 From: Ankur Date: Wed, 25 Feb 2015 15:26:11 +0530 Subject: [PATCH 06/16] Removed redundant gravity events GRAVITY_BASE_DATA_SET and GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME were the same GRAVITY_BASE_DATA_SET has been removed. GRAVITY_BASE_DATA_SET was used for polling events and GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME was used for event driven Since both these represent the same gravity sensor event, DATA_SET type has been removed. And GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME has been renamed to GRAVITY_RAW_DATA_EVENT to make it simpler. The change has been tested on rd-pq device for all sensord API and all API were found to be working. Change-Id: I224d0ccfd8b4e48c132a357f410028d6a1cfe7de --- src/gravity/gravity_sensor.cpp | 6 +++--- src/libsensord/client_common.cpp | 5 ++--- src/libsensord/sensor_deprecated.h | 3 +++ src/libsensord/sensor_gravity.h | 6 +----- src/linear_accel/linear_accel_sensor.cpp | 8 ++++---- src/server/command_worker.cpp | 2 +- test/src/auto_test.c | 2 +- test/src/tc-common.c | 4 ++-- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/gravity/gravity_sensor.cpp b/src/gravity/gravity_sensor.cpp index 69afaa4..8fa44f2 100755 --- a/src/gravity/gravity_sensor.cpp +++ b/src/gravity/gravity_sensor.cpp @@ -58,7 +58,7 @@ gravity_sensor::gravity_sensor() cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance(); m_name = std::string(SENSOR_NAME); - register_supported_event(GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME); + register_supported_event(GRAVITY_RAW_DATA_EVENT); if (!config.get(SENSOR_TYPE_GRAVITY, ELEMENT_VENDOR, m_vendor)) { ERR("[VENDOR] is empty\n"); @@ -187,7 +187,7 @@ void gravity_sensor::synthesize(const sensor_event_t &event, vector= (M_PI/2)-DEVIATION && roll <= (M_PI/2)+DEVIATION) || (roll >= -(M_PI/2)-DEVIATION && roll <= -(M_PI/2)+DEVIATION)) { gravity_event.data.values[0] = m_gravity_sign_compensation[0] * GRAVITY * sin(roll) * cos(azimuth); @@ -228,7 +228,7 @@ int gravity_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t roll *= DEG2RAD; } - if (event_type != GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME) + if (event_type != GRAVITY_RAW_DATA_EVENT) return -1; data.accuracy = SENSOR_ACCURACY_GOOD; diff --git a/src/libsensord/client_common.cpp b/src/libsensord/client_common.cpp index 1b0cc59..5b7eb35 100755 --- a/src/libsensord/client_common.cpp +++ b/src/libsensord/client_common.cpp @@ -57,7 +57,7 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, PRESSURE_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LEVEL_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LUX_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), + FILL_LOG_ELEMENT(LOG_ID_EVENT, GRAVITY_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, PRESSURE_RAW_DATA_EVENT, 0, 10), @@ -67,7 +67,6 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, GAMING_RV_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_DATA, CONTEXT_BASE_DATA_SET, 0, 25), - FILL_LOG_ELEMENT(LOG_ID_DATA, GRAVITY_BASE_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, LINEAR_ACCEL_BASE_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, ORIENTATION_BASE_DATA_SET, 0, 25), }; @@ -151,7 +150,7 @@ bool is_ontime_event(unsigned int event_type) case GEOMAGNETIC_RAW_DATA_EVENT: case LIGHT_LUX_DATA_EVENT: case PROXIMITY_DISTANCE_DATA_EVENT: - case GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME: + case GRAVITY_RAW_DATA_EVENT: case LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME: case ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME: case PRESSURE_RAW_DATA_EVENT: diff --git a/src/libsensord/sensor_deprecated.h b/src/libsensord/sensor_deprecated.h index 5ebedfe..3f751b4 100644 --- a/src/libsensord/sensor_deprecated.h +++ b/src/libsensord/sensor_deprecated.h @@ -73,6 +73,9 @@ extern "C" #define LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME LIGHT_LEVEL_DATA_EVENT #define LIGHT_EVENT_CHANGE_LEVEL LIGHT_CHANGE_LEVEL_EVENT +#define GRAVITY_BASE_DATA_SET GRAVITY_RAW_DATA_EVENT +#define GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME GRAVITY_RAW_DATA_EVENT + enum accelerometer_rotate_state { ROTATION_UNKNOWN = 0, ROTATION_LANDSCAPE_LEFT = 1, diff --git a/src/libsensord/sensor_gravity.h b/src/libsensord/sensor_gravity.h index 2509f03..de48faa 100755 --- a/src/libsensord/sensor_gravity.h +++ b/src/libsensord/sensor_gravity.h @@ -36,12 +36,8 @@ extern "C" * @{ */ -enum gravity_data_id { - GRAVITY_BASE_DATA_SET = (GRAVITY_SENSOR << 16) | 0x0001, -}; - enum gravity_event_type { - GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME = (GRAVITY_SENSOR << 16) | 0x0001, + GRAVITY_RAW_DATA_EVENT = (GRAVITY_SENSOR << 16) | 0x0001, }; /** diff --git a/src/linear_accel/linear_accel_sensor.cpp b/src/linear_accel/linear_accel_sensor.cpp index 2ce3a78..3ccc8d5 100755 --- a/src/linear_accel/linear_accel_sensor.cpp +++ b/src/linear_accel/linear_accel_sensor.cpp @@ -146,7 +146,7 @@ sensor_type_t linear_accel_sensor::get_type(void) bool linear_accel_sensor::on_start(void) { AUTOLOCK(m_mutex); - m_gravity_sensor->add_client(GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME); + m_gravity_sensor->add_client(GRAVITY_RAW_DATA_EVENT); m_gravity_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); m_gravity_sensor->start(); @@ -161,7 +161,7 @@ bool linear_accel_sensor::on_start(void) bool linear_accel_sensor::on_stop(void) { AUTOLOCK(m_mutex); - m_gravity_sensor->delete_client(GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME); + m_gravity_sensor->delete_client(GRAVITY_RAW_DATA_EVENT); m_gravity_sensor->delete_interval((intptr_t)this, false); m_gravity_sensor->stop(); @@ -211,7 +211,7 @@ void linear_accel_sensor::synthesize(const sensor_event_t &event, vectorget_sensor_data(GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME, gravity_data); + ((virtual_sensor *)m_gravity_sensor)->get_sensor_data(GRAVITY_RAW_DATA_EVENT, gravity_data); m_accel_sensor->get_sensor_data(ACCELEROMETER_RAW_DATA_EVENT, accel_data); accel_data.values[0] = m_accel_rotation_direction_compensation[0] * (accel_data.values[0] - m_accel_static_bias[0]) / m_accel_scale; diff --git a/src/server/command_worker.cpp b/src/server/command_worker.cpp index 6c52743..a467b39 100755 --- a/src/server/command_worker.cpp +++ b/src/server/command_worker.cpp @@ -851,7 +851,7 @@ void insert_priority_list(unsigned int event_type) { if (event_type == ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME || event_type == LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME || - event_type == GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME || + event_type == GRAVITY_RAW_DATA_EVENT || event_type == ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME) { priority_list.insert(ACCELEROMETER_RAW_DATA_EVENT); priority_list.insert(GYROSCOPE_RAW_DATA_EVENT); diff --git a/test/src/auto_test.c b/test/src/auto_test.c index 64857db..fdf0e1c 100644 --- a/test/src/auto_test.c +++ b/test/src/auto_test.c @@ -205,7 +205,7 @@ int main(int argc, char **argv) result = check_sensor_api(GEOMAGNETIC_RAW_DATA_EVENT, interval); fprintf(fp, "Geomagnetic - RAW_DATA_REPORT_ON_TIME - %d\n", result); - result = check_sensor_api(GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME, interval); + result = check_sensor_api(GRAVITY_RAW_DATA_EVENT, interval); fprintf(fp, "Gravity - RAW_DATA_REPORT_ON_TIME - %d\n", result); result = check_sensor_api(GYROSCOPE_RAW_DATA_EVENT, interval); diff --git a/test/src/tc-common.c b/test/src/tc-common.c index defded2..2d0fa0a 100644 --- a/test/src/tc-common.c +++ b/test/src/tc-common.c @@ -96,7 +96,7 @@ unsigned int get_event_driven(sensor_type_t sensor_type, char str[]) break; case GRAVITY_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) - return GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME; + return GRAVITY_RAW_DATA_EVENT; break; case LINEAR_ACCEL_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) @@ -209,7 +209,7 @@ int main(int argc, char **argv) } else if (strcmp(argv[1], "gravity") == 0) { sensor_type = GRAVITY_SENSOR; - event = GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME; + event = GRAVITY_RAW_DATA_EVENT; } else if (strcmp(argv[1], "linear_accel") == 0) { sensor_type = LINEAR_ACCEL_SENSOR; -- 2.7.4 From b3ef62c4f97972c41cd13f025912113d44be07a9 Mon Sep 17 00:00:00 2001 From: Vibhor Gaur Date: Wed, 25 Feb 2015 16:06:58 +0530 Subject: [PATCH 07/16] Removed redundant orientation virtual sensor events Removed redundant orientation events ORIENTATION_BASE_DATA_SET and ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME which were the same. These have been moved to the sensor_deprecated folder. ORIENTATION_BASE_DATA_SET was used for polling events and ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME was used for event driven Since both these represent the same orientation virtual sensor event, DATA_SET type has been removed. ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME has been renamed to ORIENTATION_RAW_DATA_EVENT to make it simpler. The change has been tested on rd-pq device for all sensord API and all API were found to be working Change-Id: Iac7080cef6483b4fcaf5a454739ab1be50a57d23 --- src/gravity/gravity_sensor.cpp | 8 ++++---- src/libsensord/client_common.cpp | 7 +++---- src/libsensord/sensor_deprecated.h | 4 ++++ src/libsensord/sensor_orientation.h | 8 ++------ src/orientation/orientation_sensor.cpp | 6 +++--- src/server/command_worker.cpp | 2 +- test/src/auto_test.c | 2 +- test/src/tc-common.c | 4 ++-- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/gravity/gravity_sensor.cpp b/src/gravity/gravity_sensor.cpp index 8fa44f2..d6dc7d7 100755 --- a/src/gravity/gravity_sensor.cpp +++ b/src/gravity/gravity_sensor.cpp @@ -125,7 +125,7 @@ bool gravity_sensor::on_start(void) { AUTOLOCK(m_mutex); - m_orientation_sensor->add_client(ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME); + m_orientation_sensor->add_client(ORIENTATION_RAW_DATA_EVENT); m_orientation_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); m_orientation_sensor->start(); @@ -137,7 +137,7 @@ bool gravity_sensor::on_stop(void) { AUTOLOCK(m_mutex); - m_orientation_sensor->delete_client(ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME); + m_orientation_sensor->delete_client(ORIENTATION_RAW_DATA_EVENT); m_orientation_sensor->delete_interval((intptr_t)this, false); m_orientation_sensor->stop(); @@ -178,7 +178,7 @@ void gravity_sensor::synthesize(const sensor_event_t &event, vectorget_sensor_data(ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME, orientation_data); + m_orientation_sensor->get_sensor_data(ORIENTATION_RAW_DATA_EVENT, orientation_data); azimuth = orientation_data.values[0]; pitch = orientation_data.values[1]; diff --git a/src/libsensord/client_common.cpp b/src/libsensord/client_common.cpp index 5b7eb35..9733d9d 100755 --- a/src/libsensord/client_common.cpp +++ b/src/libsensord/client_common.cpp @@ -59,7 +59,7 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LUX_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GRAVITY_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), + FILL_LOG_ELEMENT(LOG_ID_EVENT, ORIENTATION_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, PRESSURE_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, TEMPERATURE_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), @@ -68,7 +68,6 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_DATA, CONTEXT_BASE_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, LINEAR_ACCEL_BASE_DATA_SET, 0, 25), - FILL_LOG_ELEMENT(LOG_ID_DATA, ORIENTATION_BASE_DATA_SET, 0, 25), }; typedef unordered_map log_map; @@ -152,7 +151,7 @@ bool is_ontime_event(unsigned int event_type) case PROXIMITY_DISTANCE_DATA_EVENT: case GRAVITY_RAW_DATA_EVENT: case LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME: - case ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME: + case ORIENTATION_RAW_DATA_EVENT: case PRESSURE_RAW_DATA_EVENT: return true; break; @@ -190,7 +189,7 @@ unsigned int get_calibration_event_type(unsigned int event_type) case GEOMAGNETIC_SENSOR: return GEOMAGNETIC_CALIBRATION_NEEDED_EVENT; case ORIENTATION_SENSOR: - return ORIENTATION_EVENT_CALIBRATION_NEEDED; + return ORIENTATION_CALIBRATION_NEEDED_EVENT; default: return 0; } diff --git a/src/libsensord/sensor_deprecated.h b/src/libsensord/sensor_deprecated.h index 3f751b4..aee52eb 100644 --- a/src/libsensord/sensor_deprecated.h +++ b/src/libsensord/sensor_deprecated.h @@ -76,6 +76,10 @@ extern "C" #define GRAVITY_BASE_DATA_SET GRAVITY_RAW_DATA_EVENT #define GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME GRAVITY_RAW_DATA_EVENT +#define ORIENTATION_BASE_DATA_SET ORIENTATION_RAW_DATA_EVENT +#define ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME ORIENTATION_RAW_DATA_EVENT +#define ORIENTATION_EVENT_CALIBRATION_NEEDED ORIENTATION_CALIBRATION_NEEDED_EVENT + enum accelerometer_rotate_state { ROTATION_UNKNOWN = 0, ROTATION_LANDSCAPE_LEFT = 1, diff --git a/src/libsensord/sensor_orientation.h b/src/libsensord/sensor_orientation.h index ecc2d2e..5852e17 100755 --- a/src/libsensord/sensor_orientation.h +++ b/src/libsensord/sensor_orientation.h @@ -36,13 +36,9 @@ extern "C" * @{ */ -enum orientation_data_id { - ORIENTATION_BASE_DATA_SET = (ORIENTATION_SENSOR << 16) | 0x0001, -}; - enum orientation_event_type { - ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME = (ORIENTATION_SENSOR << 16) | 0x0001, - ORIENTATION_EVENT_CALIBRATION_NEEDED = (ORIENTATION_SENSOR << 16) | 0x0002, + ORIENTATION_RAW_DATA_EVENT = (ORIENTATION_SENSOR << 16) | 0x0001, + ORIENTATION_CALIBRATION_NEEDED_EVENT = (ORIENTATION_SENSOR << 16) | 0x0002, }; /** diff --git a/src/orientation/orientation_sensor.cpp b/src/orientation/orientation_sensor.cpp index 355ac12..708ca92 100755 --- a/src/orientation/orientation_sensor.cpp +++ b/src/orientation/orientation_sensor.cpp @@ -83,7 +83,7 @@ orientation_sensor::orientation_sensor() cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance(); m_name = string(SENSOR_NAME); - register_supported_event(ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME); + register_supported_event(ORIENTATION_RAW_DATA_EVENT); m_enable_orientation = 0; if (!config.get(SENSOR_TYPE_ORIENTATION, ELEMENT_VENDOR, m_vendor)) { @@ -355,7 +355,7 @@ void orientation_sensor::synthesize(const sensor_event_t &event, vector euler_orientation; float azimuth_offset; - if (event_type != ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME) + if (event_type != ORIENTATION_RAW_DATA_EVENT) return -1; m_accel_sensor->get_sensor_data(ACCELEROMETER_RAW_DATA_EVENT, accel_data); diff --git a/src/server/command_worker.cpp b/src/server/command_worker.cpp index a467b39..d30ca37 100755 --- a/src/server/command_worker.cpp +++ b/src/server/command_worker.cpp @@ -849,7 +849,7 @@ csensor_event_dispatcher& command_worker::get_event_dispathcher(void) void insert_priority_list(unsigned int event_type) { - if (event_type == ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME || + if (event_type == ORIENTATION_RAW_DATA_EVENT || event_type == LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME || event_type == GRAVITY_RAW_DATA_EVENT || event_type == ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME) { diff --git a/test/src/auto_test.c b/test/src/auto_test.c index fdf0e1c..f3d12be 100644 --- a/test/src/auto_test.c +++ b/test/src/auto_test.c @@ -217,7 +217,7 @@ int main(int argc, char **argv) result = check_sensor_api(LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME, interval); fprintf(fp, "Linear Accel - RAW_DATA_REPORT_ON_TIME - %d\n", result); - result = check_sensor_api(ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME, interval); + result = check_sensor_api(ORIENTATION_RAW_DATA_EVENT, interval); fprintf(fp, "Orientation - RAW_DATA_REPORT_ON_TIME - %d\n", result); result = check_sensor_api(PRESSURE_RAW_DATA_EVENT, interval); diff --git a/test/src/tc-common.c b/test/src/tc-common.c index 2d0fa0a..8130665 100644 --- a/test/src/tc-common.c +++ b/test/src/tc-common.c @@ -92,7 +92,7 @@ unsigned int get_event_driven(sensor_type_t sensor_type, char str[]) break; case ORIENTATION_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) - return ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME; + return ORIENTATION_RAW_DATA_EVENT; break; case GRAVITY_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) @@ -205,7 +205,7 @@ int main(int argc, char **argv) } else if (strcmp(argv[1], "orientation") == 0) { sensor_type = ORIENTATION_SENSOR; - event = ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME; + event = ORIENTATION_RAW_DATA_EVENT; } else if (strcmp(argv[1], "gravity") == 0) { sensor_type = GRAVITY_SENSOR; -- 2.7.4 From f076e298cb762677d7d8a179c43f51df5780c379 Mon Sep 17 00:00:00 2001 From: Vibhor Gaur Date: Wed, 25 Feb 2015 16:46:46 +0530 Subject: [PATCH 08/16] Removing redundant linear acceleration virtual sensor events Removed redundant linear acceleration virtual sensor events LINEAR_ACCEL_BASE_DATA_SET and LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME which were the same. These have been moved to the sensor_deprecated folder. LINEAR_ACCEL_BASE_DATA_SET was used for polling events and LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME was used for event driven. Since both these represent the same linear acceleration virtual sensor event, DATA_SET type has been removed. LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME has been renamed to LINEAR_ACCEL_RAW_DATA_EVENT to make it simpler. The change has been tested on rd-pq device for all sensord API and all API were found to be working Change-Id: Ib0603a497ef5132917aa46d9c4055bf1377dfb68 --- src/libsensord/client_common.cpp | 5 ++--- src/libsensord/sensor_deprecated.h | 3 +++ src/libsensord/sensor_linear_accel.h | 6 +----- src/linear_accel/linear_accel_sensor.cpp | 6 +++--- src/server/command_worker.cpp | 2 +- test/src/auto_test.c | 2 +- test/src/tc-common.c | 4 ++-- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/libsensord/client_common.cpp b/src/libsensord/client_common.cpp index 9733d9d..cda167c 100755 --- a/src/libsensord/client_common.cpp +++ b/src/libsensord/client_common.cpp @@ -58,7 +58,7 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LEVEL_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LUX_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GRAVITY_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), + FILL_LOG_ELEMENT(LOG_ID_EVENT, LINEAR_ACCEL_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, ORIENTATION_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, PRESSURE_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, TEMPERATURE_RAW_DATA_EVENT, 0, 10), @@ -67,7 +67,6 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, GAMING_RV_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_DATA, CONTEXT_BASE_DATA_SET, 0, 25), - FILL_LOG_ELEMENT(LOG_ID_DATA, LINEAR_ACCEL_BASE_DATA_SET, 0, 25), }; typedef unordered_map log_map; @@ -150,7 +149,7 @@ bool is_ontime_event(unsigned int event_type) case LIGHT_LUX_DATA_EVENT: case PROXIMITY_DISTANCE_DATA_EVENT: case GRAVITY_RAW_DATA_EVENT: - case LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME: + case LINEAR_ACCEL_RAW_DATA_EVENT: case ORIENTATION_RAW_DATA_EVENT: case PRESSURE_RAW_DATA_EVENT: return true; diff --git a/src/libsensord/sensor_deprecated.h b/src/libsensord/sensor_deprecated.h index aee52eb..011d12b 100644 --- a/src/libsensord/sensor_deprecated.h +++ b/src/libsensord/sensor_deprecated.h @@ -80,6 +80,9 @@ extern "C" #define ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME ORIENTATION_RAW_DATA_EVENT #define ORIENTATION_EVENT_CALIBRATION_NEEDED ORIENTATION_CALIBRATION_NEEDED_EVENT +#define LINEAR_ACCEL_BASE_DATA_SET LINEAR_ACCEL_RAW_DATA_EVENT +#define LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME LINEAR_ACCEL_RAW_DATA_EVENT + enum accelerometer_rotate_state { ROTATION_UNKNOWN = 0, ROTATION_LANDSCAPE_LEFT = 1, diff --git a/src/libsensord/sensor_linear_accel.h b/src/libsensord/sensor_linear_accel.h index d4369c0..306d1d6 100755 --- a/src/libsensord/sensor_linear_accel.h +++ b/src/libsensord/sensor_linear_accel.h @@ -36,12 +36,8 @@ extern "C" * @{ */ -enum linear_accel_data_id { - LINEAR_ACCEL_BASE_DATA_SET = (LINEAR_ACCEL_SENSOR << 16) | 0x0001, -}; - enum linear_accel_event_type { - LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME = (LINEAR_ACCEL_SENSOR << 16) | 0x0001, + LINEAR_ACCEL_RAW_DATA_EVENT = (LINEAR_ACCEL_SENSOR << 16) | 0x0001, }; /** diff --git a/src/linear_accel/linear_accel_sensor.cpp b/src/linear_accel/linear_accel_sensor.cpp index 3ccc8d5..fe2d608 100755 --- a/src/linear_accel/linear_accel_sensor.cpp +++ b/src/linear_accel/linear_accel_sensor.cpp @@ -62,7 +62,7 @@ linear_accel_sensor::linear_accel_sensor() m_name = string(SENSOR_NAME); m_enable_linear_accel = 0; - register_supported_event(LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME); + register_supported_event(LINEAR_ACCEL_RAW_DATA_EVENT); if (!config.get(SENSOR_TYPE_LINEAR_ACCEL, ELEMENT_VENDOR, m_vendor)) { @@ -231,7 +231,7 @@ void linear_accel_sensor::synthesize(const sensor_event_t &event, vector Date: Thu, 26 Feb 2015 18:18:42 +0530 Subject: [PATCH 09/16] Removing redundant event representations for context sensor Removed redundant context sensor events CONTEXT_BASE_DATA_SET and CONTEXT_EVENT_REPORT which were the same. These have been moved to the sensor_deprecated folder. Since both these represent the same context sensor event, DATA_SET type has been removed. CONTEXT_EVENT_REPORT has been renamed to CONTEXT_REPORT_EVENT to make it simpler. Change-Id: Iaca58e1b48e19adabf5edc1d6a001933cd4ec910 --- src/libsensord/client_common.cpp | 4 +--- src/libsensord/sensor_context.h | 6 +----- src/libsensord/sensor_deprecated.h | 3 +++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/libsensord/client_common.cpp b/src/libsensord/client_common.cpp index cda167c..d1f132f 100755 --- a/src/libsensord/client_common.cpp +++ b/src/libsensord/client_common.cpp @@ -49,7 +49,7 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_CHANGE_LEVEL_EVENT, 0, 1), FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_STATE_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_DISTANCE_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, CONTEXT_EVENT_REPORT, 0, 1), + FILL_LOG_ELEMENT(LOG_ID_EVENT, CONTEXT_REPORT_EVENT, 0, 1), FILL_LOG_ELEMENT(LOG_ID_EVENT, AUTO_ROTATION_CHANGE_STATE_EVENT, 0, 1), FILL_LOG_ELEMENT(LOG_ID_EVENT, ACCELEROMETER_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GYROSCOPE_RAW_DATA_EVENT, 0, 10), @@ -65,8 +65,6 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_RV_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GAMING_RV_RAW_DATA_EVENT, 0, 10), - - FILL_LOG_ELEMENT(LOG_ID_DATA, CONTEXT_BASE_DATA_SET, 0, 25), }; typedef unordered_map log_map; diff --git a/src/libsensord/sensor_context.h b/src/libsensord/sensor_context.h index c821596..d35f941 100755 --- a/src/libsensord/sensor_context.h +++ b/src/libsensord/sensor_context.h @@ -36,12 +36,8 @@ extern "C" * @{ */ -enum context_data_id { - CONTEXT_BASE_DATA_SET = (CONTEXT_SENSOR << 16) | 0x0001, -}; - enum context_event_type { - CONTEXT_EVENT_REPORT = (CONTEXT_SENSOR << 16) | 0x0001, + CONTEXT_REPORT_EVENT = (CONTEXT_SENSOR << 16) | 0x0001, }; enum context_property_id { diff --git a/src/libsensord/sensor_deprecated.h b/src/libsensord/sensor_deprecated.h index 011d12b..bb80e6c 100644 --- a/src/libsensord/sensor_deprecated.h +++ b/src/libsensord/sensor_deprecated.h @@ -83,6 +83,9 @@ extern "C" #define LINEAR_ACCEL_BASE_DATA_SET LINEAR_ACCEL_RAW_DATA_EVENT #define LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME LINEAR_ACCEL_RAW_DATA_EVENT +#define CONTEXT_BASE_DATA_SET CONTEXT_REPORT_EVENT +#define CONTEXT_EVENT_REPORT CONTEXT_REPORT_EVENT + enum accelerometer_rotate_state { ROTATION_UNKNOWN = 0, ROTATION_LANDSCAPE_LEFT = 1, -- 2.7.4 From 2d03125616781cb96afb3d7f74a2c8d91f46aa5a Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Fri, 27 Feb 2015 14:53:07 +0530 Subject: [PATCH 10/16] Adding latest timestamp for virtual sensor polling events - Fixing timestamp issue for polling based virtual sensor events. - cleanup. Change-Id: Ie1c18f8f2b94b48eae7c84a723ddf0b56e0059f6 --- src/gravity/gravity_sensor.cpp | 1 - src/orientation/orientation_sensor.cpp | 1 - src/rotation_vector/gaming_rv/gaming_rv_sensor.cpp | 3 +-- src/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp | 3 +-- src/rotation_vector/rv/rv_sensor.cpp | 3 +-- 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/gravity/gravity_sensor.cpp b/src/gravity/gravity_sensor.cpp index d6dc7d7..48fddf4 100755 --- a/src/gravity/gravity_sensor.cpp +++ b/src/gravity/gravity_sensor.cpp @@ -185,7 +185,6 @@ void gravity_sensor::synthesize(const sensor_event_t &event, vector= (M_PI/2)-DEVIATION && roll <= (M_PI/2)+DEVIATION) || diff --git a/src/orientation/orientation_sensor.cpp b/src/orientation/orientation_sensor.cpp index 708ca92..500217a 100755 --- a/src/orientation/orientation_sensor.cpp +++ b/src/orientation/orientation_sensor.cpp @@ -353,7 +353,6 @@ void orientation_sensor::synthesize(const sensor_event_t &event, vector & } m_time = get_timestamp(); - rv_event.sensor_id = get_id(); rv_event.event_type = ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME; rv_event.data.accuracy = SENSOR_ACCURACY_GOOD; @@ -365,7 +364,7 @@ int rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_t &data) } data.accuracy = SENSOR_ACCURACY_GOOD; - data.timestamp = m_time; + data.timestamp = get_timestamp(); data.value_count = 4; data.values[0] = quaternion_orientation.m_quat.m_vec[1]; data.values[1] = quaternion_orientation.m_quat.m_vec[2]; -- 2.7.4 From 3a5a30495a45f8dc6780081cfc1a90dd38220dd1 Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Fri, 27 Feb 2015 15:03:57 +0530 Subject: [PATCH 11/16] Removing mutex lock that was affecting performance - Removing mutex lock used during entry into orientation_filter - lock is not needed as each virtual sensor has a separate orientation_filter object - separate objects in virtual sensor for both event driven and polling based modes. Change-Id: Ie2d2aa41a664c858fc1305213c3f9bb2309a7e67 --- src/orientation/orientation_sensor.cpp | 28 +++++++++------------- src/orientation/orientation_sensor.h | 3 ++- src/rotation_vector/gaming_rv/gaming_rv_sensor.cpp | 10 ++------ src/rotation_vector/gaming_rv/gaming_rv_sensor.h | 1 + .../geomagnetic_rv/geomagnetic_rv_sensor.cpp | 12 +++------- .../geomagnetic_rv/geomagnetic_rv_sensor.h | 1 + src/rotation_vector/rv/rv_sensor.cpp | 26 ++++++++------------ src/rotation_vector/rv/rv_sensor.h | 3 ++- src/shared/virtual_sensor.h | 1 - 9 files changed, 32 insertions(+), 53 deletions(-) diff --git a/src/orientation/orientation_sensor.cpp b/src/orientation/orientation_sensor.cpp index 500217a..0c8bed3 100755 --- a/src/orientation/orientation_sensor.cpp +++ b/src/orientation/orientation_sensor.cpp @@ -334,15 +334,12 @@ void orientation_sensor::synthesize(const sensor_event_t &event, vector m_orientation; + orientation_filter m_orientation_filter; + orientation_filter m_orientation_filter_poll; unsigned int m_enable_orientation; diff --git a/src/rotation_vector/gaming_rv/gaming_rv_sensor.cpp b/src/rotation_vector/gaming_rv/gaming_rv_sensor.cpp index 51a0a4b..fb44e0c 100755 --- a/src/rotation_vector/gaming_rv/gaming_rv_sensor.cpp +++ b/src/rotation_vector/gaming_rv/gaming_rv_sensor.cpp @@ -244,10 +244,7 @@ void gaming_rv_sensor::synthesize(const sensor_event_t& event, vector m_orientation_filter; + orientation_filter m_orientation_filter_poll; unsigned int m_enable_gaming_rv; diff --git a/src/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp b/src/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp index ae0348f..6649333 100755 --- a/src/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp +++ b/src/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp @@ -255,10 +255,7 @@ void geomagnetic_rv_sensor::synthesize(const sensor_event_t& event, vector m_orientation_filter; + orientation_filter m_orientation_filter_poll; unsigned int m_enable_geomagnetic_rv; diff --git a/src/rotation_vector/rv/rv_sensor.cpp b/src/rotation_vector/rv/rv_sensor.cpp index 958042e..48c48de 100755 --- a/src/rotation_vector/rv/rv_sensor.cpp +++ b/src/rotation_vector/rv/rv_sensor.cpp @@ -300,15 +300,12 @@ void rv_sensor::synthesize(const sensor_event_t& event, vector & if (m_enable_orientation == ORIENTATION_ENABLED) { m_enable_orientation = 0; - m_orientation.m_pitch_phase_compensation = m_pitch_rotation_compensation; - m_orientation.m_roll_phase_compensation = m_roll_rotation_compensation; - m_orientation.m_azimuth_phase_compensation = m_azimuth_rotation_compensation; - m_orientation.m_magnetic_alignment_factor = m_magnetic_alignment_factor; + m_orientation_filter.m_pitch_phase_compensation = m_pitch_rotation_compensation; + m_orientation_filter.m_roll_phase_compensation = m_roll_rotation_compensation; + m_orientation_filter.m_azimuth_phase_compensation = m_azimuth_rotation_compensation; + m_orientation_filter.m_magnetic_alignment_factor = m_magnetic_alignment_factor; - { - AUTOLOCK(m_fusion_mutex); - quaternion_orientation = m_orientation.get_9axis_quaternion(m_accel, m_gyro, m_magnetic); - } + quaternion_orientation = m_orientation_filter.get_9axis_quaternion(m_accel, m_gyro, m_magnetic); m_time = get_timestamp(); rv_event.sensor_id = get_id(); @@ -353,15 +350,12 @@ int rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_t &data) gyro.m_time_stamp = gyro_data.timestamp; magnetic.m_time_stamp = magnetic_data.timestamp; - m_orientation.m_pitch_phase_compensation = m_pitch_rotation_compensation; - m_orientation.m_roll_phase_compensation = m_roll_rotation_compensation; - m_orientation.m_azimuth_phase_compensation = m_azimuth_rotation_compensation; - m_orientation.m_magnetic_alignment_factor = m_magnetic_alignment_factor; + m_orientation_filter_poll.m_pitch_phase_compensation = m_pitch_rotation_compensation; + m_orientation_filter_poll.m_roll_phase_compensation = m_roll_rotation_compensation; + m_orientation_filter_poll.m_azimuth_phase_compensation = m_azimuth_rotation_compensation; + m_orientation_filter_poll.m_magnetic_alignment_factor = m_magnetic_alignment_factor; - { - AUTOLOCK(m_fusion_mutex); - quaternion_orientation = m_orientation.get_9axis_quaternion(m_accel, m_gyro, m_magnetic); - } + quaternion_orientation = m_orientation_filter_poll.get_9axis_quaternion(m_accel, m_gyro, m_magnetic); data.accuracy = SENSOR_ACCURACY_GOOD; data.timestamp = get_timestamp(); diff --git a/src/rotation_vector/rv/rv_sensor.h b/src/rotation_vector/rv/rv_sensor.h index 003c3fa..e3d2158 100755 --- a/src/rotation_vector/rv/rv_sensor.h +++ b/src/rotation_vector/rv/rv_sensor.h @@ -51,7 +51,8 @@ private: cmutex m_value_mutex; - orientation_filter m_orientation; + orientation_filter m_orientation_filter; + orientation_filter m_orientation_filter_poll; unsigned int m_enable_orientation; diff --git a/src/shared/virtual_sensor.h b/src/shared/virtual_sensor.h index 3cb79fb..7a3b70c 100755 --- a/src/shared/virtual_sensor.h +++ b/src/shared/virtual_sensor.h @@ -33,7 +33,6 @@ public: bool is_virtual(void); protected: - cmutex m_fusion_mutex; bool activate(void); bool deactivate(void); -- 2.7.4 From 380bc64e391f36f4050d3cd8509ec0ea1cd948c4 Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Mon, 2 Mar 2015 12:57:59 +0530 Subject: [PATCH 12/16] Adding code to install sensor_gaming_rv.h to CMakelist Adding missed cmake code to install sensor_gaming_rv.h Change-Id: I4f60e0cebddad7176814e6d96aefd77da9ecf53b --- src/libsensord/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libsensord/CMakeLists.txt b/src/libsensord/CMakeLists.txt index 2c5032e..2a8291f 100755 --- a/src/libsensord/CMakeLists.txt +++ b/src/libsensord/CMakeLists.txt @@ -56,6 +56,7 @@ install(FILES sensor_linear_accel.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sens install(FILES sensor_orientation.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) install(FILES sensor_rv.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) install(FILES sensor_geomagnetic_rv.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) +install(FILES sensor_gaming_rv.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) install(FILES sensor_temperature.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) install(FILES sensor_motion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) install(FILES sensor_deprecated.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) -- 2.7.4 From 9e537f46b7a6efee960bd17d4a06e19c738bec60 Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Mon, 2 Mar 2015 13:00:08 +0530 Subject: [PATCH 13/16] Updating documentation code for gaming_rv and geomagnetic_rv Updating/correcting documentation code in api for gaming_rv and geomagnetic_rv sensors Change-Id: I286b82a8931a6922c4c8d9aeeca9749c23b4e51c --- src/libsensord/sensor_gaming_rv.h | 2 +- src/libsensord/sensor_geomagnetic_rv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsensord/sensor_gaming_rv.h b/src/libsensord/sensor_gaming_rv.h index e290313..a02f738 100755 --- a/src/libsensord/sensor_gaming_rv.h +++ b/src/libsensord/sensor_gaming_rv.h @@ -11,7 +11,7 @@ extern "C" #endif /** - * @defgroup SENSOR_GEOMAGNETIC_RV Rotation Vector Sensor + * @defgroup SENSOR_GAMING_RV Gaming Rotation Vector Sensor * @ingroup SENSOR_FRAMEWORK * * These APIs are used to control the Gaming Rotation Vector sensor. diff --git a/src/libsensord/sensor_geomagnetic_rv.h b/src/libsensord/sensor_geomagnetic_rv.h index 8343a42..c0fc830 100755 --- a/src/libsensord/sensor_geomagnetic_rv.h +++ b/src/libsensord/sensor_geomagnetic_rv.h @@ -29,7 +29,7 @@ extern "C" #endif /** - * @defgroup SENSOR_GEOMAGNETIC_RV Rotation Vector Sensor + * @defgroup SENSOR_GEOMAGNETIC_RV Geomagnetic Rotation Vector Sensor * @ingroup SENSOR_FRAMEWORK * * These APIs are used to control the Geomagnetic Rotation Vector sensor. -- 2.7.4 From cd6e49282798d3c643e488c9bc9e2b869fbe3d8a Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Mon, 2 Mar 2015 15:57:24 +0530 Subject: [PATCH 14/16] Adding methods for common sensor_fusion flow - Adding new methods for a common orientation computation flow irrespective of the sensors used in the inputs - Changing sensor inputs to pointers for checking if inputs are enabled. - Tested on rotation_matrix functionality which is not used in any virtual sensor and using standalone test code. Change-Id: I763305f06346db2cce87c61e870c0a43f0d1e0e0 --- src/sensor_fusion/orientation_filter.cpp | 66 +++++++++++++++++++++- src/sensor_fusion/orientation_filter.h | 8 ++- src/sensor_fusion/test/orientation_sensor.cpp | 38 ++++++------- src/sensor_fusion/test/orientation_sensor.h | 4 +- .../orientation_sensor_main.cpp | 2 +- 5 files changed, 91 insertions(+), 27 deletions(-) diff --git a/src/sensor_fusion/orientation_filter.cpp b/src/sensor_fusion/orientation_filter.cpp index 68f0431..03e50d6 100644 --- a/src/sensor_fusion/orientation_filter.cpp +++ b/src/sensor_fusion/orientation_filter.cpp @@ -75,6 +75,38 @@ orientation_filter::~orientation_filter() } template +inline void orientation_filter::initialize_sensor_data(const sensor_data *accel, + const sensor_data *gyro, const sensor_data *magnetic) +{ + if (accel != NULL) { + m_accel.m_data = accel->m_data; + m_accel.m_time_stamp = accel->m_time_stamp; + + normalize(m_accel); + } + + if (gyro != NULL) { + unsigned long long sample_interval_gyro = SAMPLE_INTV; + + if (m_gyro.m_time_stamp != 0 && gyro->m_time_stamp != 0) + sample_interval_gyro = gyro->m_time_stamp - m_gyro.m_time_stamp; + + m_gyro_dt = sample_interval_gyro * US2S; + m_gyro.m_time_stamp = gyro->m_time_stamp; + + m_gyro.m_data = m_gyro.m_data * (TYPE) PI; + + m_gyro.m_data = gyro->m_data - m_bias_correction; + } + + if (magnetic != NULL) { + m_magnetic.m_data = magnetic->m_data; + m_magnetic.m_time_stamp = magnetic->m_time_stamp; + } + +} + +template inline void orientation_filter::init_accel_gyro_mag_data(const sensor_data accel, const sensor_data gyro, const sensor_data magnetic) { @@ -104,6 +136,8 @@ inline void orientation_filter::init_accel_mag_data(const sensor_data @@ -381,6 +415,32 @@ inline void orientation_filter::measurement_update() } template +euler_angles orientation_filter::get_device_rotation(const sensor_data *accel, + const sensor_data *gyro, const sensor_data *magnetic) +{ + initialize_sensor_data(accel, gyro, magnetic); + + const sensor_data accel_in, gyro_in, magnetic_in; + euler_angles cor_euler_ang; + + if (magnetic != NULL) + orientation_triad_algorithm(); + + if (gyro != NULL) { + compute_covariance(); + + if(magnetic != NULL) + time_update(); + else + time_update_gaming_rv(); + + measurement_update(); + } + + return m_orientation; +} + +template euler_angles orientation_filter::get_orientation(const sensor_data accel, const sensor_data gyro, const sensor_data magnetic) { @@ -404,10 +464,10 @@ euler_angles orientation_filter::get_orientation(const sensor_data -rotation_matrix orientation_filter::get_rotation_matrix(const sensor_data accel, - const sensor_data gyro, const sensor_data magnetic) +rotation_matrix orientation_filter::get_rotation_matrix(const sensor_data *accel, + const sensor_data *gyro, const sensor_data *magnetic) { - get_orientation(accel, gyro, magnetic); + get_device_rotation(accel, gyro, magnetic); return m_rot_matrix; } diff --git a/src/sensor_fusion/orientation_filter.h b/src/sensor_fusion/orientation_filter.h index a04f3f7..97d372f 100644 --- a/src/sensor_fusion/orientation_filter.h +++ b/src/sensor_fusion/orientation_filter.h @@ -74,6 +74,8 @@ public: orientation_filter(); ~orientation_filter(); + inline void initialize_sensor_data(const sensor_data *accel, + const sensor_data *gyro, const sensor_data *magnetic); inline void init_accel_gyro_mag_data(const sensor_data accel, const sensor_data gyro, const sensor_data magnetic); inline void init_accel_mag_data(const sensor_data accel, @@ -89,14 +91,16 @@ public: euler_angles get_orientation(const sensor_data accel, const sensor_data gyro, const sensor_data magnetic); - rotation_matrix get_rotation_matrix(const sensor_data accel, - const sensor_data gyro, const sensor_data magnetic); + rotation_matrix get_rotation_matrix(const sensor_data *accel, + const sensor_data *gyro, const sensor_data *magnetic); quaternion get_9axis_quaternion(const sensor_data accel, const sensor_data gyro, const sensor_data magnetic); quaternion get_geomagnetic_quaternion(const sensor_data accel, const sensor_data magnetic); quaternion get_gaming_quaternion(const sensor_data accel, const sensor_data gyro); + euler_angles get_device_rotation(const sensor_data *accel, + const sensor_data *gyro, const sensor_data *magnetic); }; #include "orientation_filter.cpp" diff --git a/src/sensor_fusion/test/orientation_sensor.cpp b/src/sensor_fusion/test/orientation_sensor.cpp index 70746f5..30c74c7 100644 --- a/src/sensor_fusion/test/orientation_sensor.cpp +++ b/src/sensor_fusion/test/orientation_sensor.cpp @@ -34,23 +34,23 @@ int roll_phase_compensation = -1; int azimuth_phase_compensation = -1; int magnetic_alignment_factor = -1; -void pre_process_data(sensor_data &data_out, sensor_data &data_in, float *bias, int *sign, float scale) +void pre_process_data(sensor_data *data_out, sensor_data *data_in, float *bias, int *sign, float scale) { - data_out.m_data.m_vec[0] = sign[0] * (data_in.m_data.m_vec[0] - bias[0]) / scale; - data_out.m_data.m_vec[1] = sign[1] * (data_in.m_data.m_vec[1] - bias[1]) / scale; - data_out.m_data.m_vec[2] = sign[2] * (data_in.m_data.m_vec[2] - bias[2]) / scale; + data_out->m_data.m_vec[0] = sign[0] * (data_in->m_data.m_vec[0] - bias[0]) / scale; + data_out->m_data.m_vec[1] = sign[1] * (data_in->m_data.m_vec[1] - bias[1]) / scale; + data_out->m_data.m_vec[2] = sign[2] * (data_in->m_data.m_vec[2] - bias[2]) / scale; - data_out.m_time_stamp = data_in.m_time_stamp; + data_out->m_time_stamp = data_in->m_time_stamp; } euler_angles orientation_sensor::get_orientation(sensor_data accel_data, sensor_data gyro_data, sensor_data magnetic_data) { - pre_process_data(accel_data, accel_data, bias_accel, sign_accel, scale_accel); + pre_process_data(&accel_data, &accel_data, bias_accel, sign_accel, scale_accel); normalize(accel_data); - pre_process_data(gyro_data, gyro_data, bias_gyro, sign_gyro, scale_gyro); - pre_process_data(magnetic_data, magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic); + pre_process_data(&gyro_data, &gyro_data, bias_gyro, sign_gyro, scale_gyro); + pre_process_data(&magnetic_data, &magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic); normalize(magnetic_data); orien_filter.m_pitch_phase_compensation = pitch_phase_compensation; @@ -61,14 +61,14 @@ euler_angles orientation_sensor::get_orientation(sensor_data accel return orien_filter.get_orientation(accel_data, gyro_data, magnetic_data); } -rotation_matrix orientation_sensor::get_rotation_matrix(sensor_data accel_data, - sensor_data gyro_data, sensor_data magnetic_data) +rotation_matrix orientation_sensor::get_rotation_matrix(sensor_data *accel_data, + sensor_data *gyro_data, sensor_data *magnetic_data) { pre_process_data(accel_data, accel_data, bias_accel, sign_accel, scale_accel); - normalize(accel_data); + normalize(*accel_data); pre_process_data(gyro_data, gyro_data, bias_gyro, sign_gyro, scale_gyro); pre_process_data(magnetic_data, magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic); - normalize(magnetic_data); + normalize(*magnetic_data); orien_filter.m_pitch_phase_compensation = pitch_phase_compensation; orien_filter.m_roll_phase_compensation = roll_phase_compensation; @@ -81,10 +81,10 @@ rotation_matrix orientation_sensor::get_rotation_matrix(sensor_data orientation_sensor::get_9axis_quaternion(sensor_data accel_data, sensor_data gyro_data, sensor_data magnetic_data) { - pre_process_data(accel_data, accel_data, bias_accel, sign_accel, scale_accel); + pre_process_data(&accel_data, &accel_data, bias_accel, sign_accel, scale_accel); normalize(accel_data); - pre_process_data(gyro_data, gyro_data, bias_gyro, sign_gyro, scale_gyro); - pre_process_data(magnetic_data, magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic); + pre_process_data(&gyro_data, &gyro_data, bias_gyro, sign_gyro, scale_gyro); + pre_process_data(&magnetic_data, &magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic); normalize(magnetic_data); orien_filter.m_pitch_phase_compensation = pitch_phase_compensation; @@ -98,9 +98,9 @@ quaternion orientation_sensor::get_9axis_quaternion(sensor_data ac quaternion orientation_sensor::get_geomagnetic_quaternion(sensor_data accel_data, sensor_data magnetic_data) { - pre_process_data(accel_data, accel_data, bias_accel, sign_accel, scale_accel); + pre_process_data(&accel_data, &accel_data, bias_accel, sign_accel, scale_accel); normalize(accel_data); - pre_process_data(magnetic_data, magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic); + pre_process_data(&magnetic_data, &magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic); normalize(magnetic_data); return orien_filter.get_geomagnetic_quaternion(accel_data, magnetic_data); @@ -110,9 +110,9 @@ quaternion orientation_sensor::get_geomagnetic_quaternion(sensor_data orientation_sensor::get_gaming_quaternion(sensor_data accel_data, sensor_data gyro_data) { - pre_process_data(accel_data, accel_data, bias_accel, sign_accel, scale_accel); + pre_process_data(&accel_data, &accel_data, bias_accel, sign_accel, scale_accel); normalize(accel_data); - pre_process_data(gyro_data, gyro_data, bias_gyro, sign_gyro, scale_gyro); + pre_process_data(&gyro_data, &gyro_data, bias_gyro, sign_gyro, scale_gyro); return orien_filter.get_gaming_quaternion(accel_data, gyro_data); } diff --git a/src/sensor_fusion/test/orientation_sensor.h b/src/sensor_fusion/test/orientation_sensor.h index 358c476..5afbff4 100644 --- a/src/sensor_fusion/test/orientation_sensor.h +++ b/src/sensor_fusion/test/orientation_sensor.h @@ -29,8 +29,8 @@ public: euler_angles get_orientation(sensor_data accel, sensor_data gyro, sensor_data magnetic); - rotation_matrix get_rotation_matrix(sensor_data accel, - sensor_data gyro, sensor_data magnetic); + rotation_matrix get_rotation_matrix(sensor_data *accel, + sensor_data *gyro, sensor_data *magnetic); quaternion get_9axis_quaternion(sensor_data accel, sensor_data gyro, sensor_data magnetic); quaternion get_geomagnetic_quaternion(sensor_data accel, diff --git a/src/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp b/src/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp index c5593e9..8e6830b 100644 --- a/src/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp +++ b/src/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp @@ -85,7 +85,7 @@ int main() cout << "Orientation angles\t" << orientation.m_ang << "\n\n"; - orientation_mat = orien_sensor2.get_rotation_matrix(accel_data, gyro_data, magnetic_data); + orientation_mat = orien_sensor2.get_rotation_matrix(&accel_data, &gyro_data, &magnetic_data); cout << "Orientation matrix\t" << orientation_mat.m_rot_mat << "\n\n"; -- 2.7.4 From f93997c0b689240dd732d717c738f82554400534 Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Mon, 2 Mar 2015 17:05:23 +0530 Subject: [PATCH 15/16] Fixing return type issue in tc-common - Changing unsigned int to int for event variables and fixing warning. - cleanup Change-Id: I76c30ee886352e194f78ef40c245ab2989244972 --- test/src/tc-common.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/src/tc-common.c b/test/src/tc-common.c index ce39702..8606165 100644 --- a/test/src/tc-common.c +++ b/test/src/tc-common.c @@ -59,7 +59,7 @@ void usage() printf("The time interval should be entered based on the sampling frequency supported by accelerometer driver on the device in ms.If no value for sensor is entered default value by the driver will be used.\n"); } -unsigned int get_event_driven(sensor_type_t sensor_type, char str[]) +int get_event_driven(sensor_type_t sensor_type, char str[]) { switch (sensor_type) { case ACCELEROMETER_SENSOR: @@ -114,9 +114,9 @@ unsigned int get_event_driven(sensor_type_t sensor_type, char str[]) if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) return GAMING_RV_RAW_DATA_EVENT; break; - default: - return -1; } + + return -1; } void callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data) @@ -125,43 +125,43 @@ void callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, voi switch (sensor_type) { case ACCELEROMETER_SENSOR: - printf("Accelerometer [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]); + printf("Accelerometer [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]); break; case GYROSCOPE_SENSOR: - printf("Gyroscope [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]); + printf("Gyroscope [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]); break; case PRESSURE_SENSOR: - printf("Pressure [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]); + printf("Pressure [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]); break; case GEOMAGNETIC_SENSOR: - printf("Geomagnetic [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]); + printf("Geomagnetic [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]); break; case LIGHT_SENSOR: - printf("Light [%lld] [%6.6f]\n\n", data->timestamp, data->values[0]); + printf("Light [%lld] [%6.6f]\n", data->timestamp, data->values[0]); break; case TEMPERATURE_SENSOR : - printf("Temperature [%lld] [%6.6f]\n\n", data->timestamp, data->values[0]); + printf("Temperature [%lld] [%6.6f]\n", data->timestamp, data->values[0]); break; case PROXIMITY_SENSOR: - printf("Proximity [%lld] [%6.6f]\n\n", data->timestamp, data->values[0]); + printf("Proximity [%lld] [%6.6f]\n", data->timestamp, data->values[0]); break; case ORIENTATION_SENSOR : - printf("Orientation [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]); + printf("Orientation [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]); break; case GRAVITY_SENSOR: - printf("Gravity [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]); + printf("Gravity [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]); break; case LINEAR_ACCEL_SENSOR: - printf("Linear acceleration [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]); + printf("Linear acceleration [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]); break; case ROTATION_VECTOR_SENSOR: - printf("Rotation vector [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]); + printf("Rotation vector [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]); break; case GEOMAGNETIC_RV_SENSOR: - printf("Geomagnetic RV [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]); + printf("Geomagnetic RV [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]); break; case GAMING_RV_SENSOR: - printf("Gaming RV [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]); + printf("Gaming RV [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]); break; default: return; @@ -172,7 +172,7 @@ int main(int argc, char **argv) { int result, handle, start_handle, stop_handle, interval; char *end1, *end2; - unsigned int event; + int event; bool EVENT_NOT_ENTERED = TRUE; sensor_type_t sensor_type; mainloop = g_main_loop_new(NULL, FALSE); -- 2.7.4 From f5c62e1096393da4ea88a603705a22e4e77a09a0 Mon Sep 17 00:00:00 2001 From: Ramasamy Date: Mon, 2 Mar 2015 17:26:40 +0530 Subject: [PATCH 16/16] Changing orientation sensor to follow single sensor fusion flow - Updating orientation sensor to work on common single sensor fusion code flow. Change-Id: I5581e833e33757a0e24d56a90717473bded3e172 --- src/orientation/orientation_sensor.cpp | 4 ++-- src/sensor_fusion/orientation_filter.cpp | 25 ++++------------------ src/sensor_fusion/orientation_filter.h | 4 ++-- src/sensor_fusion/test/orientation_sensor.cpp | 14 ++++++------ src/sensor_fusion/test/orientation_sensor.h | 4 ++-- .../orientation_sensor_main.cpp | 2 +- 6 files changed, 18 insertions(+), 35 deletions(-) diff --git a/src/orientation/orientation_sensor.cpp b/src/orientation/orientation_sensor.cpp index 0c8bed3..900a7c0 100755 --- a/src/orientation/orientation_sensor.cpp +++ b/src/orientation/orientation_sensor.cpp @@ -339,7 +339,7 @@ void orientation_sensor::synthesize(const sensor_event_t &event, vector orientation_filter::get_device_rotation(const sensor_da { initialize_sensor_data(accel, gyro, magnetic); - const sensor_data accel_in, gyro_in, magnetic_in; - euler_angles cor_euler_ang; - if (magnetic != NULL) orientation_triad_algorithm(); @@ -441,24 +438,10 @@ euler_angles orientation_filter::get_device_rotation(const sensor_da } template -euler_angles orientation_filter::get_orientation(const sensor_data accel, - const sensor_data gyro, const sensor_data magnetic) +euler_angles orientation_filter::get_orientation(const sensor_data *accel, + const sensor_data *gyro, const sensor_data *magnetic) { - euler_angles cor_euler_ang; - - init_accel_gyro_mag_data(accel, gyro, magnetic); - - normalize(m_accel); - m_gyro.m_data = m_gyro.m_data * (TYPE) PI; - normalize(m_magnetic); - - orientation_triad_algorithm(); - - compute_covariance(); - - time_update(); - - measurement_update(); + get_device_rotation(accel, gyro, magnetic); return m_orientation; } @@ -477,7 +460,7 @@ quaternion orientation_filter::get_9axis_quaternion(const sensor_dat const sensor_data gyro, const sensor_data magnetic) { - get_orientation(accel, gyro, magnetic); + get_orientation(&accel, &gyro, &magnetic); return m_quat_9axis; } diff --git a/src/sensor_fusion/orientation_filter.h b/src/sensor_fusion/orientation_filter.h index 97d372f..08add8a 100644 --- a/src/sensor_fusion/orientation_filter.h +++ b/src/sensor_fusion/orientation_filter.h @@ -89,8 +89,8 @@ public: inline void time_update_gaming_rv(); inline void measurement_update(); - euler_angles get_orientation(const sensor_data accel, - const sensor_data gyro, const sensor_data magnetic); + euler_angles get_orientation(const sensor_data *accel, + const sensor_data *gyro, const sensor_data *magnetic); rotation_matrix get_rotation_matrix(const sensor_data *accel, const sensor_data *gyro, const sensor_data *magnetic); quaternion get_9axis_quaternion(const sensor_data accel, diff --git a/src/sensor_fusion/test/orientation_sensor.cpp b/src/sensor_fusion/test/orientation_sensor.cpp index 30c74c7..57b6393 100644 --- a/src/sensor_fusion/test/orientation_sensor.cpp +++ b/src/sensor_fusion/test/orientation_sensor.cpp @@ -43,15 +43,15 @@ void pre_process_data(sensor_data *data_out, sensor_data *data_in, data_out->m_time_stamp = data_in->m_time_stamp; } -euler_angles orientation_sensor::get_orientation(sensor_data accel_data, - sensor_data gyro_data, sensor_data magnetic_data) +euler_angles orientation_sensor::get_orientation(sensor_data *accel_data, + sensor_data *gyro_data, sensor_data *magnetic_data) { - pre_process_data(&accel_data, &accel_data, bias_accel, sign_accel, scale_accel); - normalize(accel_data); - pre_process_data(&gyro_data, &gyro_data, bias_gyro, sign_gyro, scale_gyro); - pre_process_data(&magnetic_data, &magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic); - normalize(magnetic_data); + pre_process_data(accel_data, accel_data, bias_accel, sign_accel, scale_accel); + normalize(*accel_data); + pre_process_data(gyro_data, gyro_data, bias_gyro, sign_gyro, scale_gyro); + pre_process_data(magnetic_data, magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic); + normalize(*magnetic_data); orien_filter.m_pitch_phase_compensation = pitch_phase_compensation; orien_filter.m_roll_phase_compensation = roll_phase_compensation; diff --git a/src/sensor_fusion/test/orientation_sensor.h b/src/sensor_fusion/test/orientation_sensor.h index 5afbff4..dab0677 100644 --- a/src/sensor_fusion/test/orientation_sensor.h +++ b/src/sensor_fusion/test/orientation_sensor.h @@ -27,8 +27,8 @@ class orientation_sensor public: orientation_filter orien_filter; - euler_angles get_orientation(sensor_data accel, - sensor_data gyro, sensor_data magnetic); + euler_angles get_orientation(sensor_data *accel, + sensor_data *gyro, sensor_data *magnetic); rotation_matrix get_rotation_matrix(sensor_data *accel, sensor_data *gyro, sensor_data *magnetic); quaternion get_9axis_quaternion(sensor_data accel, diff --git a/src/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp b/src/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp index 8e6830b..a4e7da1 100644 --- a/src/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp +++ b/src/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp @@ -79,7 +79,7 @@ int main() cout << "Magnetic Data\t" << magnetic_data.m_data << "\t Time Stamp\t" << magnetic_data.m_time_stamp << "\n\n"; - orientation = orien_sensor1.get_orientation(accel_data, gyro_data, magnetic_data); + orientation = orien_sensor1.get_orientation(&accel_data, &gyro_data, &magnetic_data); orien_file << orientation.m_ang; -- 2.7.4