1 from __future__
import division, absolute_import
4 from .pathSegment
import PathSegment
6 __all__ = [
"checkSegment"]
8 def checkSegment(pA, vA, pB, vB, dt, doPos, doVel, doAccel, doJerk, axisLim):
9 """!Check a suggested path segment of constant jerk
11 @param[in] pA position of starting point at time t = 0
12 @param[in] vA velocity of starting point at time t = 0
13 @param[in] pB position of ending point at time t = dt
14 @param[in] vB velocity of ending point at time t = dt
15 @param[in] dt duration of motion
16 @param[in] doPos log test position?
17 @param[in] doVel log test velocity?
18 @param[in] doAccel log test acceleration?
19 @param[in] doJerk log test jerk?
20 @param[in] axisLim axis limits (a tcc.base.AxisLim)
22 @return errCode: one of the tcc.base.AxisErr_* constants defined in basics.h
24 @todo: make this a method of PathSegment
27 If min and max position, max velocity, etc. cannot be computed
28 for the path, errCode is set to tcc.base.AxisErr_CannotCompute.
30 If a limit would be exceeded along the path, errCode is set appropriately.
31 Note: limits are checked in this order:
32 minpos, maxpos, vel, accel, jerk
33 and checking terminates at the first failure.
36 Even if you request that position limits be checked, some paths
37 will be accepted that have points outside the allowed region. See Details.
39 Position and velocity limits are not checked with strict accuracy,
40 but instead the limits are padded with a small fudge factor. See Details.
43 In handling position limits, we must allow motion from out of bounds
44 towards being in bounds. Hence this routine allows paths with points
45 outside the position limits in some circumstances. Specifically:
47 If the beginning position of the path is outside the allowed limits,
48 AND if the extreme pos. of the path is FURTHER outside the allowed limits,
49 ONLY :is the path considered unacceptable due to position limits.
52 2013-12-06 ROwen Converted from mov_checkPath.for
57 segment = PathSegment(pA=pA, vA=vA, pB=pB, vB=vB, dt=dt, doPos=doPos)
59 return tcc.base.AxisErr_CannotCompute
65 if segment.pMin < min(axisLim.minPos, pA):
66 return tcc.base.AxisErr_MinPos
68 if segment.pMax > max(axisLim.maxPos, pA):
69 return tcc.base.AxisErr_MaxPos
71 if doVel
and abs(segment.vPeak) > axisLim.vel:
72 return tcc.base.AxisErr_MaxVel
74 if doAccel
and abs(segment.aPeak) > axisLim.accel:
75 return tcc.base.AxisErr_MaxAccel
77 if doJerk
and abs(segment.j) > axisLim.jerk:
78 return tcc.base.AxisErr_MaxJerk
80 return tcc.base.AxisErr_OK
def checkSegment
Check a suggested path segment of constant jerk.