Example #1
0
def main():
    if len(sys.argv) == 3:
        serialID = sys.argv[2]
    else:
        serialID = 'LOCL'

    linkbot = TestLinkbot(serialID)

    print('Testing robot:', linkbot.getSerialId())
    # Get firmware checksum
    print('Firmware checksum:', linkbot.readEeprom(0x423, 2))

    # Test LED
    print('Testing LED...')
    linkbot.setLedColor(255, 0, 0)
    time.sleep(1)
    linkbot.setLedColor(0, 255, 0)
    time.sleep(1)
    linkbot.setLedColor(0, 0, 255)

    # Test buzzer
    print('Testing buzzer...')
    for i in range(440, 550, 5):
        linkbot.setBuzzerFrequency(i)
    linkbot.setBuzzerFrequency(0)

    print('Current accel readings: ' + str(linkbot.getAccelerometer()))

    print('Press all three buttons on the Linkbot...')

    def buttonCB(button, state, timestamp):
        global buttons
        buttons = buttons & ~(1 << button)

    linkbot.enableButtonEvents(buttonCB)
    while buttons:
        time.sleep(1)

    print('Testing motor power...')
    for i in range(1, 4):
        linkbot.setMotorPower(i, 128)
        time.sleep(1)
        linkbot.setMotorPower(i, -128)
        time.sleep(1)
        linkbot.setMotorPower(i, 0)

    print(
        'Testing encoders... Move the encoders around to generate encoder events.'
    )

    def encoderCB(jointNo, angle, timestamp):
        print(jointNo, angle, timestamp)

    linkbot.enableEncoderEvents(5, encoderCB)

    input('Press Enter to quit.')

    linkbot.disableEncoderEvents()
Example #2
0
def main():
    if len(sys.argv) == 2:
        serialID = sys.argv[1]
    else:
        serialID = 'LOCL'

    linkbot = TestLinkbot(serialID)

    print('Testing robot:', linkbot.getSerialId())
    # Get firmware checksum
    print('Firmware checksum:', linkbot.readEeprom(0x423, 2))

    # Test LED
    print('Testing LED...')
    linkbot.setLedColor(255, 0, 0)
    time.sleep(1)
    linkbot.setLedColor(0, 255, 0)
    time.sleep(1)
    linkbot.setLedColor(0, 0, 255)

    # Test buzzer
    print('Testing buzzer...')
    for i in range(440, 550, 5):
        linkbot.setBuzzerFrequency(i)
    linkbot.setBuzzerFrequency(0)

    print('Current accel readings: ' + str(linkbot.getAccelerometer()))

    print('Press all three buttons on the Linkbot...')

    def buttonCB(button, state, timestamp):
        global buttons
        buttons = buttons & ~(1 << button)

    linkbot.enableButtonEvents(buttonCB)
    while buttons:
        time.sleep(1)

    # con = sql.connect('testlog.db')
    initialize_tables(con.cursor())
    cur = con.cursor()
    # Check to see if this linkbot is in our database already. Add it if not
    cur.execute('SELECT * FROM robot_type WHERE Id=\'{}\''.format(
        linkbot.getSerialId()))
    rows = cur.fetchall()
    formFactor = None
    if linkbot.getFormFactor() == Linkbot.FormFactor.I:
        formFactor = "Linkbot-I"
        motor2index = 2
    elif linkbot.getFormFactor() == Linkbot.FormFactor.L:
        formFactor = "Linkbot-L"
        motor2index = 1
    else:
        formFactor = "UNKNOWN"
    print("Testing LinkBot {}".format(linkbot.getSerialId()))
    d = LinkbotDiagnostic(linkbot)
    results = d.runLinearityTest()
    now = time.strftime('%Y-%m-%d %H:%M:%S')
    if len(rows) == 0:
        cur.execute('INSERT INTO robot_type VALUES(\'{}\', \'{}\')'.format(
            linkbot.getSerialId(), formFactor))
    cur.execute("INSERT INTO linearity_tests "
                "VALUES('{}', '{}', {}, {}, {}, {}, {}, {}, {}, {})".format(
                    linkbot.getSerialId(), now, results[0]['forward_slope'],
                    results[0]['forward_rvalue'], results[0]['backward_slope'],
                    results[0]['backward_rvalue'],
                    results[motor2index]['forward_slope'],
                    results[motor2index]['forward_rvalue'],
                    results[motor2index]['backward_slope'],
                    results[motor2index]['backward_rvalue']))

    con.commit()
    con.close()
    linkbot.setBuzzerFrequency(440)
    time.sleep(0.5)
    linkbot.setBuzzerFrequency(0)
