-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
25 lines (23 loc) · 835 Bytes
/
Copy pathutils.py
File metadata and controls
25 lines (23 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import numpy as np
def curvature_weighting(demos):
n_demos = len(demos)
ind_weights = []
for i in range(n_demos):
traj = demos[i]
n_pts, n_dims = np.shape(traj)
crv_weights = np.zeros((n_pts, ))
for j in range(1, n_pts-1):
crv_weights[j] = np.linalg.norm(traj[j-1] - 2*traj[j] + traj[j+1])
ind_weights.append(crv_weights)
return np.hstack(ind_weights)
def jerk_weighting(demos):
n_demos = len(demos)
ind_weights = []
for i in range(n_demos):
traj = demos[i]
n_pts, n_dims = np.shape(traj)
jrk_weights = np.zeros((n_pts, ))
for j in range(1, n_pts-2):
jrk_weights[j] = np.linalg.norm(traj[j-1] - 3*traj[j] + 3*traj[j+1] - traj[j+2])
ind_weights.append(jrk_weights)
return np.hstack(ind_weights)