# Unit 2: Creating the matrix for ekf_localization.yaml file

In unit 2, Fuse sensor data to improve localization

While setting up the 5X3 matrix for sensor config, we are ignoring the pose values, resulting in the matrix as shown:

The justification for doing so was (below is the quote from the course) :

In most of the cases (including this one), the odometry data is generated using a wheel encoder. This means that its velocity, orientation, and position data are all generated from the same source. So, in this case, we don’t want to use all the values since we would be feeding duplicate information into the filter. Instead, it’s best to just use the velocities.

Question 1: what do you mean by duplicate information? can you give me an example?
Questions 2: Can you explain why we are ignoring the pose values in the matrix, since the data at position Y is the very thing we are filtering?

Question 3a:

In odom0,We are considering the linear velocity value at Y, by setting it to True in the matrix. Why are we considering this when the robot can move only based on linear X velocity?

Below is a quote from the course that justified this:

Awesome! But wait… there’s one more important thing to comment on. If the odometry message reports a 0 value for linear velocity in Y (and its covariance is NOT inflated to a large value), it’s best to feed that value to the filter. As a 0 measurement, in this case, indicates that the robot cannot ever move in that direction, it serves as a perfectly valid measurement.

Question 3b:
in imu0 matrix, why are we setting the Yaw to True when we set it to False in odom0 sensor?

Question 4:
In the ekf_localization.yaml file, we are using a two_d_mode parameter, defined as shown below:

• two_d_mode: This variable indicates if your robot is working in a 2D environment. If set to true, all the 3D pose variables will be set to 0.

Now when we set this to true, does this overwrite the matrix content we had manually set? Can we just leave the 3D pose data empty in the matrix and wait for two_d_mode to fill up the missing areas on its own during program execution?

Question 5:
Now when we populate the matrix using True or False, we are doing this by terming everything as False that has no chance of happening and leaving True the rest since we know that they can happen. Is this right? or is there more to it?

Question 1: what do you mean by duplicate information? can you give me an example?
For example, a robot has a speed sensor in the wheels. Thsi means that the data recovered form the sensors is speed, not distance. But then we make a calculation based on time that will give us the distance traveled. This distance traveled data is based on the speed sensor data, so in reality its a duplicate of the speed data, all the variance, the errors, everything depends on the speed data.

Questions 2: Can you explain why we are ignoring the pose values in the matrix, since the data at position Y is the very thing we are filtering?
Sam reason as above mentioned, the raw data is NOT position , but speed or whatever.

n odom0,We are considering the linear velocity value at Y, by setting it to True in the matrix. Why are we considering this when the robot can move only based on linear X velocity?

Because the odom sensor DOES generate X and Y data. The robot CAN move in Y axis in space, what it can not do is move laterally only in Y. It has to turn and move to be able to move in some way in Y.

Question 3b:
in imu0 matrix, why are we setting the Yaw to True when we set it to False in odom0 sensor?

Imu DO measure YAW, while odometry in reality normally ar NOT used for YAW movements because its very imprecise for that. IMU use compas and inertial measurement to measure just that, orientation changes, but are really bad at for example distance traveled measurements.

Question 4:
In the ekf_localization.yaml file, we are using a two_d_mode parameter, defined as shown below:

Because 2D mode makes some optimizations in the ekf that makes it faster and easier to converge, if we don’t do this, although we can set to 0 the Z axis, this will be computed and therefore make the convergence slower.

Question 5:
Now when we populate the matrix using True or False, we are doing this by terming everything as False that has no chance of happening and leaving True the rest since we know that they can happen. Is this right? or is there more to it?

Basically that’s the idea. We set to false all that that is physically impossible or that the sensor cant generate , or that it generates based on calculations of another parameter that is a real physics data.