def oldmain():
  if len(sys.argv) == 2:
    serialID = sys.argv[1]
  else:
    serialID = 'LOCL'

  linkbot = TestLinkbot(serialID)

  print('Testing robot:', linkbot.getSerialId())
  # Get firmware checksum
  print('Firmware checksum:', linkbot.readEeprom(0x423, 2))

  # Test LED
  print('Testing LED...')
  linkbot.setLedColor(255, 0, 0)
  time.sleep(1)
  linkbot.setLedColor(0, 255, 0)
  time.sleep(1)
  linkbot.setLedColor(0, 0, 255)

  # Test buzzer
  print('Testing buzzer...')
  for i in range(440, 550, 5):
      linkbot.setBuzzerFrequency(i)
  linkbot.setBuzzerFrequency(0)

  print('Current accel readings: ' + str(linkbot.getAccelerometer()))

  print('Press all three buttons on the Linkbot...')
  def buttonCB(button, state, timestamp):
    global buttons
    buttons = buttons & ~(1<<button)
  linkbot.enableButtonEvents(buttonCB)
  while buttons:
      time.sleep(1)

  con = sql.connect('testlog.db')
  initialize_tables(con.cursor())
  cur = con.cursor()
# Check to see if this linkbot is in our database already. Add it if not
  cur.execute('SELECT * FROM robot_type WHERE Id=\'{}\''.format(linkbot.getSerialId()))
  rows = cur.fetchall()
  formFactor = None
  if linkbot.getFormFactor() == Linkbot.FormFactor.I:
    formFactor = "Linkbot-I"
    motor2index = 2
  elif linkbot.getFormFactor() == Linkbot.FormFactor.L:
    formFactor = "Linkbot-L"
    motor2index = 1
  else:
    formFactor = "UNKNOWN"
  print ("Testing LinkBot {}".format(linkbot.getSerialId()))
  d = LinkbotDiagnostic(linkbot)
  results = d.runLinearityTest()
  now = time.strftime('%Y-%m-%d %H:%M:%S')
  if len(rows) == 0:
    cur.execute('INSERT INTO robot_type VALUES(\'{}\', \'{}\')'.format(
        linkbot.getSerialId(), formFactor))
  cur.execute("INSERT INTO linearity_tests "
    "VALUES('{}', '{}', {}, {}, {}, {}, {}, {}, {}, {})".format(
      linkbot.getSerialId(),
      now,
      results[0]['forward_slope'],
      results[0]['forward_rvalue'],
      results[0]['backward_slope'],
      results[0]['backward_rvalue'],
      results[motor2index]['forward_slope'],
      results[motor2index]['forward_rvalue'],
      results[motor2index]['backward_slope'],
      results[motor2index]['backward_rvalue']))

  con.commit()
  con.close()
  linkbot.setBuzzerFrequency(440)
  time.sleep(0.5)
  linkbot.setBuzzerFrequency(0)
    def startTests(self):
        try:
            linkbot = TestLinkbot('LOCL')
            x,y,z = linkbot.getAccelerometer()
            if abs(x) > 0.1 or \
               abs(x) > 0.1 or \
               abs(z-1) > 0.1:
                QtGui.QMessageBox.warning(self, 
                    "Accelerometer readings have anomalies!")
            con = sql.connect('testlog.db')
            initialize_tables(con.cursor())
            cur = con.cursor()
