當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。