Home › Forums › Forums › Technical Support for BerryIMU › Noise when using tilt compensation › Reply To: Noise when using tilt compensation
It was actually in my own C/C++ code I discovered this issue at first. I will investigate i bit more with different sensors before I conclude.
A workaround has been to implement a circular buffer to the final output like so;
….
float avgHeading[30];
….
avgHeading) )] = tiltCompensatedHeading;
i++;
for (ii=0; ii < (int)( sizeof(avgHeading) / sizeof(avgHeading[0])); ii++){
float radX = avgHeading[ii] * (M_PI/180); //Convert to radians
float radY = avgHeading[ii] * (M_PI/180); //Convert to radians
radX = cos(radX);
x += radX;
radY = sin(radY);
y += radY;
}
float smoothData = (180/M_PI) * atan2(y,x);
x = 0.0; y = 0.0;
if(smoothData < 0)
smoothData += 360;
printf(“Comp Head %7.3f \t Filt Head %7.1f\n”, heading, smoothData);
….
I guess there are more elegant ways to filter the output. Your advice would be highly appreciated.
Thanks