女人被狂躁到高潮视频免费无遮挡,内射人妻骚骚骚,免费人成小说在线观看网站,九九影院午夜理论片少妇,免费av永久免费网址

當(dāng)前位置:首頁(yè) > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]一、卡爾曼濾波九軸融合算法stm32嘗試1、Kalman濾波文件[.h已經(jīng)封裝為結(jié)構(gòu)體] 1 /* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics-> All rights reserved-> 2 3 This software may be distributed and modi

一、卡爾曼濾波九軸融合算法stm32嘗試



1、Kalman濾波文件[.h已經(jīng)封裝為結(jié)構(gòu)體]



1 /* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics-> All rights reserved->

2

3 This software may be distributed and modified under the terms of the GNU

4 General Public License version 2 (GPL2) as published by the Free Software

5 Foundation and appearing in the file GPL2->TXT included in the packaging of

6 this file-> Please note that GPL2 Section 2[b] requires that all works based

7 on this software must also be made publicly available under the terms of

8 the GPL2 ("Copyleft")->

9

10 Contact information

11 -------------------

12

13 Kristian Lauszus, TKJ Electronics

14 Web : http://www->tkjelectronics->com

15 e-mail : kristianl@tkjelectronics->com

16 */

17

18 #ifndef _Kalman_h

19 #define _Kalman_h

20 struct Kalman {

21 /* Kalman filter variables */

22 double Q_angle; // Process noise variance for the accelerometer

23 double Q_bias; // Process noise variance for the gyro bias

24 double R_measure; // Measurement noise variance - this is actually the variance of the measurement noise

25

26 double angle; // The angle calculated by the Kalman filter - part of the 2x1 state vector

27 double bias; // The gyro bias calculated by the Kalman filter - part of the 2x1 state vector

28 double rate; // Unbiased rate calculated from the rate and the calculated bias - you have to call getAngle to update the rate

29

30 double P[2][2]; // Error covariance matrix - This is a 2x2 matrix

31 double K[2]; // Kalman gain - This is a 2x1 vector

32 double y; // Angle difference

33 double S; // Estimate error

34 };

35

36 void Init(struct Kalman* klm){

37 /* We will set the variables like so, these can also be tuned by the user */

38 klm->Q_angle = 0.001;

39 klm->Q_bias = 0.003;

40 klm->R_measure = 0.03;

41

42 klm->angle = 0; // Reset the angle

43 klm->bias = 0; // Reset bias

44

45 klm->P[0][0] = 0; // Since we assume that the bias is 0 and we know the starting angle (use setAngle), the error covariance matrix is set like so - see: http://en->wikipedia->org/wiki/Kalman_filter#Example_application->2C_technical

46 klm->P[0][1] = 0;

47 klm->P[1][0] = 0;

48 klm->P[1][1] = 0;

49 }

50

51 // The angle should be in degrees and the rate should be in degrees per second and the delta time in seconds

52 double getAngle(struct Kalman * klm, double newAngle, double newRate, double dt) {

53 // KasBot V2 - Kalman filter module - http://www->x-firm->com/?page_id=145

54 // Modified by Kristian Lauszus

55 // See my blog post for more information: http://blog->tkjelectronics->dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it

56

57 // Discrete Kalman filter time update equations - Time Update ("Predict")

58 // Update xhat - Project the state ahead

59 /* Step 1 */

60 klm->rate = newRate - klm->bias;

61 klm->angle += dt * klm->rate;

62

63 // Update estimation error covariance - Project the error covariance ahead

64 /* Step 2 */

65 klm->P[0][0] += dt * (dt*klm->P[1][1] - klm->P[0][1] - klm->P[1][0] + klm->Q_angle);

66 klm->P[0][1] -= dt * klm->P[1][1];

67 klm->P[1][0] -= dt * klm->P[1][1];

68 klm->P[1][1] += klm->Q_bias * dt;

69

70 // Discrete Kalman filter measurement update equations - Measurement Update ("Correct")

71 // Calculate Kalman gain - Compute the Kalman gain

72 /* Step 4 */

73 klm->S = klm->P[0][0] + klm->R_measure;

74 /* Step 5 */

75 klm->K[0] = klm->P[0][0] / klm->S;

76 klm->K[1] = klm->P[1][0] / klm->S;

77

78 // Calculate angle and bias - Update estimate with measurement zk (newAngle)

79 /* Step 3 */

80 klm->y = newAngle - klm->angle;

81 /* Step 6 */

82 klm->angle += klm->K[0] * klm->y;

83 klm->bias += klm->K[1] * klm->y;

84

85 // Calculate estimation error covariance - Update the error covariance

86 /* Step 7 */

87 klm->P[0][0] -= klm->K[0] * klm->P[0][0];

88 klm->P[0][1] -= klm->K[0] * klm->P[0][1];

89 klm->P[1][0] -= klm->K[1] * klm->P[0][0];

90 klm->P[1][1] -= klm->K[1] * klm->P[0][1];

91

92 return klm->angle;

93 }

