การวางแผนเส้นทางและหลบหลีกสิ่งกีดขวางอัตโนมัติ

A*, RRT, occupancy maps and obstacle avoidance

Last updated:

Overview: which way to go, and can we stop in time?

An autonomous drone keeps answering three questions: what is ahead, which way should it go, and if something appears suddenly, can it stop or turn in time? Together these are path planning and obstacle avoidance.

Practical systems split the work into three layers running at different rates:

  • A global planner finds a complete route on a known map. It runs occasionally, for example at mission start or when the map changes.
  • A local avoidance layer reacts to what the sensors see right now, such as a box left in an aisle. It runs several times a second.
  • A path follower turns the route into velocity or steering commands for the flight controller.

Each layer solves its own problem. Asking one to do another's job, for example making the path follower dodge new obstacles, produces a brittle system.

Occupancy grids and inflation

An occupancy grid divides space into equal cells, each holding the probability that it is occupied. The idea comes from Elfes (1989). Its strength is that readings from several sensors, such as LiDAR and depth cameras, merge easily into one grid. Cells the sensors have never observed should be marked unknown, not free.

Resolution is the cell size. Small cells resolve narrow gaps but cost memory. In a 3D map, halving the cell size multiplies the cell count by eight.

Planners usually treat the drone as a point, so obstacles must first be inflated by the vehicle radius plus a safety margin. If the vehicle centre stays outside the inflated region, the propellers stay clear of the real obstacle.

Graph search: Dijkstra and A*

Once you have a grid, treat each free cell as a graph node, with neighbouring cells joined by edges whose cost is the distance between them.

  • Dijkstra's algorithm expands nodes in order of accumulated cost from the start, g(n). It always finds the shortest path but searches in every direction.
  • A* (Hart, Nilsson and Raphael, 1968) expands the node with the lowest f(n) = g(n) + h(n), where h(n) is a heuristic, an estimate of the remaining cost to the goal. If h never overestimates (it is admissible), A* still returns the shortest path while expanding far fewer nodes.

Common heuristics are Manhattan distance for four-way moves and straight-line distance when diagonal moves are allowed. Grid paths turn at cell corners, so real systems smooth them before handing them to the follower.

Sampling-based planning: RRT

In large 3D spaces, or when position and heading must be planned together, a fine grid has too many cells. The Rapidly-exploring Random Tree (RRT) of LaValle (1998) avoids this by sampling. Each iteration picks a random point, finds the nearest node already in the tree, and extends one step toward the sample. If that step is collision-free, it joins the tree. A fraction of samples is the goal itself, which pulls the tree toward it.

RRT finds a feasible path quickly, but the first path is usually winding and changes with the random seed. Shortcut the result and test with several seeds. Robotics texts also describe variants that keep shortening the path as sampling continues.

Reactive avoidance

Obstacles that are not on the map need methods that compute quickly from the latest sensor data.

  • Potential fields (Khatib, 1986) let the goal attract and obstacles repel, and the vehicle follows the resulting force. Simple, but it can stall in a local minimum where attraction and repulsion cancel, for example with the goal directly behind a pillar.
  • The vector field histogram (VFH) (Borenstein and Koren, 1991) divides the surroundings into angular sectors, measures obstacle density in each, and picks an opening that is wide enough and closest to the goal direction.
  • Velocity obstacles handle moving objects such as forklifts or other drones: find the set of velocities that would lead to a collision, then choose one outside it.

Flight controllers include avoidance too. PX4 Collision Prevention works in Position mode on multicopters, keeps a map of 72 sectors around the vehicle, and slows and stops before an obstacle. If no range data arrives for more than 0.5 s, horizontal movement is blocked; after 5 s the vehicle switches to HOLD. A negative CP_DIST disables the feature. ArduPilot offers both simple stop-before-obstacle behaviour and path-bending methods such as BendyRuler. All of these depend on the sensors: an object the sensor cannot see will not be avoided.

Worked example: an inspection drone in a warehouse

Example: map size, inflation and safe speed

Assume a warehouse 60 m wide, 40 m deep and 12 m high. The drone's radius including propellers is 0.35 m and we want a 0.3 m safety margin. The depth sensor sees 5 m, total latency from detection to braking is 0.3 s, and the drone can brake at 2.5 m/s². All values are assumed.

  1. Map size: 0.2 m cells give 300 × 200 × 60 = 3,600,000 cells, or 3.6 MB at one byte per cell. With 0.1 m cells there are 28,800,000 cells, 28.8 MB, eight times more.
  2. Inflation: 0.35 + 0.3 = 0.65 m, which is 3.25 cells of 0.2 m. Round up to 4 cells (0.8 m). Rounding down to 3 cells leaves only 0.6 m, less than required.
  3. Stopping distance at 3 m/s: dstop = v·tlat + v²/(2a) = 3 × 0.3 + 3²/(2 × 2.5) = 0.9 + 1.8 = 2.7 m, inside the 5 m sensor range.
  4. Highest speed that still stops in range: solving 0.3v + v²/5 = 5 gives v ≈ 4.3 m/s. Keeping a 1 m reserve (4 m instead of 5 m) gives v ≈ 3.8 m/s.

So 3 m/s leaves a reasonable margin. Remember that some sensors miss wires, glass or pallet stretch film, so the effective range can be shorter than the datasheet figure.

Common pitfalls

  • Not inflating obstacles by the vehicle size, or rounding the cell count down, so the path grazes obstacles.
  • Treating never-observed cells as free space.
  • Computing stopping distance from braking alone and forgetting the distance covered during latency.
  • Trusting a single RRT run when the result depends on the random seed.
  • Using a potential field with no way to detect a stall and hand over to a planner.
  • Assuming the flight controller's avoidance is enabled, or that it will plan a detour in every mode.
  • Testing first at speed near hard obstacles instead of starting in SITL and with soft obstacles.

Continue in the lessons

Key references

  1. Elfes, A. (1989). Using occupancy grids for mobile robot perception and navigation. Computer, 22(6), 46–57. link
  2. Hart, P. E., Nilsson, N. J., & Raphael, B. (1968). A formal basis for the heuristic determination of minimum cost paths. IEEE Transactions on Systems Science and Cybernetics, 4(2), 100–107. link
  3. LaValle, S. M. (1998). Rapidly-exploring random trees: A new tool for path planning (TR 98-11). Iowa State University. link
  4. Khatib, O. (1986). Real-time obstacle avoidance for manipulators and mobile robots. The International Journal of Robotics Research, 5(1), 90–98. link
  5. Borenstein, J., & Koren, Y. (1991). The vector field histogram—Fast obstacle avoidance for mobile robots. IEEE Transactions on Robotics and Automation, 7(3), 278–288. link
  6. PX4 Autopilot. Collision prevention. PX4 user guide (main). link

Used in courses

How to cite this page

Drone Institute, Rangsit University. (2026). การวางแผนเส้นทางและหลบหลีกสิ่งกีดขวางอัตโนมัติ. In UAS Technology Knowledge Hub (B.Tech.). https://rsu-uat.pk-research.work/en/kb/new/autonomy-planning/