def contact_camera(): nrf_bridge = Bridge('/dev/ttyACM0') # '/dev/ttyACM0' a = nrf_bridge.assign_addresses() for i in list(a.keys()): nrf_bridge.set_TX_address(i) if nrf_bridge.get_ID_type()[6] == 1: # find first camera in neighbours camera_address = i break else: raise RuntimeError('No cameras found') return nrf_bridge
from nrf import Bridge import numpy as np import cv2 import math import time from sklearn.neighbors import NearestNeighbors import scipy.sparse.csgraph import circle as CL import clustering as CLTR SHOW_NEIGHBORS = True LED_DETECTION_THRESHOLD = 6 ix, iy = -1, -1 nrf = Bridge('/dev/ttyACM0') # '/dev/ttyACM1' a = nrf.assign_addresses() for i in list(a.keys()): nrf.set_TX_address(i) if nrf.get_ID_type()[6] == 1: # find first camera in neighbours camera_address = i break else: raise RuntimeError('No cameras found') def draw_circle(event, x, y, flags, param): global ix, iy if event == cv2.EVENT_LBUTTONDBLCLK: destination = [x, y] print(destination)
sys.path.insert(0, '../libs/') from nrf import Bridge if len(sys.argv) == 2: if sys.argv[1] == '-c': camera_calibration = True print 'Entered camera calibration mode.' else: # -c: for turning on the calibration LED patterns print 'Usage:', sys.argv[0], '[-c]' sys.exit(1) else: camera_calibration = False nrf = Bridge() cameras, ebugs, unknowns = nrf.assign_static_addresses('../libs/ebug_tab.json') for addr, info in ebugs.items(): print 'Initializing eBug: ', addr nrf.set_TX_address(addr) nrf.enable_LEDs(0, 1, 0, 0) nrf.LED_brightness(8) nrf.LCD_backlight(0) if camera_calibration == True: # Calibration LED pattern (upward looking set): # D2 is illuminated red - front (0 degrees) - GGRGG # D18 is illuminated blue - (180 degrees) - GGBGG red = 0x0800 + 0x4000 + 0x8000 + 0x0001 + 0x0040 + 0x0080 + 0x0100 green = 0x1000 + 0x2000 + 0x0002 + 0x0020 + 0x0200 + 0x0400 blue = 0x0010 + 0x0008 + 0x0004
from nrf import Bridge import time from random import randint nrf = Bridge('/dev/ttyACM1')#'/dev/ttyACM0' camera, eBugs, unknown = nrf.assign_addresses() ID = 0 for address, info in eBugs.items(): nrf.set_TX_address(address) nrf.LCD_backlight(0) nrf.enable_LEDs(0,1,0,0) nrf.LED_brightness(20) LED_set = info['led_sequence'] nrf.set_LEDs(*LED_set) ID += 1
from nrf import Bridge import sys if 'all' in sys.argv: flash_all = True sys.argv.remove('all') else: flash_all = False if len(sys.argv) < 2: raise RuntimeError( 'usage: %s master|slave|<filename> [all] [<serial port>]' % sys.argv[0]) if len(sys.argv) < 3: nrf = Bridge() else: nrf = Bridge(sys.argv[2]) master = '../ebug2014-firmware/eBug2014 Master.cydsn/CortexM3/ARM_GCC_493/Release/eBug2014 Master.cyacd' slave = '../ebug2014-firmware/eBug2014 Slave.cydsn/CortexM3/ARM_GCC_493/Release/eBug2014 Slave.cyacd' flash_func = nrf.flash_all_ebugs if flash_all else nrf.flash if sys.argv[1] == 'master': flash_func(master) elif sys.argv[1] == 'slave': flash_func(slave) else: flash_func(sys.argv[1])
#!/usr/bin/python from nrf import Bridge nrf=Bridge() camera, eBugs, unknown = nrf.assign_addresses() for addr, info in eBugs.items(): nrf.set_TX_address(addr) nrf.print_top('-'.join(str(element) for element in info['psoc_id']))
from __future__ import with_statement from __future__ import division from __future__ import absolute_import #import settings import time import sys import threading from multiprocessing import Process from io import open sys.path.insert(0, '../libs/') from nrf import Bridge nrf = Bridge() while True: camera, eBugs, unknown = nrf.assign_static_addresses(path = \ u'../libs/ebug_tab.json') if camera: break else: print u" -------- Waiting for camera --------" time.sleep(0.03) #set communication with the first camera detected #to be changed when multiple cameras nrf.set_TX_address(iter(camera).next()) #settings camera # Do not play with the settings, we will fix them with camera.py
layout.addWidget(P_r, 4, 2) layout.addWidget(I_l, 5, 1) layout.addWidget(I_r, 5, 2) layout.addWidget(D_l, 6, 1) layout.addWidget(D_r, 6, 2) def update(): l, r = n.get_motor_turn_counts() pos_l.setText(str(l)) pos_r.setText(str(r)) l, r = n.get_motor_speed() # eBug actually measures period, not speed l = (1 << 16) / l # this is the value the controller uses r = (1 << 16) / r speed_l.setText(str(l)) speed_r.setText(str(r)) timer = QTimer() timer.timeout.connect(update) timer.start(10) n = Bridge() if n.assign_addresses(): win.show() sys.exit(app.exec_()) else: print('No eBugs found')
try: nrf.set_camera_thresholds(thresholds.values) except RuntimeError, e: # ACK not received, set trackbar back # to original value thresholds.values[self.i] = old cv2.setTrackbarPos([u'Red', u'Green', u'Blue', u'Magenta'] \ [self.i / 2] + u' ' + [u'U', u'V'] \ [self.i % 2], u'Blob Camera', old) # # # end class thresholds nrf = Bridge(u'/dev/ttyACM0') # or '/dev/ttyACM1' ToDo a = nrf.assign_addresses() for i in list(a.keys()): nrf.set_TX_address(i) if nrf.get_ID_type()[6] == 1: # find first camera in neighbours camera_address = i break else: raise RuntimeError(u'No cameras found') # We are operating the camera at SXGA resolution. # If you want to # overclock th PSoC and camera (default is 48MHz, which gives 15fps SXGA, # 30fps VGA, 60fps CIF and 120fps QCIF)