Replan from where the robot is now

An obstacle can invalidate a route after the robot starts moving. Replanning finds a detour from its current position, or stops it when the goal becomes unreachable.

Browser walkthrough·Beginner·About 15 min

Try the room planner

Choose a goal in the room, then run the robot.

Robot navigation room

6 moves remaining

More controls

Robot (2, 4), goal (8, 4). 6 moves remaining. Click a cell to set the goal. The green square is the modeled robot footprint.

2D reference and fallback
Room occupancy map and planned routeRobot at 2,4, goal at 8,4. A route exists with 6 moves. Gray cells are obstacles. Brown cells are excluded by the footprint. White is the planned center route.012345678910012345678

Inspect route and obstacle coordinates

Route in travel order: (2, 4) → (3, 4) → (4, 4) → (5, 4) → (6, 4) → (7, 4) → (8, 4)

Occupied cells: (5,3), (5,5), (5,6), (5,7).

Excluded robot-center cells: (5,3), (5,5), (5,6), (5,7).

Planner assumptions

Every cardinal move costs one. Breadth-first search finds a shortest route on this fixed grid. The robot is a square aligned with the grid. For footprint width 2r + 1 cells, centers within r cells horizontally and vertically of an occupied cell are excluded. Centers whose footprint crosses a room edge are also excluded. Routes move only the center. There is no turning radius, acceleration, uncertain localization, or moving obstacle prediction. The movement button advances a discrete simulation state, not a physical robot.

Optional reasoning check

Requirements and learning goals

Before you start

  • The footprint, route-planning, and localization lessons
  • A browser with JavaScript enabled

You will be able to

  • Recompute a route from the current position after a map change
  • Distinguish a detour from an unreachable goal
  • Explain why a known route and a known position are separate requirements

A route is a plan for a particular map and starting position. If an obstacle appears, the old route may no longer be valid. Replanning must use the robot's current position, rather than quietly moving it back to where the original plan began.

This final experiment combines the square and grid search from earlier lessons. Run robot follows the computed route one cell at a time. The Advance one cell button in More controls lets you inspect individual moves. Changing an obstacle immediately recomputes the route from that current cell. The experiment does not predict moving obstacles or model acceleration between cells.

We assume the current position is known exactly. The lesson showed why that is a strong assumption. Keeping it explicit lets us study map changes without pretending we have implemented a full navigation system. Allow about 15 minutes.

Try it

Use Run robot and Pause robot for continuous movement. For the exact cell-by-cell comparison below, open More controls and use Advance one cell. The main Block doorway switch changes the route while the robot moves.

  1. Reset to the one-cell footprint, start (2,4), and goal (8,4). Confirm the six-move route.
  2. Advance one cell twice. The robot should now be at (4,4), with four moves remaining.
  3. Block the doorway at (5,4). Before advancing again, inspect the recomputed route and its first cell. The robot must still be at (4,4).
  4. Advance along the detour until the robot reaches the goal. The remaining move count should decrease after each step.
  5. Reset. Close every crossing in column 5. Check that no route is drawn and the advance button is unavailable.
  6. Reset once more and choose the 3-by-3 footprint. Block the narrow doorway and explain why this does not change the route that the larger footprint was already using.

Work through the detour

After the first two moves, the robot is at (4,4). Blocking (5,4) invalidates the direct route. The point-sized robot can move up to row 2, cross the wall there, then return to row 4. From its current position, that is two upward moves, four rightward moves, and two downward moves: eight remaining moves.

If you reset before blocking the doorway, the route starts at (2,4) and needs ten moves. Both numbers are correct for their respective starts. Reporting only a route length without its starting position would make the two experiments appear inconsistent.

Checkpoint 1 of 2

Reset, advance one cell so the robot is at (3,4), then block the doorway at (5,4). How many moves remain to the goal (8,4)?

Commit to an answer. Every choice explains itself.

Check the expected results

Expect six moves at reset, four remaining after two advances, and eight remaining after blocking the doorway at that point. The first route coordinate must remain (4,4) after replanning. At the goal, the route contains one cell and zero moves, so there is no further advance.

Closing every crossing in column 5 disconnects start and goal. Expect a no-route message and a disabled advance button. The planner does not invent a route through a wall or select a different goal without telling you.

With the 3-by-3 footprint, the reset route already avoids the narrow doorway and has 12 moves. Blocking that doorway alone leaves the 12-move upper route available.

Report a navigation decision

For one scenario, record the footprint, current position, goal, changed obstacle, remaining move count, and whether movement is permitted. Explain whether the result relies on a known position, current obstacle map, or both.

Checkpoint 2 of 2

The planner is told the robot is at (4,4), but the robot is really at (3,4). The map correctly shows the blocked doorway. The robot executes the eight-move detour planned from (4,4). Where does it finish?

Commit to an answer. Every choice explains itself.

A valid grid route is only one part of physical navigation. A real system must track the route, observe obstacles between planning updates, account for localization uncertainty, and stop when its assumptions fail. This browser exercise demonstrates the planning decision without claiming those systems exist.

You are done when you can demonstrate a successful detour and an honest no-route outcome without resetting the robot during replanning.

Troubleshooting

If the robot cannot advance, read the status. It may already be at the goal, have no route, or occupy a center that is invalid for a newly enlarged footprint. Reset before comparing the specified scenarios. Changing the footprint while the robot is beside an obstacle can make its current position invalid; the simulation deliberately reports that conflict instead of moving it automatically.

Can you do each of these?

  • Recompute a route from the current position after a map change
  • Distinguish a detour from an unreachable goal
  • Explain why a known route and a known position are separate requirements

0 of 2 checkpoints solved. Try checkpoint 1

Previous: Keep more than one possible robot position
All lessons in this topic
  1. 1. Give the robot enough room to fit
  2. 2. Find a shortest route through free cells
  3. 3. Keep more than one possible robot position
  4. 4. Replan from where the robot is now
  5. 5. How LiDAR sees a room
  6. 6. Map a room and navigate to a goal

Ask Wendy

Answers about Wendy and WendyOS

What would you like to know?

Ask about devices, development, and deployment.

Check linked docs for technical details.