'Gravity Compensation in IMU Data
I'm trying to do gravity compensation on my accelerometer data. Given an Accelerometer, with 6 DOF (Accelerometer, Gyroscope) I want to remove/compensate the effect of the gravity in accelerometer reading (Accelerometer can rotate freely).
Following is the way I store raw sensor values to a struct called sample :
uint8_t *p=data; // p is a pointer to the sensor data
int i;
for(i=0; i<4; i++) // quaternion
{
sample.quaternion[i]=((float)get_int32(p))/(1<<29);
len+=snprintf(s+len, sizeof(line)-len, "\t%9.6f", sample.quaternion[i]);
p+=4;
}
for(i=0; i<3; i++) // euler213_degrees
{
sample.euler213_degrees[i]=get_int16(p);
len+=snprintf(s+len, sizeof(line)-len, "\t%d", sample.euler213_degrees[i]);
p+=2;
}
for(i=0; i<3; i++) // euler123_degrees
{
sample.euler123_degrees[i]=get_int16(p);
len+=snprintf(s+len, sizeof(line)-len, "\t%d", sample.euler123_degrees[i]);
p+=2;
}
for(i=0; i<3; i++) // acceleration_g
{
sample.acceleration_g[i]=(2.0*get_int16(p))/(1<<15);
len+=snprintf(s+len, sizeof(line)-len, "\t%6.3f", sample.acceleration_g[i]);
p+=2;
}
for(i=0; i<3; i++) // gyroscope_dps
{
sample.gyroscope_dps[i]=(2000.0*get_int16(p))/(1<<15);
len+=snprintf(s+len, sizeof(line)-len, "\t%6.1f", sample.gyroscope_dps[i]);
p+=2;
}
Can you show me a way to get gravity compensated Accelerometer data?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
