Rleg
2
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Macros
Groups
Pages
calibration.c
Go to the documentation of this file.
1
#include<stdio.h>
2
#include<stdlib.h>
3
#include "
communication/communication.h
"
4
#include "
calibration.h
"
5
//#include <string.h>
6
7
8
void
calibrate_all
(
IMU_DATA_STRUCT
*
imu_data
)
9
{
10
calibrate_imu
(imu_data);
11
return
;
12
}
13
14
void
calibrate_imu
(
IMU_DATA_STRUCT
*
imu_data
)
15
{
16
// With this parameters, the vectors of acceleration and magnetic field will have norm = 1 theorically (i.e. in g or G)
17
imu_data->
calib
.
acc
.
x
= ((double)imu_data->
acc
.
x
-
ACC_BIAS_X
)/
ACC_FS_X
;
18
imu_data->
calib
.
acc
.
y
= ((double)imu_data->
acc
.
y
-
ACC_BIAS_Y
)/
ACC_FS_Y
;
19
imu_data->
calib
.
acc
.
z
= ((double)imu_data->
acc
.
z
-
ACC_BIAS_Z
)/
ACC_FS_Z
;
20
21
imu_data->
calib
.
mag
.
x
= ((double)imu_data->
mag
.
x
-
MAG_BIAS_X
)/
MAG_FS_X
;
22
imu_data->
calib
.
mag
.
y
= ((double)imu_data->
mag
.
y
-
MAG_BIAS_Y
)/
MAG_FS_Y
;
23
imu_data->
calib
.
mag
.
z
= ((double)imu_data->
mag
.
z
-
MAG_BIAS_Z
)/
MAG_FS_Z
;
24
25
// With this parameters, we consider right datasheet scale and we get in rad/s
26
imu_data->
calib
.
gyr
.
x
= ((double)imu_data->
gyr
.
x
-
GYR_BIAS_X
)*
GYR_FS_X
;
27
imu_data->
calib
.
gyr
.
y
= ((double)imu_data->
gyr
.
y
-
GYR_BIAS_Y
)*
GYR_FS_Y
;
28
imu_data->
calib
.
gyr
.
z
= ((double)imu_data->
gyr
.
z
-
GYR_BIAS_Z
)*
GYR_FS_Z
;
29
30
imu_data->
calib_temp
= ((double)imu_data->
temp
+13200)/280 + 35;
31
32
return
;
33
}
34
35
void
calibrate_enc
(
ENC_DATA_STRUCT
*
enc_data
){
36
enc_data->
calib
.
position
= ((
ENC_MAX
- enc_data->
position
)/
ENC_FS
);
37
}
ACC_FS_Y
#define ACC_FS_Y
Definition:
calibration.h:19
MAG_BIAS_X
#define MAG_BIAS_X
Definition:
calibration.h:22
communication.h
ACC_BIAS_X
#define ACC_BIAS_X
Definition:
calibration.h:15
MAG_BIAS_Y
#define MAG_BIAS_Y
Definition:
calibration.h:23
IMU_DATA_STRUCT::calibrated::mag
DATA_XYZ_DOUBLE mag
Definition:
communication.h:100
GYR_FS_X
#define GYR_FS_X
Definition:
calibration.h:33
enc_data
ENC_DATA_STRUCT enc_data
Definition:
main.c:31
calibrate_imu
void calibrate_imu(IMU_DATA_STRUCT *imu_data)
Calibrate imu sensors.
Definition:
calibration.c:14
IMU_DATA_STRUCT
Data of IMU structure.
Definition:
communication.h:93
DATA_XYZ::y
short int y
Definition:
communication.h:77
ACC_BIAS_Z
#define ACC_BIAS_Z
Definition:
calibration.h:17
calibrate_all
void calibrate_all(IMU_DATA_STRUCT *imu_data)
Calibrate all sensors.
Definition:
calibration.c:8
ENC_MAX
#define ENC_MAX
Definition:
calibration.h:39
MAG_BIAS_Z
#define MAG_BIAS_Z
Definition:
calibration.h:24
IMU_DATA_STRUCT::temp
short int temp
Definition:
communication.h:102
GYR_BIAS_Y
#define GYR_BIAS_Y
Definition:
calibration.h:31
GYR_BIAS_Z
#define GYR_BIAS_Z
Definition:
calibration.h:32
imu_data
IMU_DATA_STRUCT imu_data
Definition:
main.c:30
IMU_DATA_STRUCT::mag
DATA_XYZ mag
Magnetormeter Vector.
Definition:
communication.h:96
ENC_FS
#define ENC_FS
Definition:
calibration.h:38
IMU_DATA_STRUCT::calibrated::gyr
DATA_XYZ_DOUBLE gyr
Definition:
communication.h:99
ACC_FS_X
#define ACC_FS_X
Definition:
calibration.h:18
GYR_BIAS_X
#define GYR_BIAS_X
Definition:
calibration.h:30
MAG_FS_Y
#define MAG_FS_Y
Definition:
calibration.h:26
ENC_DATA_STRUCT
Definition:
encoder_functions.h:45
ACC_BIAS_Y
#define ACC_BIAS_Y
Definition:
calibration.h:16
IMU_DATA_STRUCT::acc
DATA_XYZ acc
Accel Vector.
Definition:
communication.h:94
ENC_DATA_STRUCT::calib
struct ENC_DATA_STRUCT::calibrate calib
ACC_FS_Z
#define ACC_FS_Z
Definition:
calibration.h:20
DATA_XYZ::z
short int z
Definition:
communication.h:78
GYR_FS_Z
#define GYR_FS_Z
Definition:
calibration.h:35
ENC_DATA_STRUCT::position
unsigned short int position
Definition:
encoder_functions.h:47
IMU_DATA_STRUCT::calib_temp
double calib_temp
Definition:
communication.h:103
ENC_DATA_STRUCT::calibrate::position
unsigned short int position
Definition:
encoder_functions.h:49
calibration.h
IMU_DATA_STRUCT::calib
struct IMU_DATA_STRUCT::calibrated calib
DATA_XYZ_DOUBLE::y
double y
Definition:
communication.h:86
IMU_DATA_STRUCT::calibrated::acc
DATA_XYZ_DOUBLE acc
Definition:
communication.h:98
IMU_DATA_STRUCT::gyr
DATA_XYZ gyr
Gyrometer Vector.
Definition:
communication.h:95
DATA_XYZ_DOUBLE::z
double z
Definition:
communication.h:87
DATA_XYZ::x
short int x
Definition:
communication.h:76
MAG_FS_Z
#define MAG_FS_Z
Definition:
calibration.h:27
calibrate_enc
void calibrate_enc(ENC_DATA_STRUCT *enc_data)
Calibrate encoder to return values in the rage of 0 to 90.
Definition:
calibration.c:33
MAG_FS_X
#define MAG_FS_X
Definition:
calibration.h:25
DATA_XYZ_DOUBLE::x
double x
Definition:
communication.h:85
GYR_FS_Y
#define GYR_FS_Y
Definition:
calibration.h:34
Generated on Tue Mar 18 2014 14:30:11 for Rleg by
1.8.6