94

95 void setAngle(struct Kalman* klm, double newAngle) { klm->angle = newAngle; } // Used to set angle, this should be set as the starting angle

96 double getRate(struct Kalman* klm) { return klm->rate; } // Return the unbiased rate

97

98 /* These are used to tune the Kalman filter */

99 void setQangle(struct Kalman* klm, double newQ_angle) { klm->Q_angle = newQ_angle; }

100 void setQbias(struct Kalman* klm, double newQ_bias) { klm->Q_bias = newQ_bias; }

101 void setRmeasure(struct Kalman* klm, double newR_measure) { klm->R_measure = newR_measure; }

102

103 double getQangle(struct Kalman* klm) { return klm->Q_angle; }

104 double getQbias(struct Kalman* klm) { return klm->Q_bias; }

105 double getRmeasure(struct Kalman* klm) { return klm->R_measure; }

106


2、I2C總線代碼[這里把MPU和HMC掛接到上面,通過(guò)改變SlaveAddress的值來(lái)和不同的設(shè)備通信]



1 #include "stm32f10x.h"

2

3 /*標(biāo)志是否讀出數(shù)據(jù)*/

4 char test=0;

5 /*I2C從設(shè)備*/

6 unsigned char SlaveAddress;

7 /*模擬IIC端口輸出輸入定義*/

8 #define SCL_H GPIOB->BSRR = GPIO_Pin_10

9 #define SCL_L GPIOB->BRR = GPIO_Pin_10

10 #define SDA_H GPIOB->BSRR = GPIO_Pin_11

11 #define SDA_L GPIOB->BRR = GPIO_Pin_11

12 #define SCL_read GPIOB->IDR & GPIO_Pin_10

13 #define SDA_read GPIOB->IDR & GPIO_Pin_11

14

15 /*I2C的端口初始化---------------------------------------*/

16 void I2C_GPIO_Config(void)

17 {

18 GPIO_InitTypeDef GPIO_InitStructure;

19

20 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;

21 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

22 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;

23 GPIO_Init(GPIOB, &GPIO_InitStructure);

24

25 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;

26 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

27 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;

28 GPIO_Init(GPIOB, &GPIO_InitStructure);

29 }

30

31 /*I2C的延時(shí)函數(shù)-----------------------------------------*/

32 void I2C_delay(void)

33 {

34 u8 i=30; //這里可以優(yōu)化速度 ,經(jīng)測(cè)試最低到5還能寫(xiě)入

35 while(i)

36 {

37 i--;

38 }

39 }

40

41 /*I2C的等待5ms函數(shù)--------------------------------------*/

42 void delay5ms(void)

43 {

44 int i=5000;

45 while(i)

46 {

47 i--;

48 }

49 }

50

51 /*I2C啟動(dòng)函數(shù)-------------------------------------------*/

52 bool I2C_Start(void)

53 {

54 SDA_H;

55 SCL_H;

56 I2C_delay();

57 if(!SDA_read)return FALSE; //SDA線為低電平則總線忙,退出

58 SDA_L;

59 I2C_delay();

60 if(SDA_read) return FALSE; //SDA線為高電平則總線出錯(cuò),退出

61 SDA_L;

62 I2C_delay();

63 return TRUE;

64 }

65

66 /*I2C停止函數(shù)-------------------------------------------*/

67 void I2C_Stop(void)

68 {

69 SCL_L;

70 I2C_delay();

71 SDA_L;

72 I2C_delay();

73 SCL_H;

74 I2C_delay();

75 SDA_H;

76 I2C_delay();

77 }

78

7

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專(zhuān)欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

