Rleg  2
 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>
4 #include "calibration.h"
5 //#include <string.h>
6 
7 
9 {
10  calibrate_imu(imu_data);
11  return;
12 }
13 
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 
36  enc_data->calib.position = ((ENC_MAX - enc_data->position)/ENC_FS);
37 }
#define ACC_FS_Y
Definition: calibration.h:19
#define MAG_BIAS_X
Definition: calibration.h:22
#define ACC_BIAS_X
Definition: calibration.h:15
#define MAG_BIAS_Y
Definition: calibration.h:23
#define GYR_FS_X
Definition: calibration.h:33
ENC_DATA_STRUCT enc_data
Definition: main.c:31
void calibrate_imu(IMU_DATA_STRUCT *imu_data)
Calibrate imu sensors.
Definition: calibration.c:14
Data of IMU structure.
Definition: communication.h:93
short int y
Definition: communication.h:77
#define ACC_BIAS_Z
Definition: calibration.h:17
void calibrate_all(IMU_DATA_STRUCT *imu_data)
Calibrate all sensors.
Definition: calibration.c:8
#define ENC_MAX
Definition: calibration.h:39
#define MAG_BIAS_Z
Definition: calibration.h:24
#define GYR_BIAS_Y
Definition: calibration.h:31
#define GYR_BIAS_Z
Definition: calibration.h:32
IMU_DATA_STRUCT imu_data
Definition: main.c:30
DATA_XYZ mag
Magnetormeter Vector.
Definition: communication.h:96
#define ENC_FS
Definition: calibration.h:38
#define ACC_FS_X
Definition: calibration.h:18
#define GYR_BIAS_X
Definition: calibration.h:30
#define MAG_FS_Y
Definition: calibration.h:26
#define ACC_BIAS_Y
Definition: calibration.h:16
DATA_XYZ acc
Accel Vector.
Definition: communication.h:94
struct ENC_DATA_STRUCT::calibrate calib
#define ACC_FS_Z
Definition: calibration.h:20
short int z
Definition: communication.h:78
#define GYR_FS_Z
Definition: calibration.h:35
unsigned short int position
unsigned short int position
struct IMU_DATA_STRUCT::calibrated calib
DATA_XYZ gyr
Gyrometer Vector.
Definition: communication.h:95
short int x
Definition: communication.h:76
#define MAG_FS_Z
Definition: calibration.h:27
void calibrate_enc(ENC_DATA_STRUCT *enc_data)
Calibrate encoder to return values in the rage of 0 to 90.
Definition: calibration.c:33
#define MAG_FS_X
Definition: calibration.h:25
#define GYR_FS_Y
Definition: calibration.h:34