Permalink
Browse files

setup exuro_local.cfg to override values read from exuro.cfg.

added an flag to make the eyes active or inactive. this will allow use of the eye module without having an arduino connected to the system.
added experimental support for capturing all the images generated via the track program. this results in a huge number of files being generated and uses around 100MB disk / 5 seconds of run time. this is now disabled because of the problem of filling up the disk. need to reevaluate how this should work.
  • Loading branch information...
1 parent 60806ce commit c2c5c38c25ec0b5b410e219b6f598246c2d3a14c @pkropf committed Feb 18, 2011
Showing with 61 additions and 15 deletions.
  1. +1 −0 Build Environment.txt
  2. +7 −7 cfg.py
  3. +23 −0 exuro.cfg
  4. +16 −7 eye.py
  5. +14 −1 track.py
View
@@ -5,3 +5,4 @@ apt-get install python-virtualenv python-dev cmake g++ libusb-1.0-0 libusb-1.0-0
easy_install python-twitter
easy_install oauth2
easy_install Tweepy
+easy_install gdata
View
14 cfg.py
@@ -24,9 +24,7 @@
exuro = ConfigParser.RawConfigParser()
exuro.read('exuro.cfg')
-
-exuro_local = ConfigParser.RawConfigParser()
-exuro_local.read('exuro_local.cfg')
+exuro.read('exuro_local.cfg') # override any values in the general configuration file
class servo(object):
@@ -47,6 +45,7 @@ class general(object):
class eye(object):
class left(object):
+ active = exuro.getboolean('left eye', 'active')
hpin = exuro.getint('left eye', 'horizontal')
vpin = exuro.getint('left eye', 'vertical')
hmin = exuro.getint('left eye', 'hmin')
@@ -60,6 +59,7 @@ class left(object):
height = exuro.getfloat('left eye', 'height')
class right(object):
+ active = exuro.getboolean('right eye', 'active')
hpin = exuro.getint('right eye', 'horizontal')
vpin = exuro.getint('right eye', 'vertical')
hmin = exuro.getint('right eye', 'hmin')
@@ -82,7 +82,7 @@ class kinect(object):
class keys(object):
- consumer_key = exuro_local.get('keys', 'consumer_key')
- consumer_secret = exuro_local.get('keys', 'consumer_secret')
- access_key = exuro_local.get('keys', 'access_key')
- access_secret = exuro_local.get('keys', 'access_secret')
+ consumer_key = exuro.get('keys', 'consumer_key')
+ consumer_secret = exuro.get('keys', 'consumer_secret')
+ access_key = exuro.get('keys', 'access_key')
+ access_secret = exuro.get('keys', 'access_secret')
View
@@ -36,6 +36,8 @@ vfield = 43
[left eye]
#
+# active - flag indicating if the left eye is currently online
+#
# horizontal - the arduino port used to control the left eye
# horizontal servo.
#
@@ -67,6 +69,7 @@ vfield = 43
# down.
#
+active = True
horizontal = 9
vertical = 10
hmin = 0
@@ -81,6 +84,8 @@ height = 1.753
[right eye]
#
+# active - flag indicating if the right eye is currently online
+#
# horizontal - the arduino port used to control the right eye
# horizontal servo.
#
@@ -111,6 +116,7 @@ height = 1.753
# position. 1 indicates that it moves up, -1 indicates that it moves
# down.
+active = True
horizontal = 12
vertical = 11
hmin = 40
@@ -144,3 +150,20 @@ limit_watch = True
debug = True
#debug = False
+
+
+[keys]
+#
+# consumer_key - twitter consumer key
+#
+# consumer_secret - twitter consumer secret
+#
+# access_key - twitter access key
+#
+# access_secret - twitter access secret
+#
+
+consumer_key = MISSING
+consumer_secret = MISSING
+access_key = MISSING
+access_secret = MISSING
View
23 eye.py
@@ -28,22 +28,29 @@
class Eye(object):
- def __init__(self, name,
+ def __init__(self, name, active,
horizontal_pin, vertical_pin,
hmin, hmax, vmin, vmax,
port, offset,
height,
horient, vorient):
self.name = name
+ self.active = active
self.hpin = horizontal_pin
self.vpin = vertical_pin
self.hmin = hmin
self.hmax = hmax
self.vmin = vmin
self.vmax = vmax
self.port = port
- self.hservo = Servo(self.hpin, self.hmin, self.hmax, port)
- self.vservo = Servo(self.vpin, self.vmin, self.vmax, port)
+
+ if self.active:
+ self.hservo = Servo(self.hpin, self.hmin, self.hmax, port)
+ self.vservo = Servo(self.vpin, self.vmin, self.vmax, port)
+ else:
+ self.hservo = None
+ self.vservo = None
+
self.offset = offset
self.height = height
self.horient = horient
@@ -69,8 +76,10 @@ def center(self):
def move(self, horizontal, vertical):
if cfg.general.debug:
print 'move', self.name, 'to', horizontal, vertical
- self.hservo.send(horizontal)
- self.vservo.send(vertical)
+
+ if self.active:
+ self.hservo.send(horizontal)
+ self.vservo.send(vertical)
def focus_simple(self, distance, point):
@@ -175,15 +184,15 @@ def focus_angles(self, distance, point):
self.move(x, y)
-Left = Eye('left eye',
+Left = Eye('left eye', cfg.eye.left.active,
cfg.eye.left.hpin, cfg.eye.left.vpin,
cfg.eye.left.hmin, cfg.eye.left.hmax,
cfg.eye.left.vmin, cfg.eye.left.vmax,
cfg.arduino.port,
cfg.eye.left.offset, cfg.eye.left.height,
cfg.eye.left.horient, cfg.eye.left.vorient)
-Right = Eye('right eye',
+Right = Eye('right eye', cfg.eye.right.active,
cfg.eye.right.hpin, cfg.eye.right.vpin,
cfg.eye.right.hmin, cfg.eye.right.hmax,
cfg.eye.right.vmin, cfg.eye.right.vmax,
View
@@ -55,10 +55,21 @@ def move_eyes():
eye.Right.focus(distance, (closest[1], closest[0]))
+def save_depth(timestamp, depth):
+ #print 'depth timestamp:', timestamp, timestamp - last_time
+ np.save('images/%d_depth' % timestamp, depth)
+
+
+def save_video(timestamp, video):
+ #print 'video timestamp:', timestamp
+ np.save('images/%d_video' % timestamp, video)
+
+
def show_depth():
global threshold, current_depth, closest, distance
depth, timestamp = freenect.sync_get_depth()
+ #save_depth(timestamp, depth)
depthm = np.ma.masked_values(depth, 2047)
depthm = depth
amin = depthm.argmin()
@@ -78,7 +89,9 @@ def show_depth():
def show_video():
- video = frame_convert.video_cv(freenect.sync_get_video()[0])
+ video, timestamp = freenect.sync_get_video()
+ #save_video(timestamp, video)
+ video = frame_convert.video_cv(video)
cv.Circle(video, (closest[1], closest[0]), 8, (0, 0, 255))
cv.Circle(video, (closest[1], closest[0]), 4, (0, 0, 255))
cv.ShowImage('Video', video)

0 comments on commit c2c5c38

Please sign in to comment.