forked from federicocorrao/Nao-Computer-Vision-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod_redball_detection_callback.py
More file actions
45 lines (33 loc) · 972 Bytes
/
mod_redball_detection_callback.py
File metadata and controls
45 lines (33 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from naoqi import ALProxy
from naoqi import ALBroker, ALModule
IP = '127.0.0.1'
Port = 9559
# Callback
# Global variable to store the (RBModule) module instance
RB = None
memory = None
class RBModule(ALModule):
def __init__(self, name):
ALModule.__init__(self, name)
global memory
memory = ALProxy("ALMemory")
memory.subscribeToEvent("redBallDetected",
"RB",
"onRedBallDetected")
#
def onRedBallDetected(self, *_args):
print "callback"
#
#
rb = ALProxy("ALRedBallDetection", IP, Port)
rb.subscribe("prv")
# We need this broker to be able to construct
# NAOqi modules and subscribe to other modules
# The broker must stay alive until the program exists
myBroker = ALBroker("myBroker",
"0.0.0.0", # listen to anyone
0, # find a free port and use it
IP, # parent broker IP
Port) # parent broker port
RB = RBModule("RB")
print 'done'