inavFilter 惯导融合算法



    typedef struct estimatorStruct
    {
        float pos[3];
        float vel[3];
        float acc[3];
    }estimator_s;
/**
 * @brief: 根据位置加速度来计算位置和速度 
Inertial filter, implementation taken from PX4 implementation by Anton Babushkin <rk3dov@gmail.com>
 * @param {int} axis
 * @param {float} dt
 * @param {float} acc
 * @return {*}
 */
void inavFilterPredict(estimator_s *estimat, int axis, float dt, float acc)
{
    estimat->pos[axis] += estimat->vel[axis] * dt + acc * dt * dt / 2.0f; //s = s + v*t + 1/2*a*t^t
    estimat->vel[axis] += acc * dt; //v=v+a*t
}
/*位置校正*/
void inavFilterCorrectPos(estimator_s *estimat, int axis, float dt, float error, float weight)
{
    float ewdt = error * weight * dt;
    estimat->pos[axis] += ewdt;
    estimat->vel[axis] += weight * ewdt;
}
/*速度校正*/
void inavFilterCorrectVel(estimator_s *estimat, int axis, float dt, float error, float weight)
{
    estimat->vel[axis] += error * weight * dt;
}

程序原理:

1. void inavFilterPredict(estimator_s *estimat, int axis, float dt, float acc)

通过加速度acc和时间dt的积分直接出算位移和速度,加速度计有误差时,积分就会不断的累计误差,速度就不可能为0,位移也会一直往一个方向增加。

2. void inavFilterCorrectPos(estimator_s *estimat, int axis, float dt, float error, float weight)

通过另外一个位移来修正上面的位移误差,那修正时就必须要知道误差是多少,所以要有error,如果另外一个位移计的准确度是100%,那weight就是1 ,结果加上这个error*1*dt就等于另外一个位移计了。准确度是不可能100%,那weight也不要大于1。weight就是另外一个位移计的权重/可信度。位移的修正值是e*w*dt,速度的修正值是e*w*dt*dt. 误差是不断变化的,所以修正修值也是不断变化的。误差是位移的误差。

3.void inavFilterCorrectVel(estimator_s *estimat, int axis, float dt, float error, float weight)

上面修正了位移和速度,但如果结果速度的修正还不够的话,同理也可以再给速度单独一个修正的权重。这时的误差是速度的误差,修正值是e*w*dt

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值