# IMU and encoder fusion

I'm trying to simulate data fusion for a 4-wheeled mobile robot using ekf and am using IMU and wheel encoders as sensors,where IMU measures linear acceleration and angular velocity and encoder measures left and right wheel linear velocity all in body frame. now I need the measurement data for both sensors in a way that they fit each other(I mean acceleration in IMU is related to left and right velocity in encoder) but can't make the connection .I really appreciate it if anyone can help me with that.

You are setting up a filter to estimate a overall state of the robot. This state can consist of whatever you choose: orientation, position, velocity, acceleration, temperature, mood, etc. For your purposes, you have very good information to estimate the forward and angular velocity of the robot. (Though you could estimate the orientation and position as well, but this would be less accurate over time as drift accumulates).

It seems like you have an idea of how to get the velocity of the robot from the wheel encoders. You can get similar velocity measurements or estimations from your IMU.

For an example, lets look at the forward velocity of your robot (with zero angular velocity for now). You have two sensor measurements of this to feed into your filter: the wheel encoders and the IMU linear acceleration. The wheel encoders are really the position of the wheels at various update rates, so you're differentiating those positions to get velocity. The linear acceleration can be integrated to also estimate velocity.

vel = vel_prev + accel*dt

Now you have two estimates of forward velocity that can be fed into a filter. You can think of these as correcting each other; velocity measurements from the wheel encoders will give you accurate long-term information, but may be susceptible to wheel slippage. The IMU will give you short term information that is accurate in a global sense, but will quickly accumulate errors.

For angular velocity, you have a direct measurement from the IMU gyros and you have an indirect measurement from the differences in wheel encoder velocities. Again, these can be combined into a filter.

From the encoders you pick "tics" (n) per time unit (t), with this you can calculate the angular velocity ($$\omega$$) of each wheel.

$$\omega = \frac{2\pi n} { N t}$$

Where N is the total amount of pulses per revolution.

After calculating the angular velocities you can calculate the linear velocity of each wheel.

$$v = \omega * R$$, where R is the wheel radius.

And then with inverse kinematics you are able to calculate the velocity of your vehicle. The problem is that you give too less information about your robot e.g. what kind of wheels you have, can they drive both directions?

• That's not exactly what I'm having problems with,I know the equations of each sensor seperately. but I wanna simulate and compare the results of each sensor . So left and right wheel velocities(encoder inputs in simulation) need to be related to IMU acceleration and and angular velocity(IMU inputs in simulation). I have problem calculating these: take it this way: if I have( ax,ay,az wx wy wz ) as IMU measurements, what will be left and right velocities for encoder accordingly? – mahsa Apr 15 '19 at 4:19
• As I told you above from the wheel velocities with the inverse kinematics you can find the velocity of the car, but you don't mention something for your robot model. For example for differential drive inverse kinematics you can find here which is the basic model. Something more advanced we can find here – nionios Apr 15 '19 at 19:04