Probabilistic Movement Primitives Part 4: Conditioning
The modulation of via-points, final positions, and velocities is carried out using conditioning so that MP can adapt to new situations. In order to condition the MP to reach a certain state $y^*$ at any time point $t$, a desired observation $x^*_t = [y_t^*, \Sigma_y^*]$ is added to the model. Applying Bayes theorem,
\begin{equation} p(w|x^*_t) \propto \mathcal{N} (y^*_t | \Psi_t w, \Sigma^*_y) \; p(w) \end{equation}
where state vector $y^*_t$ defines the desired position and velocity at a time $t$ and $\Sigma_y^*$ defines the accuracy of the desired observation. The conditional distribution $p(w|x^*_t)$ is Gaussian for a Gaussian trajectory distribution, whose mean and variance are given by,
\begin{equation} \mu_w^{[new]} = \mu_w + L (y_t^* - \Psi_t^T \mu_w), \hspace{10mm} \Sigma_w^{[new]} = \Sigma_w - L \Psi_t^T \Sigma_w, \end{equation}
where $L = \Sigma_w \Psi_t {(\Sigma_y^* + \Psi_t^T \Sigma_w \Psi_t)}^{-1}$.
Let's code
via_points = [(0.2, .02),(0.6, .06)] # (time t, state y*)
new_mean_W = mean_W
new_sigma_W = sigma_W
traj_point_sigma=1e-10 # observation variance for the via points
for viapoint in via_points:
plt.scatter(viapoint[0], viapoint[1], marker='o', s=100)
# basis functions at observed time points
PhiT, _= generate_basis_function(phase_z=get_phase_from_time(viapoint[0])
, phase_zd=phase_speed)
aux = traj_point_sigma + np.dot(np.dot(PhiT.T, new_sigma_W), PhiT)
new_mean_W = new_mean_W + np.dot(np.dot(new_sigma_W, PhiT) * 1 / aux,
(viapoint[1] - np.dot(PhiT.T, new_mean_W)))
new_sigma_W = new_sigma_W - np.dot(np.dot(new_sigma_W, PhiT) * 1 / aux,
np.dot(PhiT.T, new_sigma_W))
# get mean and variance for the new trajectories
mean_of_sample_traj = np.dot(Phi.T, new_mean_W)
sigma_of_sample_traj = np.dot(np.dot(Phi.T, new_sigma_W), Phi)
The sampled distribution is shown in blue. The distribution in green is sampled after adding two via-points. The red one is generated after modulating the final position.
References:
Comments
Post a Comment