FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Fusion/Examples/ExampleAhrsWithoutMagnetometer.c at master · octdrone/Fusion · GitHub
octdrone
/
Fusion
Public
forked from
bmswgnp/Fusion
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Fusion
/
Examples
/
ExampleAhrsWithoutMagnetometer.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (45 loc) · 2.68 KB
Breadcrumbs
Fusion
/
Examples
/
ExampleAhrsWithoutMagnetometer.c
Copy path
File metadata and controls
59 lines (45 loc) · 2.68 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include
"..\Fusion\Fusion.h"
#include
<stdio.h>
FusionBias
fusionBias
;
FusionAhrs
fusionAhrs
;
float
samplePeriod
=
0.01f
;
// replace this value with actual sample period in seconds
FusionVector3
gyroscopeSensitivity
=
{
.
axis
.
x
=
1.0f
,
.
axis
.
y
=
1.0f
,
.
axis
.
z
=
1.0f
,
};
// replace these values with actual sensitivity in degrees per second per lsb as specified in gyroscope datasheet
FusionVector3
accelerometerSensitivity
=
{
.
axis
.
x
=
1.0f
,
.
axis
.
y
=
1.0f
,
.
axis
.
z
=
1.0f
,
};
// replace these values with actual sensitivity in g per lsb as specified in accelerometer datasheet
int
main
() {
// Initialise gyroscope bias correction algorithm
FusionBiasInitialise
(
&
fusionBias
,
0.5f
,
samplePeriod
);
// stationary threshold = 0.5 degrees per second
// Initialise AHRS algorithm
FusionAhrsInitialise
(
&
fusionAhrs
,
0.5f
);
// gain = 0.5
// The contents of this do while loop should be called for each time new sensor measurements are available
do
{
// Calibrate gyroscope
FusionVector3
uncalibratedGyroscope
=
{
.
axis
.
x
=
0.0f
,
/* replace this value with actual gyroscope x axis measurement in lsb */
.
axis
.
y
=
0.0f
,
/* replace this value with actual gyroscope y axis measurement in lsb */
.
axis
.
z
=
0.0f
,
/* replace this value with actual gyroscope z axis measurement in lsb */
};
FusionVector3
calibratedGyroscope
=
FusionCalibrationInertial
(
uncalibratedGyroscope
,
FUSION_ROTATION_MATRIX_IDENTITY
,
gyroscopeSensitivity
,
FUSION_VECTOR3_ZERO
);
// Calibrate accelerometer
FusionVector3
uncalibratedAccelerometer
=
{
.
axis
.
x
=
0.0f
,
/* replace this value with actual accelerometer x axis measurement in lsb */
.
axis
.
y
=
0.0f
,
/* replace this value with actual accelerometer y axis measurement in lsb */
.
axis
.
z
=
1.0f
,
/* replace this value with actual accelerometer z axis measurement in lsb */
};
FusionVector3
calibratedAccelerometer
=
FusionCalibrationInertial
(
uncalibratedAccelerometer
,
FUSION_ROTATION_MATRIX_IDENTITY
,
accelerometerSensitivity
,
FUSION_VECTOR3_ZERO
);
// Update gyroscope bias correction algorithm
calibratedGyroscope
=
FusionBiasUpdate
(
&
fusionBias
,
calibratedGyroscope
);
// Update AHRS algorithm
FusionAhrsUpdateWithoutMagnetometer
(
&
fusionAhrs
,
calibratedGyroscope
,
calibratedAccelerometer
,
samplePeriod
);
// Print Euler angles
FusionEulerAngles
eulerAngles
=
FusionQuaternionToEulerAngles
(
FusionAhrsGetQuaternion
(
&
fusionAhrs
));
printf
(
"Roll = %0.1f, Pitch = %0.1f, Yaw = %0.1f\r\n"
,
eulerAngles
.
angle
.
roll
,
eulerAngles
.
angle
.
pitch
,
eulerAngles
.
angle
.
yaw
);
}
while
(false);
}
Back
|
FazBrowse Home
|
New Git URL