Files
bf_original_balance_chassis/application/chassis/speed_estimation.h

28 lines
1.0 KiB
C
Raw Normal View History

#include "balance.h"
#include "user_lib.h"
#include "ins_task.h"
#include "general_def.h"
/**
* @brief 使
* @todo w和dw的滤波,w和dw均小于一定值时,dw导致的角加速度
*
* @param lp
* @param rp
* @param cp
* @param imu imu数据
* @param delta_t
*/
void SpeedEstimation(LinkNPodParam *lp, LinkNPodParam *rp, ChassisParam *cp, INS_t *imu, float delta_t)
{
// 修正轮速和距离
lp->wheel_w = lp->w_ecd + lp->phi2_w - cp->pitch_w; // 减去和定子固连的phi2_w
rp->wheel_w = rp->w_ecd + rp->phi2_w - cp->pitch_w;
// 以轮子为基点,计算机体两侧髋关节处的速度
lp->body_v = lp->wheel_w * WHEEL_RADIUS + lp->leg_len * lp->theta_w + lp->legd * msin(lp->theta);
rp->body_v = rp->wheel_w * WHEEL_RADIUS + rp->leg_len * rp->theta_w + rp->legd * msin(rp->theta);
cp->vel = cp->vel_m = (lp->body_v + rp->body_v) / 2; // 机体速度(平动)为两侧速度的平均值
cp->dist = cp->dist + cp->vel * delta_t;
}