搜索
bottom↓
回复: 12

求教:两轮自平衡车

[复制链接]

出0入0汤圆

发表于 2011-1-2 13:03:01 | 显示全部楼层 |阅读模式
我大四,现在刚研究这个东西,请问让车体保持平衡用什么传感器?陀螺仪?加速度传感器?淘宝网上买的比较便宜的能用吗?还有谁能给我份硬件原理图呢。谢谢各位大哥了

阿莫论坛20周年了!感谢大家的支持与爱护!!

月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!

出0入0汤圆

发表于 2011-2-1 00:57:33 | 显示全部楼层
用 陀螺仪 + 倾角传感器  这是传感器。然后采用卡尔曼滤波,计算各角速度 和 倾角 ,然后再通过PWM 控制电机转动。
你可以做开环的,也可以做闭环的。
对于传感器,你可以找我。我用过这两个传感器。
  QQ 540276453

出0入0汤圆

 楼主| 发表于 2011-2-8 17:43:40 | 显示全部楼层
回复【1楼】guozs1984
-----------------------------------------------------------------------

好的,已经买好了,谢谢

出0入0汤圆

发表于 2011-6-18 21:52:40 | 显示全部楼层
Kalman filtering of IMU data
Introduction
To many of us, kalman filtering is something like the holy grail. Indeed, it miraculously solves some problems which are otherwise hard to get a hold on. But beware, kalman filtering is not a silver bullet and won’t solve all of your problems!

This article will explain how Kalman filtering works. We’ll use a more practical approach to avoid the boring theory, which is hard to understand anyway. Since most of you will only use it for MAV/UAV applications, I’ll try to make it look more concrete instead of puzzling generalized approach.
Make sure you know from the previous articles how the data from “accelerometers” and “gyroscopes” are used. Some basic knowledge of algebra may also come in handy :-)

Basic operation
Kalman filtering is an iterative filter that requires two things.
First of all, you will need some kind of input (from one or more sources) that you can turn into a prediction of the desired output using only linear calculations. In other words, we will need a lineair model of our problem.
Secondly, you will need another input. This can be the real world value of the predicted one, or something that is a good approximation of it.
Every iteration, the kalman filter will change the variables in our lineair model a bit, so the output of our linear model will be closer to the second input.

Our simple model
Obviously, our two inputs will consist of the gyroscope and accelerometer data. The model using the gyroscope data looks like this:



The first formula represents the general form of a linear model. We need to “fill in” the A en B matrix, and choose a state x. The variable u represents the input. In our case this will be the gyroscope’s data. Remember how we integrate? We just add the NORMALIZED measurements up:

alpha k = alpha k-1 + (_u_ k – bias)

We need to include the time between two measurements (_dt_) because we are dealing with the rate (degrees/s):

alpha k = alpha k-1 + (_u_ k – bias) * dt

We rewrite it:

alpha k = alpha k-1 – bias * dt + u k * dt

Which is what we have in our matrix multiplication. Remark that our bias remains constant! In the tutorial on gyroscopes, we saw that the bias drifts. Well, here comes the kalman-magic: the filter will adjust the bias in each iteration by comparing the result with the accelerometer’s output (our second input)! Great!

Wrapping it all up
Now all we need are the bits and bolts that actually do the magic! These are some formulas using matrix algebra and statistics. No need right now to know the details of it. Here they are:

u = measurement1  Read the value of the last measurement  
x = A · x + B · u  Update the state x of our model  
y = measurement2  Read the value of the second measurement/real value. Here this will be the angle calculated from our accelerometer.  
Inn = y – C · x  Calculate the difference between the second value and the value predicted by our model. This is called the innovation  
s = C · P · C’ + Sz  Calculate the covariance  
K = A · P · C’ · inv(_s_)  Calculate the kalman gain  
x = x + K · Inn  Correct the prediction of the state  
P = A · P · A’ – K · C · P · A’ + Sw  Calculate the covariance of the prediction error  

The C matrix is the one that extracts the ouput from the state matrix. In our case, this is (1 0)’ :

alpha = C · x

Sz is the measurement process noise covariance: Sz = E(zk zkT)

In our example, this is how much jitter we expect on our accelerometer’s data.

Sw is the process noise covariance matrix (a 2×2 matrix here): Sw = E(x · xT)
Thus: Sw = E( [alpha bias]’ · [alpha bias] )

Since only the diagonal elements of the Sw matrix are being used, we’ll only need to know E(alpha2) and E(bias2), which is the 2nd moment. To calculate those values, we’ll need to look at our model: The noise in alpha comes from the gyroscope and is multiplied by dt2. Thus: E(alpha2) = E(u2)· dt2.

These factors depend on the sensors you’re using. You’ll need to figure them out by doing some experiments. In the source code of the autopilot/rotomotion kalman filtering, they use the following constants:

E(alpha2) = 0.001
E(bias2) = 0.003
Sz = 0.3 (radians = 17.2 degrees)

出0入0汤圆

