- 19
- 0
- 约3.44万字
- 约 50页
- 2021-11-12 发布于江苏
- 举报
//IDG330 Mannual, 2mv= 1 度/s 的角速率 ,ad 读数 1024,3.3v, 那么每读数对应
3.223mV,所以每读数对应 3.223/2/180*PI= 0.028123 弧度/ 秒
static const double SEMICIRCLE_ARC = 57.29578; /* 半圆对应的弧度值 */
static const double GYRO_OPERATOR = 0.028123; /*AD 读取的陀螺仪数值对
应的弧度算子 */
/*kalman*/
static const double C_0 = 1;
static const double Q_angle=0.001, Q_gyro=0.003, R_angle=0.5,
dt=0.005;// 注意: dt 的取值为 kalman 滤波器采样时间
double P[2][2] = {{ 1, 0 },
{ 0, 1 }};
double Pdot[4] ={ 0,0,0,0};
double q_bias, angle_err, PCt_0, PCt_1, E, K_0, K_1, t_0, t_1;
double angle, angle_dot;
/*sensor*/
double sensorPort[6] = { 0, 1, 2, 3, 4, 5};/* 传感器地址 , 电路决
定 .accZ,gyroX, AD1, AD2, AD3, AD4*/
double sensorValue[6];/* 传感器的返回值 */
/* 传感器零点 0:Z 轴( 平行轴 ) 1: 陀螺仪中点 */
double sensorZero[2] = {499,505};
double sensorAdjusted[2];/* 传感器的返回值重整 */
//double provAngle;
/*moto*/
int E1 = 6;
int E2 = 9;
int M1 = 7;
int M2 = 8;
double deadAreaCompensation1 = 45,deadAreaCompensation2 = 35;
/*balance*/
double RATE[4] = { 0,0,0,0};/* 公式中的 4 个变量 */
double K[4] = { 60.45, 1.27, 125, 0.75};/* 公式中的 4 个常量 */
double K_AD[4] = { 1, 1, 1, 1};/* 公式中的 4 个常量 */
double wheel_ls[7];/* 左轮 :0: 编码器 1: 位移 (position) 2:position_dot
3:position_dot_filter 4:speedNeed 5:turnNeed 6:speedOutPut */
double wheel_rs[7];/* 右轮 :0: 编码器 1: 位移 (position) 2:position_dot
3:position_dot_filter 4:speedNeed 5:turnNeed 6:speedOutPut */
double Torque;/* 扭矩*/
unsigned int count,count2;
boolean OK=false;// 这个是误差达到一定程度后的系统关闭开关 .
int bf,X,Y;// 从无线端发来的命令
/*kalman*/
/*angle_m: 经过 atan2(ax,ay) 方法计算的偏角 , 弧度值
gyro_m: 经过初步减去零点的陀螺仪角速度值 , 弧度值
*/
void Kalman_Filter(double angle_m,double gyro_m)
{
angle+=(gyro_m-q_bias) * dt;
angle_err = angle_m - angle;
Pdot[0]=Q_angle - P[0][1] - P[1][0
您可能关注的文档
最近下载
- (二模)苏北七市2025届高三第二次调研测试化学试卷(含标准答案).pdf
- 家校协同育人实施方案.docx
- 《数学(拓展模块一)上下册》中职数学课程全套教学课件.pptx
- 桥梁、涵洞施工方案.docx VIP
- 2026年春教科版(新教材)小学科学三年级下册(全册)教学设计(附教材目录P131).pdf
- 2025年供应链管理知识考试试题及答案解析 .docx VIP
- 5G通信基站安装协议.docx
- 煤矿井下供电的三大保护细则.docx VIP
- Unit 1 - Unit 4 课文原文及中文翻译 2025-2026学年译林版英语八年级下册.docx VIP
- 法理学(中国人民大学) 超星尔雅学习通章节测试答案.docx VIP
原创力文档

文档评论(0)