Merge "Adding polling based test functionality for sensors" into tizen
authorMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 11 May 2015 07:28:21 +0000 (00:28 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Mon, 11 May 2015 07:28:21 +0000 (00:28 -0700)
src/fusion/fusion_sensor.cpp
src/sensor_fusion/orientation_filter.cpp
src/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp
test/src/api-test.c
virtual_sensors.xml

index fa80416..0bac151 100755 (executable)
@@ -195,12 +195,17 @@ bool fusion_sensor::init(void)
        m_gyro_sensor = sensor_plugin_loader::get_instance().get_sensor(GYROSCOPE_SENSOR);
        m_magnetic_sensor = sensor_plugin_loader::get_instance().get_sensor(GEOMAGNETIC_SENSOR);
 
-       if (!m_accel_sensor || !m_gyro_sensor || !m_magnetic_sensor) {
-               ERR("Failed to load sensors,  accel: 0x%x, gyro: 0x%x, mag: 0x%x",
-                       m_accel_sensor, m_gyro_sensor, m_magnetic_sensor);
+       if (!m_accel_sensor) {
+               ERR("Failed to load accel sensor: 0x%x", m_accel_sensor);
                return false;
        }
 
+       if (!m_gyro_sensor)
+               INFO("Failed to load gyro sensor: 0x%x", m_gyro_sensor);
+
+       if (!m_magnetic_sensor)
+               INFO("Failed to load geomagnetic sensor: 0x%x", m_magnetic_sensor);
+
        INFO("%s is created!", sensor_base::get_name());
        return true;
 }
@@ -353,7 +358,6 @@ int fusion_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t
        sensor_data_t magnetic_data;
 
        euler_angles<float> euler_orientation;
-       float azimuth_offset;
 
        if (event_type != FUSION_ORIENTATION_ENABLED ||
                        event_type != FUSION_ROTATION_VECTOR_ENABLED ||
index 5aa4968..ae88a46 100644 (file)
@@ -359,29 +359,35 @@ void orientation_filter<TYPE>::get_device_orientation(const sensor_data<TYPE> *a
 {
        initialize_sensor_data(accel, gyro, magnetic);
 
-       if (magnetic != NULL)
+       if (gyro != NULL && magnetic != NULL) {
+
                orientation_triad_algorithm();
-       else if (gyro != NULL)
-               compute_accel_orientation();
 
-       if (gyro != NULL) {
                compute_covariance();
 
-               if (magnetic != NULL)
-                       time_update();
-               else
-                       time_update_gaming_rv();
+               time_update();
 
                measurement_update();
 
-               if (magnetic == NULL) {
-                       m_quaternion = m_quat_gaming_rv;
-               } else {
-                       m_quaternion = m_quat_9axis;
-               }
+               m_quaternion = m_quat_9axis;
+
+       } else if (!gyro) {
+
+               orientation_triad_algorithm();
 
-       } else {
                m_quaternion = m_quat_aid;
+
+       } else if (!magnetic) {
+
+               compute_accel_orientation();
+
+               compute_covariance();
+
+               time_update_gaming_rv();
+
+               measurement_update();
+
+               m_quaternion = m_quat_gaming_rv;
        }
 }
 
index a35a6ce..2710332 100644 (file)
@@ -90,7 +90,7 @@ int main()
 
                orientation.m_ang.m_vec[0] *= pitch_phase_compensation;
                orientation.m_ang.m_vec[1] *= roll_phase_compensation;
-               orientation.m_ang.m_vec[2] *= azimuth_phase_compensation; 
+               orientation.m_ang.m_vec[2] *= azimuth_phase_compensation;
 
                if (orientation.m_ang.m_vec[2] < 0)
                        orientation.m_ang.m_vec[2] += 360;
index 67f5319..0ecea23 100644 (file)
@@ -31,7 +31,7 @@
 static GMainLoop *mainloop;
 FILE *fp;
 
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
+void callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data)
 {
        g_main_loop_quit(mainloop);
 }
index 8371d60..3210e4f 100755 (executable)
                        <DEFAULT_SAMPLING_TIME value="100" />
                </GAMING_ROTATION_VECTOR>
        </DEVICE>
-       
+
        <DEVICE type="Mobile-RD-PQ_V2">
                <FUSION>
                        <NAME value="FUSION_SENSOR" />