运动规划第二节【深蓝学院,高飞】笔记

news/2024/11/13 11:58:26/

文章目录

  • Graph Search Basis
    • Configuration Space
      • Configuration Space Obstacle
      • Workspace and Configuration Space Obstacle
    • Graph and Search Method
    • Graph Search Overview
    • Graph Traversal
      • Breadth First Search (BFS)
      • Depth First Search (DFS)
      • versus
    • Heuristic Search
      • Greedy Best First Search
      • Costs on Actions
  • Dijkstra and A*
    • Algorithm Workflow
      • Dijkstra's Algorithm
        • 伪代码
      • Pros and Cons of Dijkstra's Algorithm
      • Search Heuristics
    • A*: Dijkstra with a Heuristic
        • 伪代码
      • A* Optimality
      • Admissible Heuristics
      • Heuristic Design
      • Sub-optimal Solution
    • Greedy Best First Search vs. Weighted A* vs. A*
    • Engineering Considerations
      • Grid-based Path Search
        • Implementation
      • The Best Heuristic
      • Tie Breaker
  • Jump Point Search
    • Look Ahead Rule
    • Jumping Rules
    • pesudo-code
    • Example
    • Extension
      • 3D JPS
      • Is JPS always better?
  • Homework
    • Assignment: Basic
    • Assignment: Advance

Graph Search Basis

Configuration Space

Robot degree of freedom (DOF): The minimum number n of real-valued coordinates need to represent the robot configuration.

Robot configuration space: a n-dim space containing all possible robot configurations, denoted as C-space

Each robot pose is a point in the C-space

Configuration Space Obstacle

Workspace - Configuration Space

  • Obstacles need to be represented in configuration space (one-time work prior to motion planning), called configuration space obstacle, or C-obstacle.
  • C-space = (C-obstacle) ∪ \cup (C-free)
  • The path planning is finding a path between start point q s t a r t q_{start} qstart and goal point q g o a l q_{goal} qgoal with C-free.

Workspace and Configuration Space Obstacle

  • In workspace
    Robot has shape and size
  • In configuration space: C-space
    Robot is a point
    Obstacle are represented in C-space prior to motion planning.

Graph and Search Method

Graphs: Graphs have nodes and edges
State space graph: a mathematical representation of a search algorithm.

Graph Search Overview

  • Maintain a container to store all the nodes to be visited
  • The container is initialized with the start state X S X_S XS
  • Loop
    Remove a node from the container according to some pre-defined score function.
    Expansion: Obtain all neighbors of the node
    Push them (neighbors) into the container.
  • End Loop

Question 1: When to end the loop?
Possible option: End the loop when the container is empty.

Question 2: What if the graph is cyclic?
When a node is removed from the container (expand / visited), it should never be added back to the container again.

Question 3: In what way to remove the right node such that the goal state can be reached as soon as possible, which results in less expansion of the graph node.

Graph Traversal

Breadth First Search (BFS)

BFS uses “first in first out” = queue
在这里插入图片描述

  • Strategy: remove / expand the shallowest node in the container

Depth First Search (DFS)

DFS uses “last in first out” = stack
在这里插入图片描述

  • Strategy: remove / expand the deepest node in the container
  • Implementation: maintain a last in first out (LIFO) container (i.e. stack)

versus

在这里插入图片描述
Breadth First Search(BFS,FIFO)能找出最短路径

Heuristic Search

Greedy Best First Search

  • BFS and DFS pick the next node off the frontiers based on which was “first in” or “last in”.

  • Greedy Best First picks the “best” node according to some rule, called a heuristic.

  • Definition: A heuristic is a guess of how close you are to the target.
    在这里插入图片描述

  • A heuristic guides you in the right direction.

  • A heuristic should be easy to compute.
    在这里插入图片描述

Costs on Actions

  • A practical search problem has a cost "C" from a node to its neighbor
    • Length, time, energy, etc.
  • When all weight are 1, BFS finds the optimal solution
  • For general cases, how to find the least-cost path as soon as possible?