# Check to see if this linkbot is in our database already. Add it if not
            cur.execute('SELECT * FROM robot_type WHERE Id=\'{}\''.format(linkbot.getSerialId()))
            rows = cur.fetchall()
            formFactor = None
            if linkbot.getFormFactor() == Linkbot.FormFactor.I:
                formFactor = "Linkbot-I"
                motor2index = 2
            elif linkbot.getFormFactor() == Linkbot.FormFactor.L:
                formFactor = "Linkbot-L"
                motor2index = 1
            else:
                formFactor = "UNKNOWN"
            print ("Testing LinkBot {}".format(linkbot.getSerialId()))
            d = LinkbotDiagnostic(linkbot)
            results = d.runLinearityTest()
            now = time.strftime('%Y-%m-%d %H:%M:%S')
            if len(rows) == 0:
                cur.execute('INSERT INTO robot_type VALUES(\'{}\', \'{}\')'.format(
                    linkbot.getSerialId(), formFactor))
            cur.execute("INSERT INTO linearity_tests "
                "VALUES('{}', '{}', {}, {}, {}, {}, {}, {}, {}, {})".format(
                    linkbot.getSerialId(),
                    now,
                    results[0]['forward_slope'],
                    results[0]['forward_rvalue'],
                    results[0]['backward_slope'],
                    results[0]['backward_rvalue'],
                    results[motor2index]['forward_slope'],
                    results[motor2index]['forward_rvalue'],
                    results[motor2index]['backward_slope'],
                    results[motor2index]['backward_rvalue']))

            con.commit()
            con.close()
            self.ui.m1f.setText(str(results[0]['forward_slope']))
            self.ui.m1fl.setText(str(results[0]['forward_rvalue']))
            self.ui.m1b.setText(str(results[0]['backward_slope']))
            self.ui.m1bl.setText(str(results[0]['backward_rvalue']))

            self.ui.m2f.setText(str(results[motor2index]['forward_slope']))
            self.ui.m2fl.setText(str(results[motor2index]['forward_rvalue']))
            self.ui.m2b.setText(str(results[motor2index]['backward_slope']))
            self.ui.m2bl.setText(str(results[motor2index]['backward_rvalue']))
            speeds = [ 
                        results[0]['forward_slope'],
                        results[0]['backward_slope'],
                        results[motor2index]['forward_slope'],
                        results[motor2index]['backward_slope'],
                     ]
            linearities = [
                results[0]['forward_rvalue'],
                results[0]['backward_rvalue'],
                results[motor2index]['forward_rvalue'],
                results[motor2index]['backward_rvalue'],
                          ]
            if any(abs(x) < 210 for x in speeds):
                self.ui.lineEdit_status.setText('FAIL')
            elif any(x < 0.99 for x in linearities):
                self.ui.lineEdit_status.setText('FAIL')
            else:
                self.ui.lineEdit_status.setText('Pass')

        except Exception as e:
            QtGui.QMessageBox.warning(self, 
                    "Test Failed: " + str(e))
def main():
  if len(sys.argv) == 3:
    serialID = sys.argv[2]
  else:
    serialID = 'LOCL'

  linkbot = TestLinkbot(serialID)

  print('Testing robot:', linkbot.getSerialId())
  # Get firmware checksum
  print('Firmware checksum:', linkbot.readEeprom(0x423, 2))

  # Test LED
  print('Testing LED...')
  linkbot.setLedColor(255, 0, 0)
  time.sleep(1)
  linkbot.setLedColor(0, 255, 0)
  time.sleep(1)
  linkbot.setLedColor(0, 0, 255)

  # Test buzzer
  print('Testing buzzer...')
  for i in range(440, 550, 5):
      linkbot.setBuzzerFrequency(i)
  linkbot.setBuzzerFrequency(0)

  print('Current accel readings: ' + str(linkbot.getAccelerometer()))

  print('Press all three buttons on the Linkbot...')
  def buttonCB(button, state, timestamp):
    global buttons
    buttons = buttons & ~(1<<button)
  linkbot.enableButtonEvents(buttonCB)
  while buttons:
      time.sleep(1)

  print('Testing motor power...')
  for i in range(1,4):
      linkbot.setMotorPower(i, 128)
      time.sleep(1)
      linkbot.setMotorPower(i, -128)
      time.sleep(1)
      linkbot.setMotorPower(i, 0)
    
  print('Testing encoders... Move the encoders around to generate encoder events.')

  def encoderCB(jointNo, angle, timestamp):
    print(jointNo, angle, timestamp)
  

  linkbot.enableEncoderEvents(5, encoderCB)

  input('Press Enter to quit.')

  linkbot.disableEncoderEvents()
