def __init__(self): try: self.controller = serial.Serial(self.port, self.baudrate, self.bytesize, self.parity, self.stopbits, self.timeout) except: print("Unexpected error:", sys.exc_info()[0]) raise self.messagePub = publisher.Publisher("P8X32 Message Publisher") self.rangePub = publisher.Publisher("P8X32-MB1220 Range Publisher") self.ranges = self.rangeInit self.qDepth = 500 # number of range readings to keep self.rangeList = deque(maxlen=self.qDepth) self.t0 = time.time()
def __init__(self, robot=None, robot_url=None, user=None, token=None): self.robot = robot self.robot_url = robot_url self.user = user self.token = token self.headers = {"content-type": "application/json"} self.t0 = time.time() self.posts = 0 self.totalPostTime = 0. try: self.robot_ca = os.environ['ROBOT_CA'] except: self.robot_ca = False if user and token: self.setAuthToken(user, token) self.publisher = publisher.Publisher("Robot http Client Publisher") self.postQ = queue.Queue() self.postThread = threading.Thread(target=self.postService, name="Post Service Thread") self.postThread.setDaemon(True) self.postThread.start()
def __init__(self, port=MPU9150_ADDRESS): self.port = port # hard iron offsets in uT measured on 2019-01-28 for lbr2a # for an untested device, set the default values to # hix = 0, hiy = 0 # self.hix = hix # self.hiy = hiy self.hix = 0 self.hiy = 0 self.alpha_setting = None self.beta_setting = None self.mpu_enabled = False self.read_errors = 0 self.error_limit = 3 self.mpuPub = publisher.Publisher("MPU Message Publisher") self.gyroPub = publisher.Publisher("Gyro Publisher") self.doPublish = False # doPublish means publish even if the result 0 self.onRecord = False self.gyroRange = 250 # dps self.gyroFullScaleRange = 2000 # dps self.gyroSquelch = 0.09 self.gyroCalibration = self.zeroGyroResult self.accelRange = 0 # selects range of +/- 2g #self.magDecl = 13+55./60. # todo dynamically look up declination self.magDecl = 0. self.magResolution = 0.3 # AK8975C for MPU9150, +4095 to -4096 : +-1229uT self.asa = [0., 0., 0.] # sensitivy adjustments self.rawAngleL = [] self.lastg = self.zeroGyroResult self.lasta = self.zeroAccelResult self.lastm = self.zeroMagResult self.lastsu = mpuData(self.zeroGyroResult, self.zeroAccelResult, self.zeroMagResult, 0., 0., 0.) self.mpusu_zero = mpuData(self.zeroGyroResult, self.zeroAccelResult, self.zeroMagResult, 0., 0., 0.) self.lastRawAngle = -1 self.unitConTime = 0 self.numReads = 0 self.setup()
def __init__(self, port=SDC2130_Port): self.port = port try: self.controller = Serial(self.port, self.baudrate, self.bytesize, self.parity, self.stopbits, self.timeout) except: print("Unexpected error:", sys.exc_info()[0]) raise self.motorCommand = self.STOP_MOTOR_COMMAND self.messagePub = publisher.Publisher("SDC2130 Message Publisher") self.voltagePub = publisher.Publisher("SDC2130 Voltage Publisher") self.ampsPub = publisher.Publisher("SDC2130 Amperage Publisher") self.motorControlPub = publisher.Publisher( "SDC2130 Motor Control Publisher") self.lastVoltages = voltages(12.0, 12.0, 5.11, time.asctime())
def __init__(self,language='English',rate=150, voice_id='Kevin'): self.engine = boto3.Session(aws_access_key_id=os.environ['ROBOT_AWS_AK'], aws_secret_access_key=os.environ['ROBOT_AWS_SK'], region_name='us-west-2').client('polly') self.output_format = 'mp3' self.supported_formats = ['mp3', 'wav', 'mp4', 'amr', 'amr-wb', 'ogg', 'webm', 'flac'] self.voice_id = voice_id self.language = language # self.engine.setProperty('rate', rate) # rate not currently used for this version self.speechPub = publisher.Publisher("Speech Publisher")
def __init__(self, language='English', rate=150): self.engine = pyttsx3.init() self.language = language self.engine.setProperty('rate', rate) self.speechPub = publisher.Publisher("Speech Publisher")