Sept. 8, 2025 ---- 根據(jù)TrendForce集邦咨詢最新調(diào)查,2025年第二季NVIDIA(英偉達(dá)) Blackwell平臺(tái)規(guī)?;鲐洠约氨泵繡SP業(yè)者持續(xù)擴(kuò)大布局General Server(通用型...

關(guān)鍵字: SSD DDR4 服務(wù)器

Sept. 4, 2025 ---- Apple(蘋(píng)果)即將發(fā)布iPhone 17、iPhone 17 Air(暫名)、iPhone 17 Pro及Pro Max四款旗艦新機(jī),除了外觀辨識(shí)度升級(jí),處理器性能、散熱和拍攝功...

關(guān)鍵字: iPhone 16 A19處理器 折疊機(jī)

Sept. 3, 2025 ---- 根據(jù)TrendForce集邦咨詢最新發(fā)布的《2025近眼顯示市場(chǎng)趨勢(shì)與技術(shù)分析》報(bào)告,2025年隨著國(guó)際品牌陸續(xù)推出AR眼鏡原型,以及Meta預(yù)計(jì)在近期發(fā)布AR眼鏡Celeste,市...

關(guān)鍵字: AR眼鏡 OLED

Sept. 2, 2025 ---- TrendForce集邦咨詢表示,2025年第二季DRAM產(chǎn)業(yè)因一般型DRAM (Conventional DRAM)合約價(jià)上漲、出貨量顯著增長(zhǎng),加上HBM出貨規(guī)模擴(kuò)張,整體營(yíng)收為3...

關(guān)鍵字: DRAM 智能手機(jī) ASP

Sept. 1, 2025 ---- 根據(jù)TrendForce集邦咨詢最新調(diào)查,2025年第二季因中國(guó)市場(chǎng)消費(fèi)補(bǔ)貼引發(fā)的提前備貨效應(yīng),以及下半年智能手機(jī)、筆電/PC、Server新品所需帶動(dòng),整體晶圓代工產(chǎn)能利用率與出貨...

關(guān)鍵字: 晶圓代工 智能手機(jī) 筆電

Aug. 28, 2025 ---- 根據(jù)TrendForce集邦咨詢最新調(diào)查,2025年第二季NAND Flash產(chǎn)業(yè)雖面臨平均銷(xiāo)售價(jià)格(ASP)小幅下滑,所幸原廠減產(chǎn)策略緩解供需失衡,疊加中、美兩大市場(chǎng)政策推動(dòng),整體...

關(guān)鍵字: NAND Flash SSD AI

Aug. 26, 2025 ---- NVIDIA(英偉達(dá))近日推出的Jetson Thor被視為機(jī)器人的物理智慧核心,以Blackwell GPU、128 GB記憶體堆疊出2070 FP4 TFLOPS AI算力,是前...

關(guān)鍵字: 機(jī)器人 大型語(yǔ)言模型 AI算力

Aug. 21, 2025 ---- 根據(jù)TrendForce集邦咨詢最新液冷產(chǎn)業(yè)研究,隨著NVIDIA GB200 NVL72機(jī)柜式服務(wù)器于2025年放量出貨,云端業(yè)者加速升級(jí)AI數(shù)據(jù)中心架構(gòu),促使液冷技術(shù)從早期試點(diǎn)邁...

關(guān)鍵字: AI 數(shù)據(jù)中心 服務(wù)器

除了充電電路外,鋰電池的放電過(guò)程也需要保護(hù)。鋰電池的放電電壓不能低于3.0V,否則電池壽命會(huì)大幅縮短。為了實(shí)現(xiàn)這一保護(hù),工程師們?cè)O(shè)計(jì)了DW01芯片與8205 MOS管的電路組合。DW01芯片能夠監(jiān)控鋰電池的放電電壓和電流...

關(guān)鍵字: 鋰電池 電池

在PCB設(shè)計(jì)的宏偉藍(lán)圖中,布局與布線規(guī)則猶如精密樂(lè)章中的指揮棒,是鑄就電路板卓越性能、堅(jiān)不可摧的可靠性及經(jīng)濟(jì)高效的制造成本的靈魂所在。恰如一位巧手的園藝師,合理的布局藝術(shù)性地編排著每一寸空間,既削減了布線交織的繁復(fù)迷宮,...

關(guān)鍵字: PCB 電路板
關(guān)閉