def moveAntenna(self, dirStr, isFine): global srvoConnected, srvoPort, centerBearing, panOffset, tiltOffset moveSteps = int(self.spn_moveSensitivity.text()) if not isFine: moveSteps *= 5 bearing = self.lcd_sttnBearing.value() elevation = self.lcd_sttnElevation.value() self.log( 'Moving antenna from %.2f, %.2f by %.2f deg.' % (bearing, elevation, moveSteps), 'INF') if dirStr == 'Center': moveServosToPosition(srvoPort, 127, 127) elif dirStr == 'Up': nudgeServos(srvoPort, 0, 0 - moveSteps) elif dirStr == 'Left': nudgeServos(srvoPort, 0 - moveSteps, 0) elif dirStr == 'Right': nudgeServos(srvoPort, moveSteps, 0) elif dirStr == 'Down': nudgeServos(srvoPort, 0, moveSteps) else: print 'errorrrr' self.log( 'After: antenna positions: centerBear: %.2f, panOffset: %.2f, tiltOffset: %.2f' % (centerBearing, panOffset, tiltOffset), 'INF')
def servoConnect(self): global srvoConnected, srvoPort if (not srvoConnected): srvoPort = serialConnect(self.cbo_srvoComPort.currentText(), int(self.cbo_srvoBaudRate.currentText())) if (srvoPort != []): srvoConnected = True setServoAccel(srvoPort) setServoSpeed(srvoPort) moveServosToPosition(srvoPort, 127, 127) self.btn_srvoConnect.setText("Disconnect") else: srvoPort.close() srvoConnected = False self.btn_srvoConnect.setText("Connect")
def calibrateStation(self): global calibrateGroundStation, calibrateIndex, skipCount, startCount, \ calibrateAzi, calibrateElev, calibrateSteps self.prg_sttnCalibrate.setValue(0) if calibrateGroundStation: # if currently calibrating the ground station, then stop calibration calibrateGroundStation = False calibrateAzi = False # Azimuth and Elevation calibrated separately calibrateElev = False self.btn_sttnCalibrate.setText('Calibrate Station') moveServosToPosition(srvoPort, 127, 127) else: moveServosToPosition(srvoPort, 0, 127) calibrateIndex = 0 skipCount = 0 startCount = 0 calibrateSteps = 0 self.btn_sttnCalibrate.setText('Stop Calibration') calibrateGroundStation = True calibrateAzi = True self.txt_sttnElevCalibrationTable.clear() self.txt_sttnAziCalibrationTable.clear()
def trackTarget(trackList, imuL): global aziDegreeLookup, elevDegreeLookup aziPosition = -1 elevPosition = -1 reachedMax = False reachedMin = False moveDown = False moveDeg = 0 direction = 1 aziDegree = int(round(trackList[1])) elevDegree = int(round(trackList[2])) if aziDegree < 0 or aziDegree > 360: print 'Error pointing to Azi degree %d out of range' % (aziDegree) return if elevDegree < 0: elevDegree = 0 if elevDegree > 90: elevDegree = 90 print 'Pointing to Azi degree %d and Elev degree %d' % (aziDegree, elevDegree) while aziPosition == -1: aziPosition = aziDegreeLookup[aziDegree + moveDeg * direction] moveDeg += 1 direction = 1 if moveDown: direction = -1 moveDown = False else: moveDown = True if aziDegree + moveDeg * direction > 360: direction = -1 reachedMax = True if aziDegree + moveDeg * direction < 0: direction = 1 reachedMin = True if reachedMax and reachedMin: print 'Have check all values, everything is -1' return print 'Point to Azi position %d - degree %d' % ( aziPosition, aziDegree + moveDeg * direction) reachedMax = False reachedMin = False moveDown = False moveDeg = 0 while elevPosition == -1: elevPosition = elevDegreeLookup[elevDegree + moveDeg * direction] moveDeg += 1 direction = 1 if moveDown: direction = -1 moveDown = False else: moveDown = True if elevDegree + moveDeg * direction > 90: direction = -1 reachedMax = True if elevDegree + moveDeg * direction < 0: direction = 1 reachedMin = True if reachedMax and reachedMin: print 'Have check all values, everything is -1' return print 'Point to Elev position %d - degree %d' % ( elevPosition, elevDegree + moveDeg * direction) moveServosToPosition(srvoPort, int(aziPosition), int(elevPosition))
def processCalibrationV2(self): global srvoConnected, srvoPort, calibrateGroundStation, calibrateIndex, \ skipCount, imuList, startCount, calibrateAzi, calibrateElev, \ aziDegreeLookup, elevDegreeLookup, isCalibrated, calibrateSteps if startCount < 100: startCount += 1 return if skipCount < 3: skipCount += 1 return skipCount = 0 if calibrateGroundStation: if not imuList: self.log('attempt to calibrate station when imuList is NULL', 'ERR') self.calibrateStation() return if calibrateAzi: deg = int(round(imuList[7])) if deg < 0 or deg > 360: self.log( 'error azi calibrating, index %d out of bounds' % (deg), 'ERR') return # aziPositionLookup[calibrateIndex] = deg tStr = '%03d - %03d' % (calibrateIndex, aziPositionLookup[calibrateIndex]) calibrateIndex += 1 calibrateSteps += 1 self.prg_sttnCalibrate.setValue(calibrateSteps * 100 / 330) if calibrateIndex >= 253: calibrateAzi = False calibrateElev = True skipCount = 0 startCount = 0 calibrateIndex = getServoMinAltitude() moveServosToPosition(srvoPort, 127, calibrateIndex) return moveServosToPosition(srvoPort, calibrateIndex, 127) self.txt_sttnAziCalibrationTable.append(tStr) elif calibrateElev: print 'calibrate elevation %d' % (calibrateIndex) idx = int(round(imuList[9])) if idx < 0: self.log( 'error elev calibrating, index %d out of bounds' % (idx), 'ERR') calibrateIndex -= 1 moveServosToPosition(srvoPort, 127, calibrateIndex) return if idx > 360: self.log( 'error elev calibrating, index %d out of bounds' % (idx), 'ERR') return elevDegreeLookup[idx] = calibrateIndex tStr = '%03d - %03d' % (idx, elevDegreeLookup[idx]) calibrateIndex -= 1 calibrateSteps += 1 self.prg_sttnCalibrate.setValue(calibrateSteps * 100 / 330) if calibrateIndex <= getServoMaxAltitude(): calibrateElev = False return moveServosToPosition(srvoPort, 127, calibrateIndex) self.txt_sttnElevCalibrationTable.append(tStr) else: isCalibrated = True printCalibration() self.calibrateStation()