
Best Ever Introduction into Baye's Filter In Robotics
Finally Understanding Kalman Filters Through Code and Animations
Simultaneous Localization and Mapping (SLAM) is one of the most elegant problems in robotics. How does a robot figure out where it is while simultaneously building a map of an unknown environment? The answer lies at the heart of probabilistic robotics — and the Kalman Filter (or more generally, the Bayes Filter) is the superstar algorithm that makes it possible.
In this blog, I’ll take you on a visual, step-by-step journey from basic state estimation to a full working filter. No heavy mathematical proofs — just clear intuition, beautiful diagrams, and cool animations that make the concepts stick.
The Big Idea: Belief and Uncertainty
Robots never know exactly where they are. Instead, they maintain a belief — a probability distribution over possible positions.
Starting with Zero Knowledge
In a simple 1D world, the robot begins completely lost:

Every position has equal probability. This is pure uncertainty.
First Hint of Information
After receiving some initial data, the belief becomes a Gaussian centered around a likely position:

The width of this bell curve (controlled by σ) represents how uncertain the robot is.
Predict Step: Motion Introduces More Uncertainty
When the robot moves, it uses its motor commands (odometry) to predict the new position. But real motion is noisy.

bel(xt) = ∫ p(xt | ut, xt-1) * bel(xt-1) dxt-1This is the prediction step. Notice how the curve gets wider and shorter with each movement — uncertainty grows.
But when sensor Correction is added, the uncertainty reduces.

The sensor data and the data from wheel sensors are fused together for correction. But if the sensor is damaged it starts giving wrong readings, making the estiamte wrong

Code Snippet (from 2_motion_model_prediction_step1.py):

From 1D to 2D: Odometry Motion Model
Real robots operate in 2D space with position (x, y) and orientation θ.

Animated Prediction in 2D
Watch the uncertainty cloud grow as the robot drives:

Code Snippet (from 5_odometry_motion_model_prediction_step2D.py):

Correct Step: Sensors Save the Day
Prediction alone leads to drift. Sensors (especially LiDAR) provide the crucial correction.
bel(x_t) = η · p(z_t | x_t) · bel(\bar{x}_t)- Wide curve = motion prediction
- Sharp likelihood = sensor reading
- Multiplication = sharp, confident belief
• Predict: Belief spreads (less certain)
• Correct: Belief sharpens (more certain)
This Predict-Correct cycle is the essence of the Kalman Filter. The sensor model is responsible for adding correction to prediction.
Sensor Models: How Robots “See” the World
Chosen sensor Model: Beam-Endpoint Model (great for LiDAR)

Bright areas indicate positions where the current scan matches well:

Live Laser Interaction:

The Full Bayes / Kalman Filter
Everything comes together in one beautiful loop:

You can clearly see:
- Uncertainty growing during motion
- The belief collapsing back to high confidence when sensor data arrives
- The robot staying accurately localized over time
Code Snippet (core of 7_full_Bayes_filter_kalman_filter.py):


This is Kalman Filter intuition at its finest — elegant, visual, and practical.
From Theory to Real-World Robots
These concepts scale beautifully. The same principles power self-driving cars, drone navigation, and vacuum robots.
I’ve taken this knowledge and applied it to a real Roomba-style robot in a physical room. The transition from 1D animations to real hardware is incredibly rewarding.
See the github Link Below
Final Thoughts
Kalman Filters aren’t scary once you see them in action. They are simply a smart way of answering:
“What does my motion tell me?” × “What does my sensor tell me?” = “Where am I most likely now?”
By starting simple (1D), moving to 2D, adding realistic sensor models, and watching the animations, you build real intuition that no textbook alone can give.
If you want to truly understand SLAM and Kalman Filters, don’t just read — visualize, animate, and implement.
The journey from researcher to engineer mindset is worth every line of code.
More from the Blog

How to Install Fusion 360 that doesn't expire
Want to use Fusion 360 for free without the 30-day limit? Learn how to legally download and install the official, non-expiring Fusion 360 personal license.

How to Train and Test An AI model on edge Impulse
This blog includes how to train an Object Localization Model on Edge impulse. We will train this model to recognize cubes of different colors. The blog will also include some tips to getting better Test Results from your model.

3D Modelling & Printing – Step by Step
TDesign cubes that will be used to Train a basic Edge impulse AI model to classify Cubes (Further Used with Robotic Arm) - Skills: 3D modelling, 3D printing