Example #1
0
class StoppableThread(threading.Thread):

    def __init__(self, description):
        super(StoppableThread, self).__init__()
        self.running = False
        self.faceRecogn = FaceRecognitionHandler()
        self.motion = ALProxy("ALMotion", "nao.local", 9559)
        self.postureProxy = ALProxy("ALRobotPosture", "nao.local", 9559)

    def run(self):
        num = 0
        self.faceRecogn.start()
        while self.running:
            #print "here"
            if num % 2 == 0:
                sensRotireCap = 1
                num = 1
            else:
                sensRotireCap = -1
                num = 0
            #while self.faceRecogn.speaking:
            #    pass
            self.motion.moveTo(0.1, 0, 0,
                [ ["MaxStepX", 0.02],         # step of 2 cm in front
                  ["MaxStepY", 0.04],         # default value
                  ["MaxStepTheta", 0.4],      # default value
                  ["MaxStepFrequency", 0.0],  # low frequency
                  ["StepHeight", 0.01],       # step height of 1 cm
                  ["TorsoWx", 0.0],           # default value
                  ["TorsoWy", 0.1] ])         # torso bend 0.1 rad in front
            #while self.faceRecogn.speaking:
            #    pass
            self.motion.angleInterpolation(
                ["HeadYaw", ],
                [math.radians(90*sensRotireCap)],
                [15],
                True)
            time.sleep(3)
            print "Search again"
            self.faceRecogn.isRunning = self.faceRecogn.isRunning & self.running
        self.postureProxy.goToPosture("Crouch", 0.5)

    def reset(self):
        self.running = False

    def set(self):
        self.running = True
Example #2
0
 def __init__(self, description):
     super(StoppableThread, self).__init__()
     self.running = False
     self.faceRecogn = FaceRecognitionHandler()
     self.motion = ALProxy("ALMotion", "nao.local", 9559)
     self.postureProxy = ALProxy("ALRobotPosture", "nao.local", 9559)