Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.apo.nmsu.edu/Telescopes/TCC/html/slew_8py_source.html
Дата изменения: Tue Sep 15 02:25:37 2015
Дата индексирования: Sun Apr 10 00:18:36 2016
Кодировка: IBM-866
lsst.tcc: python/tcc/mov/slew.py Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
slew.py
Go to the documentation of this file.
1 from __future__ import division, absolute_import
2 
3 import sys
4 
5 from coordConv import PVT
6 import tcc.base
7 
8 from .checkSegment import checkSegment
9 from .fullSlew import fullSlew
10 
11 __all__ = ["slew"]
12 
13 MaxTries = 4
14 MinTJerk = 0.1
15 
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
18 
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
25 
26  @return pvtList: a list of at least 2 PVTs; the time of the first one is 0
27 
28  @throw RuntimError if:
29  - The jerk limit is 0 (or so small that division overflows)
30  - The slew could not be computed
31 
32  History:
33  2013-12-06 ROwen Converted from mov_Slew.for
34  """
35  def formatArgs():
36  return "tcc.mov.slew(pA=%r, vA=%r, pB=%r, vB=%r, tMin=%r, axisLim=%s)" % (pA, vA, pB, vB, tMin, axisLim)
37 
38  def reportBug(msgStr):
39  """!Write a message to stderr that includes outputs, then raise RuntimeError
40  """
41  sys.stderr.write("%s failed:\n%s\n" % (formatArgs(), msgStr))
42  raise RuntimeError(msgStr)
43 
44  try:
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)")
48 
49  try:
50  # Try longer and longer 2-node paths to see if any are acceptable.
51  # The intervals tested must be at least tMin, but because tMin may
52  # be very small or zero, I use the greater of tMin and t_jerk;
53  # t_jerk is a physically sensible scale factor for slewing.
54  pvtList = []
55  tryTime = 0.0
56  tryInterval = max(tMin, t_jerk)
57  for twoNodeIter in range(MaxTries):
58  tryTime += tryInterval
59  pB_end = pB + (vB * tryTime)
60  # check vel, accel, jerk, but not pos (we don't know the pos limits)
61 
62  twoNodeErrCode = checkSegment(
63  pA=pA, vA=vA, pB=pB_end, vB=vB, dt=tryTime,
64  doPos=False, doVel=True, doAccel=True, doJerk=True, axisLim=axisLim,
65  )
66  if twoNodeErrCode == tcc.base.AxisErr_OK:
67  pvtList = (
68  PVT(pA, vA, 0),
69  PVT(pB_end, vB, tryTime),
70  )
71  break
72 
73  # if a two-node path is acceptable, use it
74  if not pvtList:
75  # no two-node path found; compute a full path
76  pvtList = fullSlew(pA, vA, pB, vB, t_jerk, axisLim.vel, axisLim.accel)
77 
78  # if slew too short, increase t_jerk and compute again
79  # full slews can be almost as short as 2*t_jerk, hence to gurantee
80  # that full slew is long enough, t_jerk must be >= tMin / 2
81  if pvtList[-1].t < tMin:
82  t_jerk = tMin / 2.0
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))
86  raise
87 
88  if pvtList[-1].t < tMin:
89  reportBug('Bug! Computed slew too short: pvtList[-1].t=%s < tMin=%s' % (pvtList[-1].t, tMin))
90 
91  return pvtList
def slew
Compute a jerk-limited slew тАУ as a single segment, if possible, else a multi-segment path...
Definition: slew.py:16
def checkSegment
Check a suggested path segment of constant jerk.
Definition: checkSegment.py:8
def fullSlew
Compute a jerk-limited trapezoidal slew.
Definition: fullSlew.py:9