Autonomous Robot (2D)
Sensing & Control
Nearest obstacle
-- m
Heading
0°
Speed
0.0 m/s
Decisions/s
0
Distance travelled
0.0 m
Avoidance events
0
How it works

The robot repeats a classic sense → decide → act loop, drawn here as a top-down floor plan instead of an orbiting 3D scene. Each frame it casts a fan of virtual lidar rays outward, measuring the distance to the nearest obstacle along each direction (sensing). It then combines an attractive pull toward its goal with a repulsive push away from any nearby obstacle, weighted by how close each obstacle is (decision-making via a potential field). Finally it turns and accelerates its heading toward the resulting vector (control).

F_total = k_goal * (goal - pos)/|goal - pos|
        - Σ k_rep * (1/d_i - 1/d_safe) * (1/d_i²) * n̂_i   for d_i < d_safe

heading += clamp(angleTo(F_total), -ω_max*dt, ω_max*dt)
speed    = v_max * clamp(min_i(d_i)/d_safe, 0.15, 1)
  • Sensor rays — how many lidar beams the robot fans out each frame; more rays sample the environment more finely.
  • Sensor range — the maximum distance each beam can detect an obstacle (d_safe in the formula).
  • Max speed — the top forward speed v_max; the robot slows automatically as obstacles get close.
  • Seek Goal / Wander — toggles whether the attractive term targets a fixed goal marker or a slowly drifting random point.
  • New Arena — regenerates the obstacle field and goal position.

This reactive potential-field scheme is a simplified version of algorithms used in real mobile robots and warehouse AGVs, which fuse lidar/sonar readings with a target heading to avoid collisions without needing a full map.