Thank you for the reply @BSTRobin , Yes, the hardware used Acc, Gyr, Mag sensors. I accept your suggestion. But, In Program I have only one function named the call-back function of the Rotation vector which gives Quaternions. Can I use the below configuration and Reading function to get RPY or Should I need to do modifications for RPY data? if (bhy_install_sensor_callback(VS_TYPE_ORIENTATION, VS_WAKEUP,
sensors_callback_orientation)) {
//DEBUG("Fail to install sensor callback\n");
}
if (bhy_enable_virtual_sensor(VS_TYPE_ORIENTATION, VS_WAKEUP,
ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0)) {
//DEBUG("Fail to enable sensor id=%d\n", VS_TYPE_ROTATION_VECTOR);
} static void sensors_callback_rotation_vector(bhy_data_generic_t *sensor_data,
bhy_virtual_sensor_t sensor_id) {
float temp;
uint8_t index;
temp = sensor_data->data_quaternion.w / 16384.0f; /* change the data unit by dividing 16384 */
out_buffer[3] = temp < 0 ? '-' : ' ';
temp = temp < 0 ? -temp : temp;
out_buffer[4] = floor(temp) + '0';
for (index = 6; index <= 8; index++) {
temp = (temp - floor(temp)) * 10;
out_buffer[index] = floor(temp) + '0';
}
temp = sensor_data->data_quaternion.x / 16384.0f;
out_buffer[13] = temp < 0 ? '-' : ' ';
temp = temp < 0 ? -temp : temp;
out_buffer[14] = floor(temp) + '0';
for (index = 16; index <= 18; index++) {
temp = (temp - floor(temp)) * 10;
out_buffer[index] = floor(temp) + '0';
}
temp = sensor_data->data_quaternion.y / 16384.0f;
out_buffer[23] = temp < 0 ? '-' : ' ';
temp = temp < 0 ? -temp : temp;
out_buffer[24] = floor(temp) + '0';
for (index = 26; index <= 28; index++) {
temp = (temp - floor(temp)) * 10;
out_buffer[index] = floor(temp) + '0';
}
temp = sensor_data->data_quaternion.z / 16384.0f;
out_buffer[33] = temp < 0 ? '-' : ' ';
temp = temp < 0 ? -temp : temp;
out_buffer[34] = floor(temp) + '0';
for (index = 36; index <= 38; index++) {
temp = (temp - floor(temp)) * 10;
out_buffer[index] = floor(temp) + '0';
}
//DEBUG("x=%d, y=%d, z=%d, w=%d\n", sensor_data->data_quaternion.x, sensor_data->data_quaternion.y, sensor_data->data_quaternion.z, sensor_data->data_quaternion.w);
} What I have to modify in that function to get RPY ?
... View more