Dijkstra and A*

Algorithm Workflow

Dijkstra’s Algorithm

  • Strategy: expand/visit the node with cheapest accumulated cost g(n)
    • g(n): The current best estimates of the accumulated cost from the start state to node “n”
    • Update the accumulated costs g(m) for all unexpected neighbors “m” of node “n”
    • A node that has been expanded/visited is guaranteed to have the smallest cost from the start state.
伪代码
  • Maintain a priority queue to store all the nodes to be expanded
  • The priority queue is initialized with the start state X s X_s Xs
  • Assign g ( X s ) = 0 g(X_s)=0 g(Xs)=0, and g(n)=infinite for all other nodes in the graph
  • Loop
    • If the queue is empty, return FALSE; break;
    • Remove the node “n” with the lowest g(n) from the priority queue
    • Mark node “n” as expanded
    • If the node “n” is the goal state, return True; break;
    • For all unexpanded neighbors “m” of node “n”
      • If g(m) = infinite
        • g(m) = g(n) + C n m C_{nm} Cnm
        • Push node “m” into the queue
      • If g(m) > g(n) + C n m C_{nm} Cnm
        • g(m) = g(n) + C n m C_{nm} Cnm
    • End
  • End Loop

priority queue = container = open list
已经扩展过的节点放到 close list

Pros and Cons of Dijkstra’s Algorithm

  • The good:
    • Complete and optimal
  • The bad:
    • Can only see the accumulated so far (i.e. the uniform cost), thus exploring next state in every “direction”
    • No information about goal location

Search Heuristics

  • Recall the heuristic introduced in Greedy Best First Search
  • Overcome the shortcomings of uniform cost search by inferring the least cost to goal (i.e. goal cost)
  • Designed for particular search problem
  • Examples: Manhattan distance VS. Euclidean distance

A*: Dijkstra with a Heuristic

  • Accumulated cost
    • g(n): The current best estimates of the accumulated cost from the start state to node “n”
  • Heuristic
    • h(n): The estimated least cost from node n to goal state (i.e. goal cost)
  • The least estimated cost from start node to goal state passing through node “n” is f(n)=g(n) + h(n)
  • Strategy: expand the node with cheapest f(n) = g(n )+ h(n)
    • Update the accumulated costs g(m) for all unexpanded neighbors “m” of node “n”
    • A node that has been expanded is guaranteed to have the smallest cost from the start node
伪代码
  • Maintain a priority queue to store all the nodes to be expanded
  • The heuristic function h(n) for all nodes are pre-defined
  • The priority queue is initialized with the start state X s X_s Xs
  • Assign g ( X s ) = 0 g(X_s)=0 g(Xs)=0, and g(n)=infinite for all other nodes in the graph
  • Loop
    • If the queue is empty, return FALSE; break;
    • Remove the node “n” with the lowest f(n) = g(n)+h(n) from the priority queue
    • Mark node “n” as expanded
    • If the node “n” is the goal state, return True; break;
    • For all unexpanded neighbors “m” of node “n”
      • If g(m) = infinite
        • g(m) = g(n) + C n m C_{nm} Cnm
        • Push node “m” into the queue
      • If g(m) > g(n) + C n m C_{nm} Cnm
        • g(m) = g(n) + C n m C_{nm} Cnm
    • End
  • End Loop

A* Optimality

在这里插入图片描述

  • What went wrong?
  • For node A: actual least cost to goal (i.e. goal cost) < estimated least cost to goal (i.e. heuristic)
  • We need the estimate to be less than actual least cost to goal (i.e. goal cost) for all nodes!

Admissible Heuristics

  • A Heuristic h is admissible(optimistic) if:
    • h(n) <= h*(n) for all node “n”, where h*(n) is the true least cost to goal from node “n”
  • If the heuristic is admissible, the A* search is optimal
  • Coming up with admissible heuristics is most of what’s involved in using A* in practice.

