1 from __future__
import division, absolute_import
5 from coordConv
import PVT
8 from .checkSegment
import checkSegment
9 from .fullSlew
import fullSlew
16 def slew(pA, vA, pB, vB, tMin, axisLim):
17 """!Compute a jerk-limited slew -- as a single segment, if possible, else a multi-segment path
19 @param[in] pA position of starting point at time t = 0 (deg)
20 @param[in] vA velocity of starting point at time t = 0 (deg/sec)
21 @param[in] pB position of ending point at time t = 0 (deg)
22 @param[in] vB velocity of ending point at time t = 0 (deg/sec)
23 @param[in] tMin minimum duration of slew (sec); if < 0 then 0 is silently used
24 @param[in] axisLim axis limits (a tcc.base.AxisLim); position limits are ignored
26 @return pvtList: a list of at least 2 PVTs; the time of the first one is 0
28 @throw RuntimError if:
29 - The jerk limit is 0 (or so small that division overflows)
30 - The slew could not be computed
33 2013-12-06 ROwen Converted from mov_Slew.for
36 return "tcc.mov.slew(pA=%r, vA=%r, pB=%r, vB=%r, tMin=%r, axisLim=%s)" % (pA, vA, pB, vB, tMin, axisLim)
38 def reportBug(msgStr):
39 """!Write a message to stderr that includes outputs, then raise RuntimeError
41 sys.stderr.write(
"%s failed:\n%s\n" % (formatArgs(), msgStr))
42 raise RuntimeError(msgStr)
45 t_jerk = max(axisLim.accel / axisLim.jerk, MinTJerk)
46 except ZeroDivisionError:
47 raise RuntimeError(
"Cannot compute slew; jerk limit is 0 (or nearly so)")
56 tryInterval = max(tMin, t_jerk)
57 for twoNodeIter
in range(MaxTries):
58 tryTime += tryInterval
59 pB_end = pB + (vB * tryTime)
63 pA=pA, vA=vA, pB=pB_end, vB=vB, dt=tryTime,
64 doPos=
False, doVel=
True, doAccel=
True, doJerk=
True, axisLim=axisLim,
66 if twoNodeErrCode == tcc.base.AxisErr_OK:
69 PVT(pB_end, vB, tryTime),
76 pvtList =
fullSlew(pA, vA, pB, vB, t_jerk, axisLim.vel, axisLim.accel)
81 if pvtList[-1].t < tMin:
83 pvtList = fullSlew (pA, vA, pB, vB, t_jerk, axisLim.vel, axisLim.accel)
84 except Exception
as e:
85 sys.stderr.write(
"%s failed:\n%s" % (formatArgs(), e))
88 if pvtList[-1].t < tMin:
89 reportBug(
'Bug! Computed slew too short: pvtList[-1].t=%s < tMin=%s' % (pvtList[-1].t, tMin))
def slew
Compute a jerk-limited slew тАУ as a single segment, if possible, else a multi-segment path...
def checkSegment
Check a suggested path segment of constant jerk.
def fullSlew
Compute a jerk-limited trapezoidal slew.