-3 Feasibility Distributions in Motion Planning
-4 Stein Variational Gradient Descent
Efficient and reliable generation of global path plans are necessary for safe execution and deployment of autonomous systems.In order to generate planning graphs which resolve the topology of a given environment, many sampling-based motion planners resort to coarse, but heuristically-driven strategies which often fail to generalize to new and varied surroundings.The paper "Stein Variational Probabilistic Roadmaps" proposes a method for Probabilistic Roadmaps which relies on particle-based Variational Inference to efficiently cover the posterior distribution over feasible regions in configuration space. Stein Variational Probabilistic Roadmap (SV-PRM) results in sample-efficient generation of planning-graphs and large improvements over traditional sampling approaches.Here is the compare of sv-prm and traditional prm. The left picture is the result of sv-prm, and the other one is traditional prm.
As the left figure shows , run the file manipulator.py, you can see the Cartesian space of a planner robot.The closest distances between manipulators and obstacles are shown in the figure.These distances will be used to calculate the posterior probability. And then we transfer the obstacles into configuration space of manipulator.
Particles are initialized based on prior distribution,here we use uniform distribution. The black points in the figure below are the initial particles.
A Bayesian occupancy map is a probabilistic approach for modeling and updating a map of an environment.In a Bayesian occupancy map, each cell in a grid map represents the probability of whether that cell is occupied or unoccupied.Desire a sampling distribution having high probability in the safe set S, and low probability elsewhere. Represent the probability of a given point xβπΉ^π being collision-free by the feasibility likelihood π(π§=1|π±;π)with map parameter πβπΉ^π. The occupancy indicator variable π§β{0,1} labels a given location as being in-collision (z = 0) or collision-free (z =1).
Using Bayesβ Rule, we can obtain a posterior probability over collision-free space:
π(π±βz=1;ΞΈ)=Ζπ(π§=1βπ±;ΞΈ)π(π±)
Where π(π±βz=1;ΞΈ) is the probability of sampling a point in a non-occupied area, and π(π§=1βπ±;ΞΈ) is the probability of the sampled point not being in collision ,π(π±) is a prior probability, and Ζ a normalizing factor.

In this case we want to optimize the posterior probability. So based on the formula above we should calculate the likelihood first.
Based on some reference papers we can get following funktions:
Log-likelihood: βππππ(π§=1βπ±;ΞΈ)=πΌ|(|π‘(π±)|)|^2+ππππ π‘
h(x) = [c(x; sj )]j=1:K
x: trajectory state
sj:collection of body spheres, j = 1:k
π(π±,π π ):the distance from the surface of π π to the nearest obstacle
π: penalizes a state if a Cartesian point on the robot is within an π -distance from the surface of the nearest obstacle
From these formulas we can know that if we want to get the likelihood we should calculate the obstacle cost first. As we can see the cost is bigger if the manipulator is close to obstacles.
These costs are combined across spheres to construct an obstacle-cost vector h(x),and define the total obstacle cost as the scaled inner-product. This picture below is the scaled inner-product of h(x) , the brighter area means the value is bigger.
Then we can use finite difference method to calculate gradient of log likelihood. And we can also get gradient of log posterior according to Bayesβ rule
Variational inference is a technique used in Bayesian inference to approximate the posterior distribution of a model, here q(x) is the approximate distribution, p(x|z) is the true posterior distribution. A proposal distribution q(x), belonging to a family Q, is chosen to minimize the KL-divergence with the target posterior distribution p(x|z) over latent variable x:
Stein Variational Gradient Descent avoids the challenge of determining an appropriate Q by leveraging a non-parameteric, particle based representation of the posterior distribution.
iteratively updated according to 
The function β
^(.) lies in the unit-ball of a reproducing kernel Hilbert space (RKHS). This RKHS is characterized by a positive-definite kernel k(.,.). The term β
^(.) represents the optimal perturbation or velocity field (i.e. gradient direction) which maximally decreases the KL-divergence:

where q([Ο΅β
]) indicates the particle distribution resulting from taking an update step. This has been shown to yield a closedform solution which can be interpreted as a functional gradient in RKHS, and can be approximated with the set of particles:

And this function has two terms that control different aspects of the algorithm. The first term is essentially a scaled gradient of the log-likelihood over the posteriorβs particle approximation. The second term is known as the repulsive force. Intuitively, it pushes particles apart when they get too close to each other and prevents them from collapsing into a single mode.
RBF kernel, where h is the bandwidth parameter
Hessian matrix to be π»(π₯)=ββ_π₯^2 ππππ(π₯|π§)
Run the file sv_prm.py, it will do all calculations above. And it will show the process of iterations, then get the final result.