Example #6
0
    def startTests(self):
        try:
            linkbot = TestLinkbot('LOCL')
            x,y,z = linkbot.getAccelerometer()
            if abs(x) > 0.1 or \
               abs(x) > 0.1 or \
               abs(z-1) > 0.1:
                QtGui.QMessageBox.warning(self, 
                    "Warning",
                    "Accelerometer readings have anomalies!")
            global db_file
            con = sql.connect(db_file)
            initialize_tables(con.cursor())
            cur = con.cursor()
# Check to see if this linkbot is in our database already. Add it if not
            cur.execute('SELECT * FROM robot_type WHERE Id=\'{}\''.format(linkbot.getSerialId()))
            rows = cur.fetchall()
            formFactor = None
            if linkbot.getFormFactor() == linkbot3.FormFactor.I:
                formFactor = "Linkbot-I"
                motor2index = 2
            elif linkbot.getFormFactor() == linkbot3.FormFactor.L:
                formFactor = "Linkbot-L"
                motor2index = 1
            else:
                formFactor = "UNKNOWN"
            print ("Testing LinkBot {}".format(linkbot.getSerialId()))
            d = LinkbotDiagnostic(linkbot)
            results = d.runLinearityTest()
            now = time.strftime('%Y-%m-%d %H:%M:%S')
            if len(rows) == 0:
                cur.execute('INSERT INTO robot_type VALUES(\'{}\', \'{}\')'.format(
                    linkbot.getSerialId(), formFactor))
            cur.execute("INSERT INTO linearity_tests "
                "VALUES('{}', '{}', {}, {}, {}, {}, {}, {}, {}, {})".format(
                    linkbot.getSerialId(),
                    now,
                    results[0]['forward_slope'],
                    results[0]['forward_rvalue'],
                    results[0]['backward_slope'],
                    results[0]['backward_rvalue'],
                    results[motor2index]['forward_slope'],
                    results[motor2index]['forward_rvalue'],
                    results[motor2index]['backward_slope'],
                    results[motor2index]['backward_rvalue']))

            con.commit()
            con.close()
            self.ui.m1f.setText(str(results[0]['forward_slope']))
            self.ui.m1fl.setText(str(results[0]['forward_rvalue']))
            self.ui.m1b.setText(str(results[0]['backward_slope']))
            self.ui.m1bl.setText(str(results[0]['backward_rvalue']))

            self.ui.m2f.setText(str(results[motor2index]['forward_slope']))
            self.ui.m2fl.setText(str(results[motor2index]['forward_rvalue']))
            self.ui.m2b.setText(str(results[motor2index]['backward_slope']))
            self.ui.m2bl.setText(str(results[motor2index]['backward_rvalue']))
            speeds = [ 
                        results[0]['forward_slope'],
                        results[0]['backward_slope'],
                        results[motor2index]['forward_slope'],
                        results[motor2index]['backward_slope'],
                     ]
            linearities = [
                results[0]['forward_rvalue'],
                results[0]['backward_rvalue'],
                results[motor2index]['forward_rvalue'],
                results[motor2index]['backward_rvalue'],
                          ]
            if any(abs(x) < 210 for x in speeds):
                self.ui.lineEdit_status.setText('FAIL')
            elif any(x < 0.93 for x in linearities):
                self.ui.lineEdit_status.setText('FAIL')
            else:
                self.ui.lineEdit_status.setText('Pass')

        except Exception as e:
            QtGui.QMessageBox.warning(self, 
                    "Warning",
                    "Test Failed: " + str(e))