Heuristic Design

An admissible heuristic function has to be designed case by case.

  • Euclidean Distance
    Is Euclidean distance (L2 norm) admissible? Always

  • Manhattan Distance
    Is Manhattan distance (L1 norm) admissible? Depends

Is L ∞ \infty norm distance admissible? Always
Is 0 distance admissible? Always

A* expands mainly towards the goal, but does not hedge its bets to ensure optimality.

Sub-optimal Solution

What if we intend to use an over-estimate heuristic?
Suboptimal path and Faster
Weighted A*: Expands states based on f = g + ε h f = g + \varepsilon h f=g+εh, ε > 1 \varepsilon>1 ε>1=bias towards states that are closer to goal.

  • Weighted A* Search
    • Optimality vs. speed
    • ε \varepsilon ε-suboptimal: cost(solution) <= ε c o s t ( o p t i m a l s o l u t i o n ) \varepsilon cost(optimal solution) εcost(optimalsolution)
    • It can be orders of magnitude faster than A*

Weighted A* -> Anytime A* -> ARA* -> D*

Greedy Best First Search vs. Weighted A* vs. A*

在这里插入图片描述

Engineering Considerations

Grid-based Path Search

  • How to represent grids as graphs?
    Each cell is a node. Edges connect adjacent cells.
Implementation
  • Create a dense graph.
  • Link the occupancy status stored in the grid map.
  • Neighbors discovered by grid index.
  • Perform A* search.

\;

  • Priority queue in C++
  • std::priority_queue
  • std::make_heap
  • std::multimap

The Best Heuristic

They are useful, but none of them is the best choice, why?
Because none of them is tight
Tight means who close they measure the true shortest distance.

Why so many nodes expanded?
Because Euclidean distance is far from the truly theoretical optimal solution.

\;

How to get the truly theoretical optimal solution
Fortunately, the grid map is highly structural.
在这里插入图片描述

  • You don’t need to search the path.
  • It has the closed-form solution!
    d x = a b s ( n o d e . x − g o a l . x ) d y = a b s ( n o d e . y − g o a l . y ) h = ( d x + d y ) + ( 2 − 2 ) ∗ m i n ( d x , d y ) dx = abs(node.x - goal.x)\\ dy = abs(node.y - goal.y)\\ h = (dx+dy) + (\sqrt2 - 2)*min(dx, dy) dx=abs(node.xgoal.x)dy=abs(node.ygoal.y)h=(dx+dy)+(2 2)min(dx,dy)

diagonal Heuristic h(n) = h*(n)

Tie Breaker

  • Many paths have the same f value.

  • No differences among them making them explored by A* equally.
    在这里插入图片描述

  • Manipulate the f f f value breaks tie

  • Make same f f f values differ.

  • Interfere h h h slightly.

    • h = h × ( 1.0 + p ) h = h \times (1.0 + p) h=h×(1.0+p)
    • p < m i n i m u m c o s t o f o n e s t e p e x p e c t e d m a x i m u m p a t h c o s t p < \frac{minimum \; cost \; of \; one \; step}{expected \; maximum \; path \; cost} p<expectedmaximumpathcostminimumcostofonestep

Core idea of tie breaker:
Find a preference among same cost paths

  • When nodes having same f f f, compare their h h h

  • Add deterministic random numbers to the heuristic or edge costs (A hash of the coordinates).

  • Prefer paths that are along the straight line from the starting point to the goal.
    d x 1 = a b s ( n o d e . x − g o a l . x ) d y 1 = a b s ( n o d e . y − g o a l . y ) d x 2 = a b s ( s t a r t . x − g o a l . x ) d y 2 = a b s ( s t a r t . y − g o a l . y ) c r o s s = a b s ( d x 1 × d y 2 − d x 2 × d y 1 ) h = h + c r o s s × 0.001 dx1=abs(node.x - goal.x)\\ dy1 = abs(node.y - goal.y)\\ dx2 = abs(start.x - goal.x)\\ dy2 = abs(start.y - goal.y)\\ cross = abs(dx1\times dy2 - dx2\times dy1)\\ h = h+cross\times 0.001 dx1=abs(node.xgoal.x)dy1=abs(node.ygoal.y)dx2=abs(start.xgoal.x)dy2=abs(start.ygoal.y)cross=abs(dx1×dy2dx2×dy1)h=h+cross×0.001

  • … Many customized ways

