|
附上我的角度测量程序:
/*******************************************/
函数名称: short AVR_Get_Angle(float x,float y,float z,unsigned char dir)
功 能: 知道三个轴上的重力加速度就可以通过如下算法计算出角度。
参 数: ms--延时的毫秒数
返 回 值: 一个16位的角度值 0.1度
/********************************************/
short AVR_Get_Angle(float x,float y,float z,unsigned char dir)
{
float Result=0;
float temp;
switch(dir)
{
case 0: //X
temp = sqrt((x*x+y*y))/z;
Result = atan(temp);
break;
case 1: //Y
temp = x/sqrt((z*z+y*y));
Result =atan(temp);
break;
case 2: //Z
temp = y/sqrt((x*x+z*z));
Result =atan(temp);
break;
}
return Result*1800/3.14;
}
很奇怪的时候为什么我的角度测出来是0~90°,请前辈多多指教?
还有就是MPU6050模块用那种测量角度更好一点? |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|