1 from __future__
import division, absolute_import
8 __all__ = [
"oneSlewIter"]
15 def oneSlewIter(doAxis, oldMount, newMount, begTime, minTime, axeLim):
16 """!Compute a slew for all axes, given the starting and target paths.
18 @param[in] doAxis slew this axis? A sequence of NAxes bools
19 @param[in] oldMount initial position, as a list of NAxes PVTs
20 @param[in] newMount target coordinates, as a list of NAxes PVTs
21 @param[in] begTime start time (TAI, MJD sec)
22 @param[in] minTime minimum slew duration (sec)
23 @param[in] axeLim axes limits, as an tcc.base.AxeLim
24 where NAxes = tcc.base.NAxes
27 - pathList: a list of NAxes pvtLists, where each pvtList is a list of PVTs describing the motion of that axis;
28 if doAxis[axis] is false then pathList[axis] is an empty list
29 - endTime: end time of slew (TAI, MJD sec)
31 @throw RuntimeError if the slew ends too soon or cannot be computed
33 If no axes are to be slewed (slew not requested, or beginning or ending
34 position is unknown), then endTime = begTime + minTime. No warning is given.
37 2013-12-06 ROwen Converted from doSlew.for
40 return "tcc.mov.oneSlewIter(doAxis=%s, oldMount=%s, newMount=%s, begTime=%r, minTime=%r)" % \
41 (doAxis, oldMount, newMount, begTime, minTime)
43 def reportBug(msgStr):
44 """!Write a detailed message to stderr and raise RuntimeError"""
45 sys.stderr.write(
"%s failed:\n%s\n" % (formatArgs(), msgStr))
46 raise RuntimeError(msgStr)
51 pathList = [[]]*tcc.base.NAxes
56 for axis
in range(tcc.base.NAxes):
57 oldPVT = oldMount[axis]
58 newPVT = newMount[axis]
59 if doAxis[axis]
and oldPVT.isfinite()
and newPVT.isfinite():
65 pA = oldPVT.getPos(begTime),
67 pB = newPVT.getPos(begTime),
70 axisLim = axeLim[axis],
73 sys.stderr.write(
"%s failed on axis %s when calling tcc.mov.slew\n" % (formatArgs(), axis))
80 endTime = max(endTime, pvtList[-1].t)
81 pathList[axis] = list(pvtList)
85 for axis
in range(tcc.base.NAxes):
86 pvtList = pathList[axis]
89 if lastPVT.t < endTime - MinPVTSep:
90 endPVT = newMount[axis].copy(endTime)
91 pvtList.append(endPVT)
94 if (endTime > 0.0)
and (endTime < begTime + minTime):
95 reportBug(
"Bug! Computed slew ended too soon; endTime=%s" % (endTime,))
97 return pathList, endTime
def oneSlewIter
Compute a slew for all axes, given the starting and target paths.