\;

  • Prefer paths that are along the straight line from the starting point to the goal.
    在这里插入图片描述

Jump Point Search

Core idea of JPS
Find symmetry and break them.

在这里插入图片描述

JPS explores intelligently, because it always looks ahead based on a rule.

Look Ahead Rule

Consider

  • current node x x x
  • x x x’s expanded direction
    在这里插入图片描述

Neighbor Pruning

  • Gray nodes: inferior neighbors, when going to them, the path without x x x is cheaper. Discard.
  • White nodes: natural neighbors
  • We only need to consider natural neighbors when expand the search.

在这里插入图片描述

Forced Neighbors

  • There is obstacle adjacent to x x x
  • Red nodes are forced neighbors.
  • A cheaper path from x x x’s parent to them is blocked by obstacle.

Jumping Rules

在这里插入图片描述

  • Recursively apply straight pruning rule and identify y as a jump point successor of x x x. This node is interesting because it has a neighbor z that cannot be reached optimally except by a path that visit x x x then y y y.
  • Recursively apply the diagnol pruning rule and identify y as a jump point successor of x x x
  • Before each diagonal step we first recurse straight. Only if both straight recursions fail to identify a jump point do we step diagnally again.
  • Node w, a forced neighbor of x x x, is expanded as normal. (also push into the open list, the priority queue)

pruning rule = look ahead rule

pesudo-code

Recall A* 's pseudo-code, JPS’s is all the same!

  • Maintain a priority queue to store all the nodes to be expanded
  • The heuristic function h(n) for all nodes are pre-defined
  • The priority queue is initialized with the start state X s X_s Xs
  • Assign g ( X s ) = 0 g(X_s)=0 g(Xs)=0, and g(n)=infinite for all other nodes in the graph
  • Loop
    • If the queue is empty, return FALSE; break;
    • Remove the node “n” with the lowest f(n) = g(n) + h(n) from the priority queue
    • Mark node “n” as expanded
    • If the node “n” is the goal state, return TRUE, break;
    • For all unexpanded neighbors “m” of node “n”
      • If g(m) = infinite
        • g(m) = g(n) + C n m C_{nm} Cnm
        • Push node “m” into the queue
      • If g(m) > g(n) + C n m C_{nm} Cnm
        • g(m) = g(n) + C n m C_{nm} Cnm
    • end
  • End Loop

在这里插入图片描述

Example

在这里插入图片描述

Extension

3D JPS

Planning Dynamically Feasible Trajectories for Quadrotors using Safe Flight Corridors in 3-D Complex Environments, Sikang Liu, RAL 2017
KumarRobotics/jps3d

Is JPS always better?

  • This is a simple example saying “No.”
  • This case may commonly occur in robot navigation.
  • Robot with limited FOV, but a global map/large local map.
    在这里插入图片描述
    Conclusion:
  • Most time, especially in complex environment, JPS is better, but far away from “always”. Why?
  • JPs reduces the number of nodes in Open List, but increase the number of status query.
  • You can try JPS in Homework2.
  • JPS's limitation: only applicable to uniform grid map.

Homework

Assignment: Basic

  • This project work will focus on path finding and obstacle avoidance in a 2D grid map.
  • A 2D grid map is generated randomly every time the Project is run, which contains the obstacles, start point and target point locations will be provided. You can also change the probability of obstacles in the map in obstacle_map.m
  • You need to implement a 2D A* path search method to plan an optimal path with safety guarantee.

