I am using some code made by someone else, to implement a kalman filter into my imu with arduino. I understand the vast majority of it and the maths behind it, but i am having some errors when implementing it which i cannot understand (serious lack of knowledge on typdefs and structs and initializing them). If someone could explain this error to me it would be much appreciated.
The header file contains this...
struct kalman_data{
float x1, x2, x3;
float p11, p12, p13,
p21, p22, p23,
p31, p32, p33;
float q1, q2, q3;
};
typedef struct _kalman_data kalman_data;
void kalman_data(kalman_data* data);
void kalman_calc(kalman_data* data, float z1, float z2);
My arduino code contains this..
kalman_data pitch_data;
kalman_data roll_data;
void loop(){
kalman_data(&pitch_data);
kalman_data(&roll_data);
kalman_calc(&pitch_data, pitch, gyro_yz);
kalman_calc(&roll_data, roll, gyro_xz);
}
And this is the error i get...
In file included from test.ino:2:0: E:\Users\Alexander\Documents\Arduino\libraries\Kalman/kalman.h:30:29: error: conflicting declaration 'typedef struct _kalman_data kalman_data'
typedef struct _kalman_data kalman_data;E:\Users\Alexander\Documents\Arduino\libraries\Kalman/kalman.h:17:8: error: 'struct kalman_data' has a previous declaration as 'struct kalman_data' struct kalman_data{
The
struct
definition is reserving the namekalman_data
and the typedef is trying to reserve the name again, for a struct called_kalman_data
. This causes the error.To rectify this, use
struct _kalman_data
and then the typedef will work as intended.