#!/usr/bin/env python # -*- coding: utf-8 -*- # 云台完整代码 from steering import Steering import time import configparser
classCamera: def__init__(self): ''' init camera's parameter ''' config = configparser.ConfigParser() config.read("config.ini") #Horizontal direction control parameters H_servoNum = config.getint("camera","H_servoNum") H_MinPosition = config.getint("camera","H_minPosition") H_MaxPosition = config.getint("camera","H_maxPosition") H_InitPosition = config.getint("camera","H_InitPosition") H_Speed = config.getint("camera","H_speed") #Vertical direction control parameters V_servoNum = config.getint("camera","V_servoNum") V_MinPosition = config.getint("camera","V_minPosition") V_MaxPosition = config.getint("camera","V_maxPosition") V_InitPosition = config.getint("camera","V_InitPosition") V_Speed = config.getint("camera","V_speed") #HC= horizontal control VC=vertiacl control self.HC = Steering(H_servoNum,H_InitPosition, H_MinPosition,H_MaxPosition,H_Speed) self.VC = Steering(V_servoNum,V_InitPosition, V_MinPosition,V_MaxPosition,V_Speed) defcameraRotation(self,direction): ''' This method is used to control the camera's rotating value means: HR = turn right HL = turn left VU = up VD = down GL = left prospective GF = front prospective GR = right prospective GU = up prospective GD = down prospective ''' if direction == "HL": self.HC.forwardRotation() elif direction == "HR": self.HC.reverseRotation() elif direction == "VU": self.VC.reverseRotation() elif direction == "VD": self.VC.forwardRotation() elif direction == "GL": # self.VC.reset() self.HC.turnleft() elif direction == "GR": # self.VC.reset() self.HC.turnrigth() elif direction == "GU": self.VC.turnrigth() elif direction == "GD": self.VC.turnleft() elif direction == "GF": self.VC.reset() self.HC.reset() elif direction == "S": self.VC.stop() self.HC.stop() else: print("input error,please input :HL,HR,VU,VD") if __name__ == "__main__": camera = Camera() while(True): direction = input("Please input direction: ") camera.cameraRotation(direction)