Assignment: Advance

  • I highly suggest you implement Dijkstra/A* with C++/ROS
  • Complex 3d map can be generated randomly. The sparsity of obstacles in this map is tunable.
  • An implementation of JPS is also provided. Comparisons can be made between A* and JPS in different map set-up.

http://www.ppmy.cn/news/1528081.html

相关文章

百元头戴式耳机都有哪些?五大精品独家推荐!

在当今市场中&#xff0c;耳机已经成为我们生活中不可或缺的电子设备之一。而对于追求性价比的朋友来说&#xff0c;如何在百元价位内挑选到一款音质出色、舒适耐用的头戴式耳机&#xff0c;无疑是一大难题。百元头戴式耳机都有哪些&#xff1f;为了帮助大家在琳琅满目的产品中…

生信初学者教程(六):数学基础

文章目录 描述性统计推断性统计假设检验检验分布线性回归机器学习R与统计本教程的核心在于数据分析,因此初学者需要具备一定的数学基础。在这里,简要介绍一些基础数学概念,包括描述性统计、推断性统计以及机器学习等内容。特别地,对于机器学习基础的学习至关重要,例如如何…

机器学习-深度学习数据集之打架斗殴识别数据集

关于“打架识别数据集”&#xff0c;这是一个专门设计用于训练计算机视觉模型以识别打架、摔倒以及持械行为的数据集。此类数据集对于开发安全监控系统至关重要&#xff0c;可以帮助在公共场所如学校、酒吧或地铁站等地及时发现潜在的暴力事件&#xff0c;从而快速采取行动来防…

蓝桥杯2024省C

P10898 [蓝桥杯 2024 省 C] 拼正方形 题目描述 小蓝正在玩拼图游戏&#xff0c;他有 7385137888721个 22的方块和 10470245 个 11 的方块&#xff0c;他需要从中挑出一些来拼出一个正方形&#xff0c;比如用 3 个 22 和 4 个 11 的方块可以拼出一个 44 的正方形&#xff0c;用…

uniapp中实现<text>文本内容点击可复制或拨打电话

推荐学习文档 golang应用级os框架&#xff0c;欢迎stargolang应用级os框架使用案例&#xff0c;欢迎star案例&#xff1a;基于golang开发的一款超有个性的旅游计划app经历golang实战大纲golang优秀开发常用开源库汇总想学习更多golang知识&#xff0c;这里有免费的golang学习笔…

️ 保护您的 JavaScript:安全和隐私的最佳实践

JavaScript 是一种用于构建动态 Web 应用程序的强大语言&#xff0c;但功能越强大&#xff0c;责任越大。确保 Web 应用程序的安全性和隐私性至关重要。本指南介绍了保护应用程序和用户的基本最佳实践。 &#x1f6e1;️ 安全和隐私基础知识 1.1、了解安全与隐私 安全&#x…

尚硅谷-----乐(智)尚代驾(Day4...重置版)---项目概述环境搭建

一、项目介绍 1.背景 乐尚代驾是一种新型的出行服务模式&#xff0c;通过该平台可以为用户提供代驾服务&#xff0c;采用微信小程序方式进行开发&#xff0c;主要分为乘客端、司机端和平台管理端&#xff0c;这里只实现前两个。 2.技术概括 后端技术栈 前端技术栈 使用的云服…

linux 系统是如何收发数据包

目录 1. 背景 1.1 协议栈的构成 1. 应用层: 2. Socket 层: 3. 传输层 (TCP/UDP): 4. 网络层 (IP): 5. 数据链路层 (MAC): 6. 物理层 (网卡驱动): 1.2 数据包的组成 2. 接收网络数据包的流程 2.1 数据包接收流程概述 2.2 详细步骤说明 2.2.1 网卡接收数据包 2.2.2…