当前位置: 首页>>代码示例>>Python>>正文


Python Drive.goto方法代码示例

本文整理汇总了Python中drive.Drive.goto方法的典型用法代码示例。如果您正苦于以下问题:Python Drive.goto方法的具体用法?Python Drive.goto怎么用?Python Drive.goto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在drive.Drive的用法示例。


在下文中一共展示了Drive.goto方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SRT

# 需要导入模块: from drive import Drive [as 别名]
# 或者: from drive.Drive import goto [as 别名]

#.........这里部分代码省略.........
            print("Calibration only works in live mode.")
        elif self.mode == Mode.LIVE:
            self.setStatus(Status.CALIBRATING)
            self.drive.calibrate()

    def slew(self,pos):
        """
        Slews to position pos in degrees.
        """
        delay = 0.05
        self.status = Status.SLEWING
            
        if self.mode == Mode.SIM:
            print("Slewing in sim mode.")
            if isinstance(pos,SkyCoord):
                now = Time.now()
                altazframe = AltAz(obstime=now,location=self.drive.location)
                apos = pos.transform_to(altazframe)
                x, y = int(apos.az.value), int(apos.alt.value)
            else:
                (xf,yf) = pos # target position in degrees
                x = int(xf)
                y = int(yf)
            (cxf,cyf) = self.pos # current position in degrees
            cx = int(cxf)
            cy = int(cyf)
            if x < cx:
                for i in reversed(range(x,cx)):
                    self.setCurrentPos((i,cy))
                    QtGui.QApplication.processEvents()
                    time.sleep(delay)
            elif x > cx:
                for i in range(cx,x+1):
                    self.setCurrentPos((i,cy))
                    QtGui.QApplication.processEvents()
                    time.sleep(delay)
            if y < cy:
                for i in reversed(range(y,cy)):
                    self.setCurrentPos((x,i))
                    QtGui.QApplication.processEvents()
                    time.sleep(delay)
            elif y > cy:
                for i in range(cy,y+1):
                    self.setCurrentPos((x,i))
                    QtGui.QApplication.processEvents()
                    time.sleep(delay)
        else:
            # This is where live code goes
            # remember self.getCurrentPos() is now in degrees in azalt - NOT pixel coordinates.
            print("Slewing in live mode.")
            if isinstance(pos,SkyCoord):
                now = Time.now()
                altazframe = AltAz(obstime=now,location=self.drive.location)
                apos = pos.transform_to(altazframe)
                x, y = int(apos.az.value), int(apos.alt.value)
            else:
                (x,y) = pos # target - mouse click position in degrees
            (cx,cy) = self.pos # current position in degrees.
            #print("Target Pos: (" + str(x) + "," + str(y) + ")")
            #print("Current Pos: (" + str(cx) + "," + str(cy) + ")")
            # construct a SkyCoord in correct coordinate frame.
            # TODO: fix this -- drive.location
            acreRoadAstropy = self.location
            now = Time(time.time(),format='unix')
            altazframe = AltAz(x*u.deg,y*u.deg,obstime=now,location=acreRoadAstropy)
            skycoordazel = SkyCoord(altazframe)        
            self.drive.goto(skycoordazel,track=self.drive.tracking)

        
    def slewSuccess(self,targetPos):
        """
        """
        (tx,ty) = targetPos
        targetPos = SkyCoord(AltAz(tx*u.deg,ty*u.deg,obstime=self.drive.current_time,location=self.drive.location))
        (cx,cy) = self.pos
        realPos = SkyCoord(AltAz(cx*u.deg,cy*u.deg,obstime=self.drive.current_time,location=self.drive.location))
        d = 0.5
        
        if targetPos.separation(realPos).value <= d:
            #print("Finished slewing to " + str(self.getCurrentPos()))
            return True
        else:
            return False

    def getStatus(self):
        return self.status

    def setStatus(self,status):
        self.status = status

    def track(self,src):
        """
        The SRT will follow the source as it move across the sky.
        """
        if self.mode == Mode.SIM:
            #pos = src.getPos()
            #self.slew(pos)
            self.status = Status.TRACKING
        else:            
            pass
开发者ID:acrerd,项目名称:acreroad_1420,代码行数:104,代码来源:srt.py


注:本文中的drive.Drive.goto方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。