Mod5 Robotics
Mod5 Robotics
30-03- AICML,MEC,March 2
2026 2026
Obstacle avoidance
Bug algorithm - Vector Field Histogram -
Dynamic window approaches.
Example:
The robot wants to go straight to the [Link] a table
is blocking the [Link] robot moves around the
table and continues to the goal.
So the robot must avoid obstacles while moving.
30-03- AICML,MEC,March 4
2026 2026
What is Local Obstacle Avoidance?
•The robot has sensors (camera, lidar, ultrasonic).
•While moving, it continuously checks nearby obstacles.
•If it detects something, it changes its path immediately.
•So the robot decides based on current sensor
readings. Example
•Robot is moving → sensor detects a wall → robot turns slightly
→
continues moving.
This is called local decision making.
Example:
•Robot knows Goal is 10 meters north, it tries to move toward
the goal
while avoiding obstacles.
30-03- AICML,MEC,March 6
2026 2026
Global Map vs Local Information
•A global map means the robot already has a map of
the entire environment.
30-03- AICML,MEC,March 8
2026 2026
Obstacle Avoidance Algorithms
•These are methods that tell the robot how to move
when it sees obstacles.
•Different algorithms:
• Bug algorithm
Bug Algorithm
•The Bug algorithm is one of the simplest obstacle
avoidance algorithms.
idea:
• If a robot meets an
obstacle:
• It moves along the boundary of the obstacle
• It goes around the obstacle,then it move to the point where it
can leave the obstacle.
• Then it continues toward the goal
•This is called contour following or wall following.
•So the robot basically walks around the obstacle
until it can go toward the goal again.
30-03- AICML,MEC,March 1
2026 2026 0
Bug1 Algorithm
• Step 1
Robot moves straight toward the goal.
• Step 2
If it hits an obstacle, it cannot go straight.
• Step 3
Robot goes around the entire obstacle boundary.
• Step 4
During this full circle, it records the point closest to the goal.
• Step 5
After finishing the full loop, the robot moves to that closest point.
• Step 6
Then it continues moving toward the goal.
Important property
• Bug1 guarantees reaching the goal if the goal is reachable.
• But it is very inefficient because the robot must go around the whole
Even
obstacle if theonce
exit path appears early, it still completes
the loop.
30-03-2026 AICML,MEC,March 2026 11
30-03- AICML,MEC,March 1
2026 2026 2
Bug2 Algorithm (Improved Version)
•Bug2 improves Bug1.
•The robot does NOT circle the whole obstacle.
•Instead:
30-03- AICML,MEC,March 1
2026 2026 4
•Bug2 uses two robot behaviors (states):
-> GOALSEEK (SEEK)
•Robot tries to move toward the goal.
-> WALLFOLLOW
•Robot follows the obstacle boundary.
The robot switches between these two states.
30-03- AICML,MEC,March 15
2026 2026
:
• Else (if no) If the robot has not yet reached the goal, it
must continue navigating. Compute the forward speed
using the sonar sensor readings. Check if the robot is
currently in GOALSEEK mode (moving toward the goal).
Rotate the robot so that it faces the goal direction. Check
whether there is an obstacle in the direction of the goal.
If an obstacle blocks the path, switch to WALLFOLLOW
mode. End of GOALSEEK condition.
• Check if the robot is currently in WALLFOLLOW mode.
Compute the rotation needed to follow the obstacle
boundary (wall). Check if the path toward the goal is free
again. If the path is clear, switch back to GOALSEEK
mode. End of WALLFOLLOW condition.
• Send commands to the robot motors:
• forwardVel controls forward motion
• rotationVel controls turning motion
30-03-2026 AICML,MEC,March 2026 17
30-03- AICML,MEC,March 1
2026 2026 8
•Pseudocode for Differential Drive:Here is the extra
pseudocode that converts motion commands to
wheel speeds.
•function SetVelocity(forwardVel, rotationVel) //This function
receives motion commands from Bug2.
•leftWheel = forwardVel – rotationVel//Calculate speed
of the left wheel.
•rightWheel = forwardVel + rotationVel//Calculate speed of
the right wheel.
•setLeftMotor(leftWheel)//Send speed command to the
left wheel motor.
•setRightMotor(rightWheel)//Send speed command to the
right wheel motor.
•end function
Now the robot can actually move.
30-03- AICML,MEC,March 2
2026 2026 0
Vector field histogram
•Many simple algorithms (like Bug methods) use only the
most recent sensor readings.
Problem:
•If sensors do not detect obstacles early enough, the robot may:
• make poor navigation decisions
• fail in complex environments
Example:
•robot approaches a narrow corridor
•sensors detect obstacles too late
•robot cannot plan properly
30-03-2026 AICML,MEC,March 2026 21
Occupancy Grid
•The environment around the robot is divided into small cells.
•Each cell stores the probability of an obstacle.
30-03- AICML,MEC,March 2
2026 2026 2
• Polar The next step VFH converts the occupancy
a polar
Histogram: grid into This graph helps the robot understand:
histogram. which directions have obstacles
which directions are free to
move
The x-axis shows all
possible directions the
robot could move. The
vertical axis is labeled P.
This represents the
probability or strength of
obstacles in that direction.
The directions correspond to angles around the [Link] standing at the center and looking
around
360°.obstacle density in each direction. So it is called a polar representation(polar histogram).
Threshold
•Each bar corresponds to a direction (angle) around the robot.
•Height of bar = obstacle density or probability in that direction.
30-03- AICML,MEC,March 24
2026 2026
30-03- AICML,MEC,March 25
2026 2026
30-03- AICML,MEC,March 2
2026 2026 6
• Target Direction-Measures how well the direction aligns with the goal. If robot moves
directly toward
goal → low cost, Large deviation from goal → high cost
• Wheel Orientation-Measures how much the robot must turn its wheels. Large
turn = high cost, Small turn = preferred.
• Previous Direction-Encourages smooth movement, If robot suddenly changes direction →
cost
increases. This prevents zig-zag motion.
• Cost Function Weights: a->importance of goal direction, b->importance of
wheel orientation, c->importance of smooth motion
30-03-2026 AICML,MEC,March 2026 27
Steps:
• Identify free openings
30-03- AICML,MEC,March 3
2026 2026 0
Algorithm Summary: Vector Field Histogram
Advantages of VFH
Limitations
30-03- AICML,MEC,March 3
2026 2026 2
Comparison With Bug Algorithm
30-03- AICML,MEC,March 3
2026 2026 4
Key Idea of Dynamic Window Approach
•Instead of directly choosing a direction, the robot
chooses a velocity command.
•The robot evaluates possible combinations of:
• linear velocity (v) → forward speed
• angular velocity (ω) → turning speed
•From these combinations it chooses the safest motion.
30-03- AICML,MEC,March 3
2026 2026 6
30-03-2026 AICML,MEC,March 2026 37
Example:
•So in the next small time interval, the robot can only
reach some nearby velocities.
30-03- AICML,MEC,March 3
2026 2026 8
The Dynamic Window
•The dynamic window is simplyThe set of velocities that the
can reach in the next time step,
robot considering acceleration
limits.
•Graphically this appears as a small rectangular
region in velocity space.
•It is called dynamic because it depends on:
• current robot velocity
• acceleration capability
• As the robot moves, the window moves in velocity space.
• So the window changes dynamically every moment.
•Admissible Velocities:
• Velocities that allow the robot to stop before hitting an obstacle.
30-03- AICML,MEC,March 4
2026 2026 0
Local Dynamic Window Algorithm
•Step 1
Read sensor data and robot state.
•Step 2
Generate the velocity space (all possible (v, ω)).
•Step 3
Select the dynamic window based on acceleration limits.
•Step 4 Suppose:
Remove velocities that cause Robot speed = 1 m/s
Obstacle distance = 0.5
collisions. m Robot braking
distance = 1 m Then:
Remaining set → admissible Robot cannot stop before the
velocities. obstacle.
So: 41
1 m/s is NOT admissible-not safe
30-03-2026 AICML,MEC,March
2026
•Step 5
For each admissible
velocity: predict robot
trajectory compute
objective function.
Objective function
•we have a set of safe velocities(admissible velocities).
•But the robot must choose the best one.
•For this, the algorithm uses an objective function.
30-03- AICML,MEC,March 4
2026 2026 2
heading(v,ω) :Measures how well the robot's motion points toward the goal.
If the robot moves directly toward the goal → high score.
dist(v,ω) : Represents the distance to the nearest obstacle along the trajectory.
Large distance → safer path.
30-03- AICML,MEC,March 4
2026 2026 3
•Step 6
Select velocity with maximum objective score.
•Step 7
Send this velocity command to the robot.
•Step 8
Repeat the process at the next time step.
30-03- AICML,MEC,March 4
2026 2026 4
Global Dynamic Window Approach(GDWA)
•The Local Dynamic Window Approach (DWA) only
considers current robot velocity , nearby obstacles ,
goal direction
•But it does not consider the global structure of the
environment.
•Problem:
• The robot might:
• take inefficient paths
• get stuck in complex obstacle arrangements
• fail to find long-range routes
•So the Global Dynamic Window Approach adds
global path planning information.
30-03- AICML,MEC,March 4
2026 2026 6
NF1 (Navigation Function)
•NF1 is also called Grassfire algorithm.
•Its job is to compute distance from every free cell to the goal.
•It works on an occupancy grid
map. Occupancy Grid Map
•When a robot moves in an environment, it must know:
• where obstacles are
• where free space is
•But sensors (lidar, sonar, camera) only give local
measurements.
•So the robot stores this information in a map.
•One simple way to represent the environment is the occupancy
grid map.
•An occupancy grid map divides the environment into small
square cells.
•Each cell stores information about whether that location is
occupied by an obstacle or free.
30-03-2026 AICML,MEC,March 2026 47
NF1-Working
NF1 uses occupancy matrix to create a map that tells the robot which direction
30-03- AICML,MEC,March 4
2026 2026 8
•The robot simply moves toward cells with smaller
numbers. Example:
•Robot at value = 6
Neighbor cells =
5,7,8
•Robot chooses:
6→5→4→3→2→1→0
So the numbers create a global path toward the
30-03- AICML,MEC,March 5
2026 2026 2
Navigation Architectures
30-03- AICML,MEC,March 5
2026 2026 4
•You could write one huge program that does everything. But
that’s a
bad idea for real robots
•Why?
• If you change one part → everything breaks
• Hard to debug
• Not reusable
30-03- AICML,MEC,March 5
2026 2026 6
• Using a well-designed navigation architecture has ba
number of concrete advantages:
4. Focused Verification
• Each module can be verified independently
30-03- AICML,MEC,March 6
2026 2026 0
• Ensures correctness of specific functions
Example:Verify obstacle avoidance works correctly before integration
30-03- AICML,MEC,March 6
2026 2026 0
5. Independent Testing in Simulation
•High-level modules (like planning) can be tested without real
robot
•Saves time and resources
30-03- AICML,MEC,March 6
2026 2026 2
•A system can be modular BUT still bad.
Example:
•Ideal System
Modular system
Each module has clearly defined control
30-03- AICML,MEC,March 6
2026 2026 4
One way to characterize a particular architecture
is by its decomposition of the robot’s
software.
•What is Decomposition?
Advantages :
•Easier to design
•Easier to understand
•Easier to implement
30-03- AICML,MEC,March 6
2026 2026 6
Types of Decomposition
•There are two main types:
Temporal Decomposition
• Temporal divides modules onhow fast
must [Link] is calledbased
decomposition temporal decomposition
theybecause
The robot system is divided based on time requirements
(speed of operation).
30-03- AICML,MEC,March 6
2026 2026 8
1. Hard Real-Time (FASTEST) : This is the lowest level
• What it does:
• Direct control of motors
• Runs very fast (e.g., 40–150 Hz)
• Example:
• PID controller controlling wheel speed
If this fails → robot cannot move properly
2. Quasi Real-Time : Slightly slower than hard real-time
• What it does:
• Quick reactions, but not extremely fast
• Example:
• Basic obstacle detection
• Small corrections
3. Tactical Decisions : Medium-speed decisions
• What it does:
• Decides immediate actions
• Example:
• Avoid obstacle
• Choose local path
Works based on current situation
30-03-2026 AICML,MEC,March 2026 69
30-03- AICML,MEC,March 7
2026 2026 0
General properties of
temporal
decompositions:
• As we move from bottom → top layers (in figure):
Example:
30-03- AICML,MEC,March 7
2026 2026 2
30-03-2026 AICML,MEC,March 2026 73
• Each
• Takes some inputs
module:
• Produces one output
30-03- AICML,MEC,March 7
2026 2026 4
Two Extreme Types of Control
•(A) Serial Control (Sequential)
•(B) Parallel Control
•Each module:
• Takes some inputs
• Produces one output
30-03- AICML,MEC,March 7
2026 2026 6
•Modules are arranged in a line (series)
•Each depends only on the previous module
•No module runs
independently Important
Characteristics
Advantages
•Easy to understand
•Easy to debug
•Predictable behavior
Disadvantages
•Slow (must wait for each step)
•Not flexible
•Cannot handle multiple behaviors simultaneously
Idea:
• Multiple modules run at the same time
• All influence the final action
Example modules:
•Obstacle avoidance
•Path following
30-03- AICML,MEC,March 7
2026 2026 8
30-03-2026 AICML,MEC,March 2026 79
30-03- AICML,MEC,March 8
2026 2026 0
Types of Parallel Control
(1) Switched Parallel Control
(2) Mixed Parallel Control
30-03- AICML,MEC,March 8
2026 2026 2
Switched Parallel Control
• Only ONE module controls the robot at a
time Example:
• If obstacle < 50 cm → use obstacle avoidance
• Else → use path following
Advantages:
• Simple
• Easy to analyze
Disadvantages:
• Frequent switching → unstable behavior
• No combination of behaviors
Robot cannot:Avoid obstacle AND follow path at same time
30-03- AICML,MEC,March 8
2026 2026 4
Alternatives for Navigation Using
Neural
Networks
Example:
•Reward for reaching goal
•Penalty for collision
example
Algorithm:DQN
30-03- AICML,MEC,March 8
2026 2026 8
3. Imitation Learning:Imitation learning is a technique
where an agent learns a policy by mimicking the actions of an
expert using demonstration data.
30-03- AICML,MEC,March 9
2026 2026 0
Image Processing Pipeline for
Navigation
Step 1: Preprocessing
•Resize image (e.g., 224×224)
•Normalize pixel values
•Apply filters (edge detection)
Purpose: Reduce noise C standardize input
30-03- AICML,MEC,March 9
2026 2026 2
Optimizer: Adam / SGD
30-03- AICML,MEC,March 9
2026 2026 2
•Step 5: Testing C Deployment-Simulation → real-world
30-03- AICML,MEC,March 9
2026 2026 4
•Training Process
Steps:
• Input image → CNN
• Predict control output
• Compare with actual value
• Compute loss
• Update weights (backpropagation)
• Repeat for many epochs
Step 4 : Testing:
• Use unseen data
• Validate performance
Step 5 : Deployment
30-03- AICML,MEC,March 9
2026 2026 6
•The network learns by minimizing a loss function that
measures how far the predicted control commands are
from the desired ones.
•For regression (continuous outputs like steering):Mean
Squared Error (MSE):
•For classification (e.g., discrete movement directions):
Cross-Entropy Loss
•The model updates its parameters via
backpropagation and optimizers.
30-03- AICML,MEC,March 9
2026 2026 8
Real-Time Feedback Loop
This
ensures: Continuous decision-
making Adaptation to
environment