}
template <typename TYPE>
+inline void orientation_filter<TYPE>::initialize_sensor_data(const sensor_data<TYPE> accel,
+ const sensor_data<TYPE> magnetic)
+{
+ m_accel.m_data = accel.m_data;
+ m_magnetic.m_data = magnetic.m_data;
+
+ m_accel.m_time_stamp = accel.m_time_stamp;
+ m_magnetic.m_time_stamp = magnetic.m_time_stamp;
+}
+
+template <typename TYPE>
inline void orientation_filter<TYPE>::orientation_triad_algorithm()
{
TYPE arr_acc_e[V1x3S] = {0.0, 0.0, 1.0};
return m_quat_9axis;
}
+template <typename TYPE>
+quaternion<TYPE> orientation_filter<TYPE>::get_geomagnetic_quaternion(const sensor_data<TYPE> accel,
+ const sensor_data<TYPE> magnetic)
+{
+ initialize_sensor_data(accel, magnetic);
+
+ normalize(m_accel);
+ normalize(m_magnetic);
+
+ orientation_triad_algorithm();
+
+ return m_quat_aid;
+}
#endif //_ORIENTATION_FILTER_H_
inline void initialize_sensor_data(const sensor_data<TYPE> accel,
const sensor_data<TYPE> gyro, const sensor_data<TYPE> magnetic);
+ inline void initialize_sensor_data(const sensor_data<TYPE> accel,
+ const sensor_data<TYPE> magnetic);
inline void orientation_triad_algorithm();
inline void compute_covariance();
inline void time_update();
const sensor_data<TYPE> gyro, const sensor_data<TYPE> magnetic);
quaternion<TYPE> get_9axis_quaternion(const sensor_data<TYPE> accel,
const sensor_data<TYPE> gyro, const sensor_data<TYPE> magnetic);
+ quaternion<TYPE> get_geomagnetic_quaternion(const sensor_data<TYPE> accel,
+ const sensor_data<TYPE> magnetic);
};
#include "orientation_filter.cpp"
return orien_filter.get_9axis_quaternion(accel_data, gyro_data, magnetic_data);
}
+quaternion<float> orientation_sensor::get_geomagnetic_quaternion(sensor_data<float> accel_data,
+ sensor_data<float> magnetic_data)
+{
+ 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);
+ normalize(magnetic_data);
+
+ return orien_filter.get_geomagnetic_quaternion(accel_data, magnetic_data);
+}
#endif
sensor_data<float> gyro, sensor_data<float> magnetic);
quaternion<float> get_9axis_quaternion(sensor_data<float> accel,
sensor_data<float> gyro, sensor_data<float> magnetic);
+ quaternion<float> get_geomagnetic_quaternion(sensor_data<float> accel,
+ sensor_data<float> magnetic);
};
#include "orientation_sensor.cpp"
euler_angles<float> orientation;
rotation_matrix<float> orientation_mat;
quaternion<float> orientation_9axis_quat;
- orientation_sensor orien_sensor1, orien_sensor2, orien_sensor3;
+ quaternion<float> orientation_geomagnetic_quat;
+ orientation_sensor orien_sensor1, orien_sensor2, orien_sensor3, orien_sensor4;
accel_in.open(((string)ORIENTATION_DATA_PATH + (string)"accel.txt").c_str());
gyro_in.open(((string)ORIENTATION_DATA_PATH + (string)"gyro.txt").c_str());
orientation_9axis_quat = orien_sensor3.get_9axis_quaternion(accel_data, gyro_data, magnetic_data);
cout << "Orientation 9-axis quaternion\t" << orientation_9axis_quat.m_quat << "\n\n";
+
+ orientation_geomagnetic_quat = orien_sensor4.get_geomagnetic_quaternion(accel_data, magnetic_data);
+
+ cout << "Orientation geomagnetic quaternion\t" << orientation_geomagnetic_quat.m_quat << "\n\n";
}
accel_in.close();