整合3轴陀螺仪的读数? [英] Integrate readings from a 3 axis Gyroscope?

查看:300
本文介绍了整合3轴陀螺仪的读数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我用C编写了一个程序,以很高的数据速率打印3轴陀螺仪的值.这些值是角速度的瞬时值,该角速度在移动时会上升,在设备静止时会下降.我需要它保持较高的值,并在返回到位置时恢复为零. 如果我在固定的采样时间内对这些值进行积分,是否可以实现?我该如何进行整合?我是C编程的初学者. 谢谢

So I have written a program in C to print values of 3 axis gyro at a very high data rate. The values are instantaneous values of angular speed that rise on movement and fall if the device is still. I need it to hold the high values and come back to zero when returned to position. If I integrate the values over a fixed sample time, would I achieve this? How do I go about integrating? I am a beginner in C programming. Thank you

推荐答案

首先,您需要了解数字陀螺仪的物理方面:它为suffers from drift(它不会返回0,但通常会持续很长时间时间段),并且同样重要的是,通常是biased;这是一个校准问题.

First off you need to understand the physical aspect of a digital gyroscope: it suffers from drift (it won't return to 0, but that usually happens over long periods of time) and equally important it usually is biased; this is a calibration issue.

可以通过在静止时读取其轴值来观察陀螺仪的偏斜.如果它读取的不是0,那是您的偏见.您需要对此进行补偿.你怎么做呢? -校准

The gyro bias can be observed by reading it's axis value when it's still. If it reads anything other than 0, that's your bias. And you need to compensate for that. How do you do it? - calibration

陀螺仪校准:读取给定时间段内的轴值(应执行1000个样本).对样本取平均值以获得偏差值. You have to subtract this bias value from all readings when running you code to get a valid reading.如果在陀螺仪不动时读零,您就会知道自己做对了.

Gyro calibration: read the axis values for a given period of time (1000 samples should do it). Average the samples to get the bias value. You have to subtract this bias value from all readings when running you code to get a valid reading. You'll know you have done it right if you read zeros while the gyro is not moving.

接下来,解释陀螺仪数据:陀螺仪为您提供angular velocity values.这些原始形式对您没有多大用处.因此,随着时间的推移,您将它们集成在一起以获得angle values,但是在您能够做到这一点之前,您需要做一些事情:

Next up, interpreting the gyro data: the gyro gives you angular velocity values. These are not of much use to you in their raw form; so, you integrate them over time to get angle values, but before you can do that you'll need a few things:

    陀螺仪增益;在数据表中将其指定为与其灵敏度相关的值(例如,对于2000dps的灵敏度,GAIN = 0.07)-它应全部位于数据表的表格中,并且取决于陀螺仪的配置方式.
  1. 您需要选择一个用于积分值的时间间隔,这又取决于陀螺仪配置(请参见dps设置),但是10毫秒或20毫秒就可以了.
  2. 确保您以良好的周期性(即每10毫秒精确读取一次)读取陀螺仪值
  3. 编写一些代码以将它们放在一起-像这样:

  1. the gyro gain; this is specified in the datasheet as a value associated to it's sensitivity (i.e. GAIN = 0.07 for a sensitivity of 2000dps) - it should all be in a table in the data sheet and it depends on how the gyro is configured.
  2. you need to choose a time interval over which you integrate the values, this again depends on the gyro configuration (see the dps settings) but you should be fine with 10 or 20 ms.
  3. make sure you read the gyro values with a good periodicity (i.e. exactly one every 10ms)
  4. write some code to put it all together- like so:

while(1)
{
    startInt = mymillis();// this function returns the current time in ms

    gyroRaw = readGyro(); 

    //Convert Gyro raw to degrees per second
    rate_gyro = (float) gyrRaw * GYRO_GAIN;

    //Calculate the angles from the gyro
    gyroAangle += rate_gyro * DT;

    //print the gyro angle ...or anything you find useful

    //Each loop should be at least 20ms.
    while(mymillis() - startInt < 20)
    {
       usleep(100);
    }
}

我希望这可以帮助您走上正确的道路:)

This should get you started on the right path, I hope :)

这篇关于整合3轴陀螺仪的读数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