def test_locator(self): orb = Sphero(MyTestCase.SPHERO) orb.connect() orb.set_stream_callback('odometer', callback=self.print_xy, mask_id=2) orb.update_streaming(rate=10) time.sleep(2) before = MyTestCase.current_position orb.config_locator(10,50,0) orb.ping() time.sleep(2) orb.config_locator(50, -10, 0) orb.ping() middle = MyTestCase.current_position orb.ping() time.sleep(2) orb.ping() time.sleep(2) after = MyTestCase.current_position self.assertNotEquals(before, middle) self.assertNotEquals(middle, after)
def test_set_heading2(self): orb = Sphero(MyTestCase.SPHERO) orb.connect() for angle in range(0,360,90): orb.roll(30,90) time.sleep(3) orb.set_heading(angle) time.sleep(1) orb.roll(30, 90) time.sleep(3)
def test_set_heading(self): orb = Sphero(MyTestCase.SPHERO) orb.connect() orb.set_tail_light(255) orb.set_stabilization(False) print("Move Sphero so tail is heading to -y") input("Press Enter to continue...") orb.set_stabilization(True) orb.set_tail_light(0) time.sleep(3)
def test_set_heading(self): orb = Sphero(MyTestCase.SPHERO) orb.connect() orb.set_tail_light(255) orb.set_heading(0) time.sleep(2) orb.set_heading(90) time.sleep(2) orb.set_heading(180) time.sleep(2) orb.set_heading(270) time.sleep(2) orb.set_tail_light(0) time.sleep(3)
def test_roll(self): orb = Sphero(MyTestCase.SPHERO) orb.connect() orb.roll(10,0)
def test_set_color(self): orb = Sphero(MyTestCase.SPHERO) orb.connect() orb.set_rgb_led(255,0,0)
def test_connect(self): orb = Sphero(MyTestCase.SPHERO) result = orb.connect() self.assertTrue(result)
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ STATIC_URL = '/static/' from sphero import Sphero SP = Sphero("/dev/tty.Sphero-GPR-AMP-SPP") SP.connect()