来自系列:了解卡尔曼过滤器
Melda Ulusoy, MathWorks
该视频演示了如何在Simulink中使用扩展的卡尔曼滤波器估计非线性摆动系统的角度位置金宝app®。
在此视频中,使用Simsceuce Multibody™在Simulink中建模了一个简单的摆锤系统。金宝app使用控制系统工具箱™中可用的扩展卡尔曼滤波器块估计非线性摆动系统的角度位置。该视频显示如何指定扩展的卡尔曼滤波器块参数,例如状态转换和测量函数,初始状态估计和噪声特征。如果要实时地运行硬件状态估计,则可以从Simulink中的扩展Kalman过滤器块生成C / C ++代码,并将其部署到硬件。金宝app
Download this virtual labto study linear and extended Kalman filter design with interactive exercises.
在此视频中,我们将演示如何在Simulink中使用扩展的卡尔曼滤波器。金宝app以前,我们使用了一个简单的摆锤系统,并假设用传感器测量摆锤的角位置θθ。为了过滤噪声测量,我们使用卡尔曼滤波器并显示它在θ的初始条件小时提供了很好的估计。然而,当我们增加Theta到90度的值时,我们无法准确估计,因为摆模型非线性地用于较大的θ值。因此,为了估计这个非线性系统的θ,我们将使用扩展的卡尔曼滤波器。
We’ll start by adding the Extended Kalman Filter block from Control System Toolbox to our model. Remember that in the previous videos we’ve discussed that state transition and measurement functions might be nonlinear, and how the extended Kalman filter algorithm uses linear approximations to these nonlinear functions to compute the state estimates. Now, in the Extended Kalman Filter block, we will specify these functions. Here, we’ll use MATLAB functions to create f and g, but note that you can also use Simulink function blocks. The state transition function uses the current state and the input to determine how the states of the next time step will be calculated. Here, any input to the state transition function other than the states and process noise is connected through an input port. So, we connect u as the first input to the block. We first discretize this signal using a zero-order hold as the Extended Kalman Filter block estimates states of a discrete nonlinear system.
在我们的示例中,我们不会指定Jacobian,因为它将在数字上计算。但是,如果可以使用分析雅可比,您可以创建一个函数来计算它并在此处输入该函数的名称。接下来,我们输入我们之前在脚本中定义的过程噪声协方差。我们还输入了各州的初始值。在摆锤模型中,θ用90度和0速度初始化。我们在扩展的卡尔曼过滤器块中使用相同的值。由于我们知道初始状态值,我们将将初始状态估计错误协方差设置为小值。但是,如果您对初始状态值没有信心,则可以为协方差指定高值。
接下来,我们指定的测量功能,再次sing a MATLAB function. Then we connect the measured theta corresponding to the measurement function that we’ve just specified in the block. And we enter the measurement covariance whose value has been previously defined in the script. Remember that a Kalman filter is also referred to as a sensor fusion algorithm, since it combines measurements from multiple sensors to reduce the uncertainty in the state estimate. So, if you have multiple measurements, you can enter them by clicking “Add Measurement.” And different sensors may have different sampling rates, so you can specify the sample times of measurements and the state transition under the “Multirate” tab. And lastly, we enter the sample time.
既然我们指定了扩展卡尔曼过滤器块的参数,我们可以运行此模拟并查看结果。这里,蓝色信号显示实际的θ,嘈杂的噪音显示测量,绿线是估计的θ。该结果表明,尽管摆动系统是非线性的,但是使用扩展的卡尔曼滤波器使我们对θ的良好估计。但请注意,如果您的系统中有更严重的非线性,则扩展卡尔曼滤波器可能不足以处理系统中的非线性。但在这种情况下,您可以使用一个Unscented Kalman筛选器,您可以在控制系统工具箱中找到。
In this simulation, we showed how to estimate states of a nonlinear system using the extended Kalman filter. If you’re interested in running state estimation on your hardware in real time, you can generate code from this block and deploy it to your hardware. Remember that Kalman filter algorithm consists of two steps: the prediction and the correction. If you look at the generated code, you’ll recognize functions that take care of the calculation of these algorithm steps. This code snippet for example shows how the correction is calculated.
在这里,我们总结了我们对卡尔曼过滤器的讨论。在这个系列中,我们已经讨论了为什么你将使用卡尔曼过滤器,它们是什么,如何处理非线性系统中的状态估计,我们还在Simulink中展示了示例。金宝app我们将继续控制关于不同控制主题的技术谈判。与此同时,随意留下任何意见并分享您对未来主题的建议。
Featured Product
选择网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:。
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.