Skip to content

Commit 8bacdd4

Browse files
authored
Merge pull request AtsushiSakai#152 from jwdinius/eta3_traj2
polishing up continuous velocity profile overlay on path
2 parents 5a6970e + 3938079 commit 8bacdd4

File tree

2 files changed

+450
-4
lines changed

2 files changed

+450
-4
lines changed

PathPlanning/Eta3SplinePath/eta3_spline_path.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ def __init__(self, start_pose, end_pose, eta=None, kappa=None):
152152
+ (10. * eta[1] - 2. * eta[3] + 1. / 6 * eta[5]) * sb \
153153
- (2. * eta[1]**2 * kappa[2] - 1. / 6 * eta[1]**3 *
154154
kappa[3] - 1. / 2 * eta[1] * eta[3] * kappa[2]) * cb
155-
156-
def s_dot(u): return np.linalg.norm(self.coeffs[:, 1:].dot(
157-
np.array([1, 2. * u, 3. * u**2, 4. * u**3, 5. * u**4, 6. * u**5, 7. * u**6])))
158-
self.segment_length = quad(lambda u: s_dot(u), 0, 1)[0]
155+
156+
self.s_dot = lambda u : max(np.linalg.norm(self.coeffs[:, 1:].dot(np.array([1, 2.*u, 3.*u**2, 4.*u**3, 5.*u**4, 6.*u**5, 7.*u**6]))), 1e-6)
157+
self.f_length = lambda ue: quad(lambda u: self.s_dot(u), 0, ue)
158+
self.segment_length = self.f_length(1)[0]
159159

160160
"""
161161
eta3_path_segment::calc_point
@@ -170,6 +170,21 @@ def calc_point(self, u):
170170
assert(u >= 0 and u <= 1)
171171
return self.coeffs.dot(np.array([1, u, u**2, u**3, u**4, u**5, u**6, u**7]))
172172

173+
"""
174+
eta3_path_segment::calc_deriv
175+
176+
input
177+
u - parametric representation of a point along the segment, 0 <= u <= 1
178+
returns
179+
(d^nx/du^n,d^ny/du^n) of point along the segment, for 0 < n <= 2
180+
"""
181+
def calc_deriv(self, u, order=1):
182+
assert(u >= 0 and u <= 1)
183+
assert(order > 0 and order <= 2)
184+
if order == 1:
185+
return self.coeffs[:, 1:].dot(np.array([1, 2.*u, 3.*u**2, 4.*u**3, 5.*u**4, 6.*u**5, 7.*u**6]))
186+
else:
187+
return self.coeffs[:, 2:].dot(np.array([2, 6.*u, 12.*u**2, 20.*u**3, 30.*u**4, 42.*u**5]))
173188

174189
def test1():
175190

0 commit comments

Comments
 (0)