发表于 2011-7-24 12:10:46 | 显示全部楼层

(原文件名:图片1.png)

出0入0汤圆

发表于 2012-1-8 00:57:30 | 显示全部楼层
mark

出0入0汤圆

发表于 2012-1-8 11:57:48 | 显示全部楼层
楼上英文翻译:
惯性数据测量——卡尔曼滤波
介绍
对于大多数人来说,卡尔曼滤波很难理解。的确,他奇迹般地解决了其他方法很难解决的问题。但是注意,卡尔曼滤波并不是解决你所有问题万能的良方。
这篇文章将阐述卡尔曼滤波的使用。我们将使用多的实际方法而避免那些很难理解的繁琐理论,因为大多数人仅仅将其用于MAV/UAV(微型飞行器/无人机)应用上,我将试图将它形象具体化。
必须确保你已经知道了怎样使用加速度计和陀螺仪来进行数据采集,另外,一些基础的代数知识也是必要的。

基本操作
卡尔曼滤波是一种链形滤波器(累接滤波器),他需要两个东西:
首先,你将需要几种输入(一路或更多的数据源),你可以仅仅使用线性计算将他们转换为你预期的输出。换句话说,在我们的问题中,我们需要建立一个线性模型。
其次,你需要另一路输入。这一路是期望数据中的实际外界数据值,或者是它的近似。
每一次迭代,卡尔曼滤波器都将微小地改变线性模型中的变量,因此线性模型的输出将于第二次输入接近。

简化模型
显然,两路输入包含陀螺仪和加速度计的数据。使用陀螺仪数据模型看起来像这样:

第一个公式展示了一个线性模型的一般形式。我们需要在B矩阵中“填入”A矩阵,然后选择一个状态x。变量_u_k代表输入。对我们来说,这就是陀螺仪的数据。记住,怎样去积分?我们只是对归一化的数据进行求和:
alpha k = alpha k-1 + (_u_ k – bias)
我们需要再两个测量(_dt_)之间加入时间参数,因为我们要处理角速度(degrees/s):
alpha k = alpha k-1 + (_u_ k – bias) * dt
重写如下:
alpha k = alpha k-1 – bias * dt + u k * dt
上式在矩阵乘法中我将用到。注意bias保持恒定!在个别陀螺仪中,我们看到了bias的漂移。接下来就是卡尔曼的神奇之处了:滤波器通过将加速度计的输出和结果进行比较调整每次迭代的bias。真是棒极了!。
包装总结:
现在,我们需要bits and bolts来做这件神奇的事了。这些用到了矩阵代数和统计学中的公式。没有必要立刻就知晓他们的细节。如下:
u= measurement1        读取上一次测量的数据
x= A • x + B • u        更新模型中的状态x
y= measurement2        读第二次测量的数据. 数据来源于加速度计,将对角度进行计算
Inn= y – C • x        计算先前模型中的数据和第二次测量数据的差值,This is called the innovation
s= C • P • C’ + Sz        计算协方差
K= A • P • C’ • inv(_s_)        计算卡尔曼增益
x= x + K • Inn        修正先前状态值
P= A • P • A’ – K • C • P • A’ + Sw        计算先前误差的协方差
矩阵C用于提取状态矩阵中的输出。对于我们而言,它是(1 0)’ :
alpha = C • x
Sz是测量过程的噪声协方差:Sz = E(zk zkT)
在我们的例子中,这是加速度计数据我们期望的抖动程度。
Sw 地方过程噪声协方差矩阵(这里是2×2矩阵):Sw = E(x • xT)
这样:Sw = E( [alpha bias]’ • [alpha bias] )
因为仅仅只有用到Sw矩阵的对角元素,因此我们只需要知道E(alpha2) 和E(bias2),他们是第二个时刻的值。为了计算这些值,我们需要查看我们建立的模型:alpha中的噪声来自于陀螺仪,同时乘以dt2这样:E(alpha2) = E(u2)• dt2。
这些因素取决于你使用的传感器,你需要通过做实验把他们计算出来。在autopilot/rotomotion的卡尔曼滤波的源代码中,他们使用以下的常量:
E(alpha2) = 0.001
E(bias2) = 0.003
Sz = 0.3 (radians = 17.2 degrees)
英文原档ourdev_711265HG8XPM.doc(文件大小:36K) (原文件名:Kalman filtering of IMU data.doc)

出0入0汤圆

发表于 2012-1-13 21:45:24 | 显示全部楼层
回复【2楼】rezire199847 無ξ
-----------------------------------------------------------------------
你买的什么型号的?

出0入0汤圆

发表于 2012-1-15 23:09:46 | 显示全部楼层
楼主所需,亦是我所需啊!

出0入0汤圆

发表于 2012-1-18 10:14:13 | 显示全部楼层
顶一下

出0入0汤圆

发表于 2012-2-11 13:04:20 | 显示全部楼层
帮顶

出0入0汤圆

发表于 2014-11-16 13:45:56 | 显示全部楼层
留个记号!!!
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-4-29 00:35

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表