+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- *
- */
-
-#ifdef _GRAVITY_SENSOR_H_
-
-#define GRAVITY 9.80665
-
-sensor_data<float> gravity_sensor::get_gravity(const sensor_data<float> accel,
- const sensor_data<float> gyro, const sensor_data<float> magnetic)
-{
- euler_angles<float> orientation;
- sensor_data<float> gravity;
-
- orientation = orien_sensor.get_orientation(accel, gyro, magnetic);
-
- gravity.m_data.m_vec[0] = GRAVITY * sin(orientation.m_ang.m_vec[0]);
- gravity.m_data.m_vec[1] = GRAVITY * sin(orientation.m_ang.m_vec[1]);
- gravity.m_data.m_vec[2] = GRAVITY * cos(orientation.m_ang.m_vec[0]) *
- cos(orientation.m_ang.m_vec[1]);
-
- return gravity;
-}
-
-#endif
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 _GRAVITY_SENSOR_H_
-#define _GRAVITY_SENSOR_H_
-
-#include "orientation_sensor.h"
-
-class gravity_sensor
-{
-public:
- orientation_sensor orien_sensor;
-
- sensor_data<float> get_gravity(const sensor_data<float> accel,
- const sensor_data<float> gyro, const sensor_data<float> magnetic);
-};
-
-#include "gravity_sensor.cpp"
-
-#endif /* _GRAVITY_SENSOR_H_ */
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- *
- */
-
-#ifdef _LINEAR_ACCELERATION_SENSOR_H_
-
-sensor_data<float> linear_acceleration_sensor::get_linear_acceleration(const sensor_data<float> accel,
- const sensor_data<float> gyro, const sensor_data<float> magnetic)
-{
- sensor_data<float> gravity_data;
- float la_x, la_y, la_z;
-
- gravity_data = grav_sensor.get_gravity(accel, gyro, magnetic);
-
- la_x = accel.m_data.m_vec[0] - gravity_data.m_data.m_vec[1];
- la_y = accel.m_data.m_vec[1] - gravity_data.m_data.m_vec[0];
- la_z = accel.m_data.m_vec[2] - gravity_data.m_data.m_vec[2];
-
- sensor_data<float> lin_accel_data(la_x, la_y, la_z);
-
- return lin_accel_data;
-}
-
-#endif
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 _LINEAR_ACCELERATION_SENSOR_H_
-#define _LINEAR_ACCELERATION_SENSOR_H_
-
-#include "gravity_sensor.h"
-
-class linear_acceleration_sensor
-{
-public:
- gravity_sensor grav_sensor;
-
- sensor_data<float> get_linear_acceleration(const sensor_data<float> accel,
- const sensor_data<float> gyro, const sensor_data<float> magnetic);
-};
-
-#include "linear_acceleration_sensor.cpp"
-
-#endif /* _LINEAR_ACCELERATION_SENSOR_H_ */
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- *
- */
-
-#ifdef _ORIENTATION_SENSOR_H_
-
-float bias_accel[] = {0.098586, 0.18385, (10.084 - GRAVITY)};
-float bias_gyro[] = {-5.3539, 0.24325, 2.3391};
-float bias_magnetic[] = {0, 0, 0};
-int sign_accel[] = {+1, +1, +1};
-int sign_gyro[] = {+1, +1, +1};
-int sign_magnetic[] = {+1, +1, +1};
-float scale_accel = 1;
-float scale_gyro = 1150;
-float scale_magnetic = 1;
-int magnetic_alignment_factor = -1;
-
-void orientation_sensor::get_device_orientation(sensor_data<float> *accel_data,
- sensor_data<float> *gyro_data, sensor_data<float> *magnetic_data)
-{
- vect<float, 3> vec_bias_gyro(bias_gyro);
-
- pre_process_data(accel_data, accel_data, bias_accel, sign_accel, scale_accel);
- normalize(*accel_data);
-
- if (gyro_data != NULL) {
- pre_process_data(gyro_data, gyro_data, bias_gyro, sign_gyro, scale_gyro);
- }
-
- if (magnetic_data != NULL) {
- pre_process_data(magnetic_data, magnetic_data, bias_magnetic, sign_magnetic, scale_magnetic);
- normalize(*magnetic_data);
- }
-
- orien_filter.get_device_orientation(accel_data, gyro_data, magnetic_data);
-}
-
-#endif /* _ORIENTATION_SENSOR_H_ */
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 _ORIENTATION_SENSOR_H_
-#define _ORIENTATION_SENSOR_H_
-
-#include "../orientation_filter.h"
-
-class orientation_sensor
-{
-public:
- orientation_filter<float> orien_filter;
-
- void get_device_orientation(sensor_data<float> *accel,
- sensor_data<float> *gyro, sensor_data<float> *magnetic);
-};
-
-#include "orientation_sensor.cpp"
-
-#endif /* _ORIENTATION_SENSOR_H_ */
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 "../../../euler_angles.h"
-
-int main()
-{
- float arr0[3] = {234.98, 345.24, -56.12};
- float arr1[3] = {56, -34, 76};
- float arr2[4] = {0.6, 0.6, -.18, -.44};
- float arr3[4] = {-0.5, -0.36, .43, .03};
-
- vect<float, 3> v0(arr0);
- vect<float, 3> v1(arr1);
- vect<float, 4> v2(arr2);
- vect<float, 4> v3(arr3);
-
- quaternion<float> q1(v2);
- quaternion<float> q2(v3);
-
- euler_angles<float> e0(v0);
- euler_angles<float> e1(v1);
- euler_angles<float> e2((float)234.98, (float)345.24, (float)-56.12);
- euler_angles<float> e3(e1);
- euler_angles<float> e4;
-
- cout << "Constructor tests\n";
- cout << "input\t" << v0 << "\n";
- cout << "output\t" << e0.m_ang << "\n\n";
- cout << "input\t" << v1 << "\n";
- cout << "output\t" << e1.m_ang << "\n\n";
- cout << "input\t" << v0 << "\n";
- cout << "output\t" << e2.m_ang << "\n\n";
- cout << "input\t" << v1 << "\n";
- cout << "output\t" << e3.m_ang << "\n\n";
- cout << "default constructor\n";
- cout << "output\t" << e4.m_ang << "\n\n";
-
- cout << "Quaternion to Euler\n";
- euler_angles<float> e5 = quat2euler(q1);
- cout << "input\t" << q1.m_quat << "\n";
- cout << "output\t" << e5.m_ang << "\n\n";
- euler_angles<float> e8 = quat2euler(q2);
- cout << "input\t" << q2.m_quat << "\n";
- cout << "output\t" << e8.m_ang << "\n\n";
-
- cout << "Euler to Quaternion\n";
- quaternion<float> q3 = euler2quat(e8);
- cout << "input\t" << e8.m_ang << "\n";
- cout << "output\t" << q3.m_quat << "\n\n";
-
- cout << "Radians to Degrees\n";
- euler_angles<float> e6 = deg2rad(e0);
- cout << "input\t" << e0.m_ang << "\n";
- cout << "output\t" << e6.m_ang << "\n\n";
-
- cout << "Degrees to Radians\n";
- euler_angles<float> e7 = rad2deg(e6);
- cout << "input\t" << e6.m_ang << "\n";
- cout << "output\t" << e7.m_ang << "\n\n";
-}
-
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 "../../gravity_sensor.h"
-#include <stdlib.h>
-#include <iostream>
-#include <fstream>
-#include <string>
-using namespace std;
-
-#define GRAVITY_DATA_PATH "../../../design/data/100ms/gravity/throw/"
-#define GRAVITY_DATA_SIZE 135
-
-int main()
-{
- int data_available = GRAVITY_DATA_SIZE;
- ifstream accel_in, gyro_in, mag_in;
- ofstream gravity_file;
- string line_accel, line_gyro, line_magnetic;
- float sdata[3];
- unsigned long long time_stamp;
- sensor_data<float> gravity;
- gravity_sensor grav_sensor;
-
- accel_in.open(((string)GRAVITY_DATA_PATH + (string)"accel.txt").c_str());
- gyro_in.open(((string)GRAVITY_DATA_PATH + (string)"gyro.txt").c_str());
- mag_in.open(((string)GRAVITY_DATA_PATH + (string)"magnetic.txt").c_str());
-
- gravity_file.open(((string)"gravity.txt").c_str());
-
- char *token = NULL;
-
- while (data_available-- > 0)
- {
- getline(accel_in, line_accel);
- sdata[0] = strtof(line_accel.c_str(), &token);
- sdata[1] = strtof(token, &token);
- sdata[2] = strtof(token, &token);
- time_stamp = strtoull(token, NULL, 10);
- sensor_data<float> accel_data(sdata[0], sdata[1], sdata[2], time_stamp);
-
- cout << "Accel Data\t" << accel_data.m_data << "\t Time Stamp\t" << accel_data.m_time_stamp << "\n\n";
-
- getline(gyro_in, line_gyro);
- sdata[0] = strtof(line_gyro.c_str(), &token);
- sdata[1] = strtof(token, &token);
- sdata[2] = strtof(token, &token);
- time_stamp = strtoull(token, NULL, 10);
- sensor_data<float> gyro_data(sdata[0], sdata[1], sdata[2], time_stamp);
-
- cout << "Gyro Data\t" << gyro_data.m_data << "\t Time Stamp\t" << gyro_data.m_time_stamp << "\n\n";
-
- getline(mag_in, line_magnetic);
- sdata[0] = strtof(line_magnetic.c_str(), &token);
- sdata[1] = strtof(token, &token);
- sdata[2] = strtof(token, &token);
- time_stamp = strtoull(token, NULL, 10);
- sensor_data<float> magnetic_data(sdata[0], sdata[1], sdata[2], time_stamp);
-
- cout << "Magnetic Data\t" << magnetic_data.m_data << "\t Time Stamp\t" << magnetic_data.m_time_stamp << "\n\n";
-
- gravity = grav_sensor.get_gravity(accel_data, gyro_data, magnetic_data);
-
- gravity_file << gravity.m_data;
-
- cout << "Gravity Data\t" << gravity.m_data << "\n\n";
- }
-
- accel_in.close();
- gyro_in.close();
- mag_in.close();
- gravity_file.close();
-
- return 0;
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 "../../linear_acceleration_sensor.h"
-#include <stdlib.h>
-#include <iostream>
-#include <fstream>
-#include <string>
-using namespace std;
-
-#define LA_DATA_PATH "../../../design/data/100ms/linear_acceleration/move_x_y_z/"
-#define LA_DATA_SIZE 170
-
-int main()
-{
- int data_available = LA_DATA_SIZE;
- ifstream accel_in, gyro_in, mag_in;
- ofstream la_file;
- string line_accel, line_gyro, line_magnetic;
- float sdata[3];
- unsigned long long time_stamp;
- sensor_data<float> lin_accel;
- linear_acceleration_sensor la_sensor;
-
- accel_in.open(((string)LA_DATA_PATH + (string)"accel.txt").c_str());
- gyro_in.open(((string)LA_DATA_PATH + (string)"gyro.txt").c_str());
- mag_in.open(((string)LA_DATA_PATH + (string)"magnetic.txt").c_str());
-
- la_file.open(((string)"linear_acceleration.txt").c_str());
-
- char *token = NULL;
-
- while (data_available-- > 0)
- {
- getline(accel_in, line_accel);
- sdata[0] = strtof(line_accel.c_str(), &token);
- sdata[1] = strtof(token, &token);
- sdata[2] = strtof(token, &token);
- time_stamp = strtoull(token, NULL, 10);
- sensor_data<float> accel_data(sdata[0], sdata[1], sdata[2], time_stamp);
-
- cout << "Accel Data\t" << accel_data.m_data << "\t Time Stamp\t" << accel_data.m_time_stamp << "\n\n";
-
- getline(gyro_in, line_gyro);
- sdata[0] = strtof(line_gyro.c_str(), &token);
- sdata[1] = strtof(token, &token);
- sdata[2] = strtof(token, &token);
- time_stamp = strtoull(token, NULL, 10);
- sensor_data<float> gyro_data(sdata[0], sdata[1], sdata[2], time_stamp);
-
- cout << "Gyro Data\t" << gyro_data.m_data << "\t Time Stamp\t" << gyro_data.m_time_stamp << "\n\n";
-
- getline(mag_in, line_magnetic);
- sdata[0] = strtof(line_magnetic.c_str(), &token);
- sdata[1] = strtof(token, &token);
- sdata[2] = strtof(token, &token);
- time_stamp = strtoull(token, NULL, 10);
- sensor_data<float> magnetic_data(sdata[0], sdata[1], sdata[2], time_stamp);
-
- cout << "Magnetic Data\t" << magnetic_data.m_data << "\t Time Stamp\t" << magnetic_data.m_time_stamp << "\n\n";
-
- lin_accel = la_sensor.get_linear_acceleration(accel_data, gyro_data, magnetic_data);
-
- la_file << lin_accel.m_data;
-
- cout << "Linear Acceleration Data\t" << lin_accel.m_data << "\n\n";
- }
-
- accel_in.close();
- gyro_in.close();
- mag_in.close();
- la_file.close();
-
- return 0;
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 "../../../matrix.h"
-
-int main()
-{
- float arr0[2][2] = {{-2.243, 2.57}, {3.56, -3.02}};
- float arr1[2][2] = {{2.2, 2.5}, {3.5, 3.0}};
- float arr5[3][2] = {{0.22, 4.56}, {3.652, 5.86}, {1.430, 0.45}};
- float arr11[1][3] = {{2.0, 3.0, 4.0}};
- float arr12[3][1] = {{2.0}, {1.0}, {3.0}};
- float arr15[2][3] = {{20.0, -40.0, 10.0}, {36.0, 52.0, -55.0}};
- float arr3[3][3] = {{20.2, 40.5, 10.0}, {3.6, 52.0, 5.5}, {1.0, 45.5, 66.6}};
- float arr4[3][3] = {{2.24, 0.5, 0.023}, {3.675, 5.32, 0.556}, {1.023, 45.75, 621.6}};
- float arr8[3][3] = {{4.75, 0.65, 0.123}, {0.075, 5.302, 0.56}, {1.113, 0.475, 2.362}};
- float arr9[3][3] = {{1, 2, 3}, {1, 2, 3}, {1, 2, 3}};
-
- matrix<float, 2, 2> m1(arr0);
- matrix<float, 2, 2> m2(arr1);
- matrix<float, 2, 2> m3;
- matrix<float, 3, 3> m10(arr3);
- matrix<float, 3, 2> m11(arr5);
- matrix<float, 3, 3> m6;
- matrix<float, 3, 2> m13;
- matrix<float, 3, 3> m12(arr4);
- matrix<float, 3, 3> m15(arr8);
- matrix<float, 1, 3> m20(arr11);
- matrix<float, 3, 1> m21(arr12);
- matrix<float, 2, 3> m22(arr15);
- matrix<float, 3, 3> m9(arr9);
-
- cout << "Constructor Test\n";
- cout << "\n" << m6;
-
- cout << "\n\nAddition\n";
- m6 = m10 + m15;
- m13 = m11 + m11;
- cout << "\n" << m10 << "\n" << m15;
- cout << "\nSum:\n" << m6 << endl;
- cout << "\n" << m11 << "\n" << m11;
- cout << "\nSum:\n" << m13 << endl;
-
- cout << "\n\n\nSubtraction\n";
- m6 = m10 - m12;
- cout << "\n" << m10 << "\n" << m12;
- cout << "\nDifference:\n" << m6 << endl;
-
- cout << "\n\n\nMultiplication\n";
- m6 = m10 * m12;
- m3 = m1 * m2;
- matrix<float, 1, 1> m7;
- m7 = m20 * m21;
- cout << "\n" << m10 << "\n" << m12;
- cout << "\nProduct:\n" << m6 << endl;
- cout << "\n" << m1 << "\n" << m2;
- cout << "\nProduct:\n" << m3 << endl;
- cout << "\n" << m20 << "\n" << m21;
- cout << "\nProduct:\n" << m7 << endl;
- cout << "\n" << m9 << "\n" << m21;
- m21 = m9 * m21;
- cout << "\nProduct:\n" << m21 << endl;
-
- cout << "\n\n\nDivision\n";
- m3 = m1 / (float)2.5;
- cout << "\n" << m1 << "\n" << "2.5";
- cout << "\nResult:\n" << m3 << endl;
- m6 = m12 / (float)0.125;
- cout << "\n" << m12 << "\n" << ".125";
- cout << "\nResult:\n" << m6 << endl;
-
- float num = 5.5650;
- float num1 = -2.32;
- cout << "\n\n\nScalar addition\n";
- m3 = m2 + num;
- m6 = m10 + num1;
- cout << "\nNumber added:" << num;
- cout << "\n\n" << m2;
- cout << "\nResult:\n\n" << m3;
- cout << "\nNumber added:" << num1;
- cout << "\n\n" << m10;
- cout << "\nResult:\n\n" << m6;
-
- float x = 4.0;
- float x1 = -2.5;
- cout << "\n\n\nScalar subtraction\n";
- m13 = m11 - x;
- m6 = m10 - x1;
- cout << "\nNumber Subtracted:" << x;
- cout << "\n\n" << m11;
- cout << "\nResult:\n\n" << m13;
- cout << "\nNumber Subtracted:" << x1;
- cout << "\n\n" << m10;
- cout << "\nResult:\n\n" << m6;
-
- float z = 3.50;
- float z1 = -5.567;
- cout << "\n\n\nScalar multiplication\n";
- m3 = m1 * z;
- m6 = m12 * z1;
- cout << "\nNumber Multiplied:" << z;
- cout << "\n\n" << m1;
- cout << "\nResult:\n\n" << m3;
- cout << "\nNumber Multiplied:" << z1;
- cout << "\n\n" << m12;
- cout << "\nResult:\n\n" << m6;
-
- m6 = tran(m15);
- cout << "\n\n\nTranspose:";
- cout << "\n\n" << m15;
- cout << "\nResult:\n\n" << m6;
-
- cout << "\n\nm1:\n\n" << m1;
- cout << "\n\nm2:\n\n" << m2;
- cout << "\n\n\nm1 == m2 :";
- cout << (m1 == m2);
-
- cout << "\n\nm2:\n\n" << m2;
- cout << "\n\nm2:\n\n" << m2;
- cout << "\n\n\nm2 == m2 :";
- cout << (m2 == m2);
-
- cout << "\n\nm6:\n\n" << m6;
- cout << "\n\nm6:\n\n" << m6;
- cout << "\n\n\nm6 != m6 :";
- cout << (m6 != m6);
-
- cout << "\n\nm6:\n\n" << m6;
- cout << "\n\nm1:\n\n" << m1;
- cout << "\n\n\nm6 != m1 :";
- cout << (m6 != m1);
-
-
- cout << "\n\nAssignment\n";
- matrix<float, 3, 3> m30 = m12;
- cout << "Input \n" << m12;
- cout << "\nOutput:\n" << m30 << endl;
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 "../../orientation_sensor.h"
-#include <stdlib.h>
-#include <iostream>
-#include <fstream>
-#include <string>
-using namespace std;
-
-#define ORIENTATION_DATA_PATH "../../../design/data/100ms/orientation/roll_pitch_yaw/"
-#define ORIENTATION_DATA_SIZE 1095
-int pitch_phase_compensation = -1;
-int roll_phase_compensation = -1;
-int azimuth_phase_compensation = -1;
-
-int main()
-{
- int data_available = ORIENTATION_DATA_SIZE;
- ifstream accel_in, gyro_in, mag_in;
- ofstream orien_file;
- string line_accel, line_gyro, line_magnetic;
- float sdata[3];
- unsigned long long time_stamp;
- euler_angles<float> orientation;
- rotation_matrix<float> orientation_mat;
- quaternion<float> orientation_9axis_quat;
- quaternion<float> orientation_geomagnetic_quat;
- quaternion<float> orientation_gaming_quat;
- orientation_sensor orien_sensor;
-
- accel_in.open(((string)ORIENTATION_DATA_PATH + (string)"accel.txt").c_str());
- gyro_in.open(((string)ORIENTATION_DATA_PATH + (string)"gyro.txt").c_str());
- mag_in.open(((string)ORIENTATION_DATA_PATH + (string)"magnetic.txt").c_str());
-
- orien_file.open(((string)"orientation.txt").c_str());
-
- char *token = NULL;
-
- while (data_available-- > 0)
- {
- getline(accel_in, line_accel);
- sdata[0] = strtof(line_accel.c_str(), &token);
- sdata[1] = strtof(token, &token);
- sdata[2] = strtof(token, &token);
- time_stamp = strtoull(token, NULL, 10);
- sensor_data<float> accel_data(sdata[0], sdata[1], sdata[2], time_stamp);
-
- cout << "Accel Data\t" << accel_data.m_data << "\t Time Stamp\t" << accel_data.m_time_stamp << "\n\n";
-
- getline(gyro_in, line_gyro);
- sdata[0] = strtof(line_gyro.c_str(), &token);
- sdata[1] = strtof(token, &token);
- sdata[2] = strtof(token, &token);
- time_stamp = strtoull(token, NULL, 10);
- sensor_data<float> gyro_data(sdata[0], sdata[1], sdata[2], time_stamp);
-
- cout << "Gyro Data\t" << gyro_data.m_data << "\t Time Stamp\t" << gyro_data.m_time_stamp << "\n\n";
-
- getline(mag_in, line_magnetic);
- sdata[0] = strtof(line_magnetic.c_str(), &token);
- sdata[1] = strtof(token, &token);
- sdata[2] = strtof(token, &token);
- time_stamp = strtoull(token, NULL, 10);
- sensor_data<float> magnetic_data(sdata[0], sdata[1], sdata[2], time_stamp);
-
- cout << "Magnetic Data\t" << magnetic_data.m_data << "\t Time Stamp\t" << magnetic_data.m_time_stamp << "\n\n";
-
- orien_sensor.get_device_orientation(&accel_data, &gyro_data, &magnetic_data);
-
- orientation = orien_sensor.orien_filter.m_orientation;
-
- cout << "Gyro Bias in radians\t" << orien_sensor.orien_filter.m_gyro_bias;
-
- orientation = rad2deg(orientation);
-
- 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;
-
- if (orientation.m_ang.m_vec[2] < 0)
- orientation.m_ang.m_vec[2] += 360;
-
- orien_file << orientation.m_ang;
-
- orientation = orien_sensor.orien_filter.m_orientation;
-
- cout << "Orientation angles\t" << orientation.m_ang << "\n\n";
-
- cout << "Orientation matrix\t" << orien_sensor.orien_filter.m_rot_matrix.m_rot_mat << "\n\n";
-
- cout << "Orientation 9-axis quaternion\t" << orien_sensor.orien_filter.m_quat_9axis.m_quat << "\n\n";
-
- cout << "Orientation geomagnetic quaternion\t" << orien_sensor.orien_filter.m_quat_aid.m_quat << "\n\n";
-
- cout << "Orientation gaming quaternion\t" << orien_sensor.orien_filter.m_quat_gaming_rv.m_quat << "\n\n";
- }
-
- accel_in.close();
- gyro_in.close();
- mag_in.close();
- orien_file.close();
-
- return 0;
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 "../../../quaternion.h"
-
-int main()
-{
- float arr0[4] = {2344.98, 345.24, 456.12, 98.33};
- float arr1[4] = {0.056, 0.34, -0.0076, 0.001};
- float axis1[3] = {6.5, 7.5, 8.3};
- float ang1 = 8.4;
-
- vect<float, 4> v0(arr0);
- vect<float, 4> v1(arr1);
- vect<float, 3> v2(axis1);
-
- quaternion<float> q0(v0);
- quaternion<float> q1(v1);
- quaternion<float> q2((float)2344.98, (float)345.24, (float)456.12, (float)98.33);
- quaternion<float> q3(q1);
- quaternion<float> q4;
-
- cout << "Constructor tests\n";
- cout << "input\t" << v0 << "\n";
- cout << "output\t" << q0.m_quat << "\n\n";
- cout << "input\t" << v1 << "\n";
- cout << "output\t" << q1.m_quat << "\n\n";
- cout << "input\t" << v0 << "\n";
- cout << "output\t" << q2.m_quat << "\n\n";
- cout << "input\t" << v1 << "\n";
- cout << "output\t" << q3.m_quat << "\n\n";
- cout << "default constructor\n";
- cout << "output\t" << q4.m_quat << "\n\n";
-
- cout << "Multiplication\n";
- float val = 0.1;
- quaternion<float> q5 = q0 * val;
- cout << "input\t" << q0.m_quat << "\n" << 0.1 << "\n";
- cout << "output\t" << q5.m_quat << "\n\n";
- quaternion<float> q6 = q0 * q1;
- cout << "input\t" << q0.m_quat << "\n" << q1.m_quat << "\n";
- cout << "output\t" << q6.m_quat << "\n\n";
-
- cout << "Addition\n";
- quaternion<float> q7 = q0 + q1;
- cout << "input\t" << q0.m_quat << "\n" << q1.m_quat << "\n";
- cout << "output\t" << q7.m_quat << "\n\n";
-
- cout << "Quaternion Normalization\n";
- cout << "input\t" << q1.m_quat << "\n";
- q1.quat_normalize();
- cout << "output\t" << q1.m_quat << "\n\n";
-
- cout << "Axis2quat\n";
- cout << "input\t" << " " << v2 << endl;
- cout << endl;
- quaternion<float> q11 = axis2quat(v2, ang1);
- cout << "output\t" << q11.m_quat << "\n\n";
- cout << endl;
-}
-
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 "../../../rotation_matrix.h"
-
-int main()
-{
- float arr1[3][3] = {{20.2, 40.5, 10.0}, {3.6, 52.0, 5.5}, {1.0, 45.5, 66.6}};
- float arr2[3][3] = {{2.24, 0.5, 0.023}, {3.675, 5.32, 0.556}, {1.023, 45.75, 621.6}};
- float arr3[3][3] = {{4.75, 0.65, 0.123}, {0.075, 5.302, 0.56}, {1.113, 0.475, 2.362}};
-
- matrix<float, 3, 3> m1(arr1);
- matrix<float, 3, 3> m2(arr2);
- matrix<float, 3, 3> m3(arr3);
-
- rotation_matrix<float> rm0, rm5;
- rotation_matrix<float> rm1(m1);
- rotation_matrix<float> rm2(m2);
- rotation_matrix<float> rm3(m3);
- rotation_matrix<float> rm4(arr1);
-
- quaternion<float> q0(-0.612372, 0.456436, 0.456436, 0.456436);
- quaternion<float> q1;
-
- cout << "Constructor tests\n";
- cout << "input\n" << m1 << "\n";
- cout << "output\n" << rm1.m_rot_mat << "\n\n";
- cout << "input\n" << m2 << "\n";
- cout << "output\n" << rm2.m_rot_mat << "\n\n";
- cout << "input\n" << m3 << "\n";
- cout << "output\n" << rm3.m_rot_mat << "\n\n";
- cout << "input\n" << m1 << "\n";
- cout << "output\n" << rm4.m_rot_mat << "\n\n";
- cout << "default constructor\n";
- cout << "output\n" << rm0.m_rot_mat << "\n\n";
-
- cout << "Quaternion to Rotation Matrix\n";
- cout << "input\n" << q0.m_quat << "\n";
- rm0 = quat2rot_mat(q0);
- cout << "output\n" << rm0.m_rot_mat << "\n\n";
-
- cout << "Rotation Matrix to Quaternion\n";
- cout << "input\n" << rm0.m_rot_mat << "\n";
- q1 = rot_mat2quat(rm0);
- cout << "output\n" << q1.m_quat << "\n\n";
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 "../../../sensor_data.h"
-
-int main()
-{
- float arr1[3] = {1.04, -4.678, -2.34};
- float arr2[3] = {0, 0, 1};
- vect<float, 3> v1(arr1);
- vect<float, 3> v2(arr2);
-
- sensor_data<float> sd1(2.0, 3.0, 4.0, 140737488355328);
- sensor_data<float> sd2(1.04, -4.678, -2.34, 0);
- sensor_data<float> sd3(0.054, 1.097, 4.456, 140737488355328);
-
- sensor_data<float> sd10(v1, 140737488355328);
- sensor_data<float> sd11(0.2, 0.1, 0.3, 140737488355328);
-
- cout << "Constructor tests\n";
- cout << "input\t" << v1 << "\n";
- cout << "output\t" << sd10.m_data << "\t" << sd10.m_time_stamp << "\n\n";
- cout << "input\t" << v1 << "\n";
- cout << "output\t" << sd2.m_data << "\t" << sd2.m_time_stamp << "\n\n";
-
- cout << "Addition:\n";
- sensor_data<float> sd4 = sd1 + sd2;
- cout << "\n" << sd1.m_data << "\n" << sd2.m_data;
- cout << "\nSum:\n" << sd4.m_data << endl;
- sensor_data<float> sd9 = sd1 + sd10;
- cout << "\n" << sd1.m_data << "\n" << sd10.m_data;
- cout << "\nSum:\n" << sd9.m_data << endl;
-
- cout << "\n\n\nNormalization:\n";
- cout << "\n" << sd3.m_data;
- normalize(sd3);
- cout << "\nResult:\n" << sd3.m_data << endl;
- cout << "\n" << sd2.m_data;
- normalize(sd2);
- cout << "\nResult:\n" << sd2.m_data << endl;
-
- float xx = 2.5;
- cout << "\n\n\nScale data:\n";
- sensor_data<float> sd8 = scale_data(sd2, xx);
- cout << "\n" << sd2.m_data << "\n" << xx;
- cout << "\nResult:\n" << sd8.m_data << endl;
-
- cout << "\n\n\nConvert Sensor Data to Quaternion:\n";
- quaternion<float> q = sensor_data2quat(sd11, v2);
- cout << "\n" << sd11.m_data << "\n" << v2;
- cout << "\nResult:\n" << q.m_quat << endl;
-}
-
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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 "../../../vector.h"
-
-int main()
-{
- float arr2[3] = {0.056, 2.34, -65.76};
- float arr15[3] = {1.04, -4.678, -2.34};
- float arr3[4] = {1.03, 2.345, 6.78, 5.55};
- float arr4[4] = {-6.78, -45.213, -7.89, -3.456};
- float arr8[5] = {0.0123, 5.678, 2.345, 0.345, 8.956};
- float arr0[5] = {2344.98, 345.24, 456.12, 98.33, 144.67};
- float arr1[6] = {1.234, 4.5, 6.8987, 3.33, 5.66, 77.695};
- float arr43[6] = {2.3454, -0.0384, -8.90, 3.455, 6.785, 21.345};
- float arr5[5] = {0.2, -0.4, 0.6, -0.8, 1.0};
-
- vect<float, 5> v1(arr0);
- vect<float, 5> v2(arr8);
- vect<float, 4> v10(arr3);
- vect<float, 4> v12(arr4);
- vect<float, 6> v15(arr1);
- vect<float, 6> v20(arr43);
- vect<float, 3> v21(arr2);
- vect<float, 3> v22(arr15);
- vect<float, 5> v31(arr0);
- vect<float, 3> v3;
- vect<float, 2> vn;
- vect<float, 4> v61(arr4);
- vect<float, 3> v6;
- vect<float, 4> vm;
- vect<float, 5> v13;
- vect<float, 6> v95;
- vect<float, 5> v35(arr5);
- vect<float, 5> vl;
- vect<float, 4> vp;
- vect<float, 4> vr(arr4);
- vect<float, 3> vf;
-
- float arr57[3][3] = {{2.24, 0.5, 0.023}, {3.675, 5.32, 0.556}, {1.023, 45.75, 621.6}};
- matrix<float, 3, 3> m12(arr57);
- float arr67[3][1] = {{2.0}, {3.0}, {4.0}};
- matrix<float, 3, 1> m32(arr67);
-
- cout << "Constructor Test\n";
- cout << "\n" << v3;
-
- cout << "\n\nAddition\n";
- v3 = v21 + v22;
- v95 = v15 + v20;
- cout << "\n\nNumbers added\n";
- cout << "\n" << v21 << "\n" << v22;
- cout << "\nSum:\n" << v3 << endl;
- cout << "\n\nNumbers added\n";
- cout << "\n" << v15 << "\n" << v20;
- cout << "\nSum:\n" << v95 << endl;
-
- float num = 5.5650;
- float num1 = -2.32;
- cout << "\n\n\nScalar addition\n";
- vl = v2 + num;
- vm = v10 + num1;
- cout << "\nNumber added:" << num;
- cout << "\n\n" << v2;
- cout << "\nResult:\n\n" << vl;
- cout << "\nNumber added:" << num1;
- cout << "\n\n" << v10;
- cout << "\nResult:\n\n" << vm;
-
- cout << "\n\n\nSubtraction\n";
- vp = v10 - v12;
- cout << "\n" << v10 << "\n" << v12;
- cout << "\nDifference:\n" << vp << endl;
-
- float x = 4.0;
- float x1 = -2.5;
- cout << "\n\n\nScalar subtraction\n";
- v13 = v1 - x;
- vp = v10 - x1;
- cout << "\nNumber Subtracted:" << x;
- cout << "\n\n" << v1;
- cout << "\nResult:\n\n" << v13;
- cout << "\nNumber Subtracted:" << x1;
- cout << "\n\n" << v10;
- cout << "\nResult:\n\n" << vp;
-
- float xx = 7.2;
- cout << "\n\n\nMultiplication\n";
- v13 = v2 * xx;
- cout << "\n" << v2 << "\n" << xx;
- cout << "\nProduct:\n" << v13 << endl;
-
- cout << "\n\n\nMultiplication matrix x vector:\n";
- matrix<float, 3, 3> m102 = m32 * v22;
- cout << "\n" << m32 << "\n" << v22;
- cout << "\nProduct:\n" << m102 << endl;
-
- cout << "\n\n\nVector x Multiplication matrix:\n";
- vect<float, 3> v102 = (v22 * m12);
- cout << "\n" << v22 << "\n" << m12;
- cout << "\nProduct:\n" << v102 << endl;
-
- float z = 3.50;
- float z1 = -5.567;
- cout << "\n\n\nScalar multiplication\n";
- v13 = v1 * z;
- v61 = v12 * z1;
- cout << "\nNumber Multiplied:" << z;
- cout << "\n\n" << v1;
- cout << "\nResult:\n\n" << v13;
- cout << "\nNumber Multiplied:" << z1;
- cout << "\n\n" << v12;
- cout << "\nResult:\n\n" << v6;
-
- float num2 = 5.5;
- cout << "\n\n\nDivision\n";
- v31 = v1 / num2;
- cout << "\n" << v1 << "\n" << num2;
- cout << "\nResult:\n" << v3 << endl;
-
- cout << "\n\n\nTranspose:";
- cout << "\n\n" << v20;
- cout << "\nResult:\n\n";
- matrix<float, 6, 1> m101 = transpose(v20);
- cout << m101;
- cout << "\n\n" << m101;
- cout << "\nResult:\n\n";
- v20 = transpose(m101);
- cout << v20;
-
- cout << "\n\nv1:\n\n" << v1;
- cout << "\n\nv2:\n\n" << v2;
- cout << "\n\n\nv1 == v2 :";
- cout << (v1 == v2);
-
- cout << "\n\nv10:\n\n" << v10;
- cout << "\n\nv10:\n\n" << v10;
- cout << "\n\n\nv10 == v10 :";
- cout << (v10 == v10);
-
- cout << "\n\nv12:\n\n" << v12;
- cout << "\n\nv15:\n\n" << vr;
- cout << "\n\n\nv12 != v15 :";
- cout << (v12 != vr);
-
- cout << "\n\nv15:\n\n" << v15;
- cout << "\n\nv15:\n\n" << v15;
- cout << "\n\n\nv15 != v15 :";
- cout << (v15 != v15);
-
- cout << "\n\nAssignment\n";
- v3 = vf;
- cout << "Input \n" << v1;
- cout << "\nOutput:\n" << v3 << endl;
-
- vect<float, 3> v111 = cross(v21, v22);
- cout << "\n\n\nCross Product:";
- cout << "\n\n" << v21 << "\n\n" << v22;
- cout << "\nResult:\n\n" << v111;
-
- float val = dot(v21, v22);
- cout << "\n\n\nDot Product:";
- cout << "\n\n" << v21 << "\n\n" << v22;
- cout << "\nResult:\n\n" << val;
-
- cout << "\n\n\nQueue insert function:";
- cout << "\nInput:\n\n" << v111;
- insert_end(v111, (float) 0.9191919);
- cout << "\nResult:\n\n" << v111;
-
- cout << "\n\n\nVariance:";
- cout << "\nInput:\n\n" << v35;
- val = var(v35);
- cout << "\nResult:\n\n" << val;
-
- cout << "\n\n\nIs Initialized:";
- cout << "\nInput:\n\n" << v35;
- cout << "\nResult:\n\n" << is_initialized(v35) << endl;
-}
-