Exemplo n.º 1
0
    def checkin(self):
        if self.appdisabled:
            return False

        try:
            self.twtaccess = Twitter(
                auth=OAuth(tininfo.TiNTwOAToken, tininfo.TiNTwOASecret,
                           tininfo.TiNTwConKey, tininfo.TiNTwConSecret))
        except:
            print 'Unable to check into PyRIDE PR2 twitter app. Try again in 10mins.'
            return False

        self.startupTime = time.localtime()
        self.updatestatus(
            time.strftime("I'm back online at %H:%M to serve ",
                          time.localtime()) + tininfo.TiNLocation + ".")

        self.token = self.lastoken
        self.getmessages()
        tinstate.updateStatus(constants.NEW_MESSAGES, len(self.messages) == 0)
        tid = PyPR2.addTimer(60, -1, 60)
        self.timercontext[tid] = 'getmsg'
        timermanager.addTimer(tid, self)
        #add purge archive time
        purgetime = timermanager.calcTimePeriodFromNow("4:00")
        if purgetime > 0:
            tid = PyPR2.addTimer(purgetime, -1, 24 * 60 * 3600)
            self.timercontext[tid] = 'purgemsg'
            timermanager.addTimer(tid, self)

        return True
Exemplo n.º 2
0
def onHumanTracking(tracking_objs):
	#global busymoving
	#SHOOTING_TAG = 0
	#global start_time,last_action_counter,movement_tracker,msgTryTimer,d,x,y,track_x,track_y,track_d,elapsed_time,focus_obj,HUMAN_DETECTION_COUNTER
	global a2,b2,NEW_INTERACTION_INITIALISER, NumPeople, HumanPresence, x, y, msgTryTimer
	NumPeople = len(tracking_objs)
	a2 +=1 
	if len(tracking_objs)==0:
		NEW_INTERACTION_INITIALISER += 1
		if HumanPresence == True:
			PyPR2.removeTimer(msgTryTimer)
		
		if NEW_INTERACTION_INITIALISER > 500:
				restoreInitialState()

 		HumanPresence = False

	elif len(tracking_objs) > 0:
			if HumanPresence== False:
			
				PyPR2.onTimer = timerActions
				msgTryTimer = PyPR2.addTimer(1,-1,0.5)
				b2+=1
			#st_time = time.time()
			#no_objTracker.append(elapsed_time)
				HumanPresence = True

			object_index = closest_obj_index(tracking_objs)
			focus_obj = tracking_objs[object_index]
			x = focus_obj['est_pos'][0]
			y = focus_obj['est_pos'][1]


			mid_x = focus_obj['bound'][0] + focus_obj['bound'][2] / 2
      			
			mid_y = focus_obj['bound'][1] + focus_obj['bound'][3] / 2
     			
			ofs_x = mid_x - 320
    			ofs_y = mid_y - 240
      			chx = chy = 0.0
			
    			if math.fabs(ofs_x) > 10:
       				chx = -ofs_x * 90.0 / 640 * 0.01745329252	
				#head_yaw_list.append(chx)
				
   			if math.fabs(ofs_y) > 10:
        			chy = ofs_y * 90.0 / 640 * 0.01745329252

			PyPR2.updateHeadPos( chx, chy )
def onHumanTracking(tracking_objs):
    #global busymoving
    #SHOOTING_TAG = 0
    #global start_time,last_action_counter,movement_tracker,msgTryTimer,d,x,y,track_x,track_y,track_d,elapsed_time,focus_obj,HUMAN_DETECTION_COUNTER
    global a2, b2, NEW_INTERACTION_INITIALISER, NumPeople, HumanPresence, x, y, msgTryTimer
    NumPeople = len(tracking_objs)
    a2 += 1
    if len(tracking_objs) == 0:
        NEW_INTERACTION_INITIALISER += 1
        if HumanPresence == True:
            PyPR2.removeTimer(msgTryTimer)

        if NEW_INTERACTION_INITIALISER > 500:
            restoreInitialState()

        HumanPresence = False

    elif len(tracking_objs) > 0:
        if HumanPresence == False:

            PyPR2.onTimer = timerActions
            msgTryTimer = PyPR2.addTimer(1, -1, 0.5)
            b2 += 1
            #st_time = time.time()
            #no_objTracker.append(elapsed_time)
            HumanPresence = True

        object_index = closest_obj_index(tracking_objs)
        focus_obj = tracking_objs[object_index]
        x = focus_obj['est_pos'][0]
        y = focus_obj['est_pos'][1]

        mid_x = focus_obj['bound'][0] + focus_obj['bound'][2] / 2

        mid_y = focus_obj['bound'][1] + focus_obj['bound'][3] / 2

        ofs_x = mid_x - 320
        ofs_y = mid_y - 240
        chx = chy = 0.0

        if math.fabs(ofs_x) > 10:
            chx = -ofs_x * 90.0 / 640 * 0.01745329252
        #head_yaw_list.append(chx)

        if math.fabs(ofs_y) > 10:
            chy = ofs_y * 90.0 / 640 * 0.01745329252

        PyPR2.updateHeadPos(chx, chy)
def onHumanTracking(tracking_objs):

	global HUMAN_COUNTER,track_data,msgTryTimer,x,y,d,st_time
	if len(tracking_objs) !=0:
		if HUMAN_COUNTER ==0:
			
			PyPR2.onTimer = timerActions
			msgTryTimer = PyPR2.addTimer(1,-1,2)

			elapsed_time = time.time() - st_time
			no_objTracker.append((elapsed_time,time.time()))
			HUMAN_COUNTER= len(tracking_objs)


		object_index = closest_obj_index(tracking_objs)
		focus_obj = tracking_objs[object_index]

		x = focus_obj['est_pos'][0]
		y = focus_obj['est_pos'][1]
		d = math.sqrt((math.pow(x,2))+(math.pow(y,2)))
		
#		track_y.append(y)
	
		mid_x = focus_obj['bound'][0] + focus_obj['bound'][2] / 2
      			
		mid_y = focus_obj['bound'][1] + focus_obj['bound'][3] / 2
     				#print "track obj {} mid pt ({}.{})".format(focus_obj['track_id'],mid_x,mid_y)
      		ofs_x = mid_x - 320
      		ofs_y = mid_y - 240
      		chx = chy = 0.0
			
      		if math.fabs(ofs_x) > 10:
      			chx = -ofs_x * 90.0 / 640 * 0.01745329252	
				#head_yaw_list.append(chx)
				
      		if math.fabs(ofs_y) > 10:
 			chy = ofs_y * 90.0 / 640 * 0.01745329252
		PyPR2.updateHeadPos( chx, chy )

	else:
		
		if HUMAN_COUNTER !=0:
			PyPR2.removeTimer(msgTryTimer)
			#msgTryTimer = -1
			st_time = time.time()
			HUMAN_COUNTER =0
def onHumanTracking(tracking_objs):

    global HUMAN_COUNTER, track_data, msgTryTimer, x, y, d, st_time
    if len(tracking_objs) != 0:
        if HUMAN_COUNTER == 0:

            PyPR2.onTimer = timerActions
            msgTryTimer = PyPR2.addTimer(1, -1, 2)

            elapsed_time = time.time() - st_time
            no_objTracker.append((elapsed_time, time.time()))
            HUMAN_COUNTER = len(tracking_objs)

        object_index = closest_obj_index(tracking_objs)
        focus_obj = tracking_objs[object_index]

        x = focus_obj['est_pos'][0]
        y = focus_obj['est_pos'][1]
        d = math.sqrt((math.pow(x, 2)) + (math.pow(y, 2)))

        #		track_y.append(y)

        mid_x = focus_obj['bound'][0] + focus_obj['bound'][2] / 2

        mid_y = focus_obj['bound'][1] + focus_obj['bound'][3] / 2
        #print "track obj {} mid pt ({}.{})".format(focus_obj['track_id'],mid_x,mid_y)
        ofs_x = mid_x - 320
        ofs_y = mid_y - 240
        chx = chy = 0.0

        if math.fabs(ofs_x) > 10:
            chx = -ofs_x * 90.0 / 640 * 0.01745329252
        #head_yaw_list.append(chx)

        if math.fabs(ofs_y) > 10:
            chy = ofs_y * 90.0 / 640 * 0.01745329252
        PyPR2.updateHeadPos(chx, chy)

    else:

        if HUMAN_COUNTER != 0:
            PyPR2.removeTimer(msgTryTimer)
            #msgTryTimer = -1
            st_time = time.time()
            HUMAN_COUNTER = 0
Exemplo n.º 6
0
def main():
    global myMessenger, msgTryTimer
    global extProcCall, iksResolver

    extProcCall = extprocall.ProcConduit()
    iksResolver = iksresolver.IKSResolver()

    PyPR2.onUserLogOn = userLogon
    PyPR2.onUserLogOff = userLogoff
    PyPR2.onTimer = timerActions
    PyPR2.onTimerLapsed = timerLapsedActions
    PyPR2.onRemoteCommand = remoteCommandActions
    PyPR2.onSystemShutdown = systemShutdownActions
    PyPR2.onPowerPluggedChange = powerPlugChangeActions
    PyPR2.onBatteryChargeChange = batteryChargeChangeActions
    PyPR2.onNodeStatusUpdate = nodeStatusUpdate

    myMessenger = messenger.Messenger()
    if not myMessenger.checkin():
        msgTryTimer = PyPR2.addTimer(10 * 60, -1, 10 * 60)

    PyPR2.say(constants.INTRO_TEXT)
    PyPR2.setLowPowerThreshold(20)
Exemplo n.º 7
0
def onHumanTracking(tracking_objs):
	global start_time,last_action_counter,movement_tracker,msgTryTimer,d,x,y,track_x,track_y,track_d,elapsed_time,focus_obj,HUMAN_DETECTION_COUNTER
	
	if len(tracking_objs)==0:
		PyPR2.removeTimer(msgTryTimer)
		HUMAN_DETECTION_COUNTER=0

	
	elapsed_time = time.time() - start_time
	object_index = closest_obj_index(tracking_objs)
	focus_obj = tracking_objs[object_index]
	x = focus_obj['est_pos'][0]
	y = focus_obj['est_pos'][1]
	track_x.append(x)
	track_y.append(y)
	#track_d.append((elapsed_time,x,y))
	mid_x = focus_obj['bound'][0] + focus_obj['bound'][2] / 2
      			
	mid_y = focus_obj['bound'][1] + focus_obj['bound'][3] / 2
     			#print "track obj {} mid pt ({}.{})".format(focus_obj['track_id'],mid_x,mid_y)
      	ofs_x = mid_x - 320
      	ofs_y = mid_y - 240
      	chx = chy = 0.0
			
      	if math.fabs(ofs_x) > 10:
       		chx = -ofs_x * 90.0 / 640 * 0.01745329252	
				#head_yaw_list.append(chx)
				
      	if math.fabs(ofs_y) > 10:
        	chy = ofs_y * 90.0 / 640 * 0.01745329252
	PyPR2.updateHeadPos( chx, chy )
	PyPR2.onTimer =  timerActions
	if msgTryTimer==-1:
	   #PyPR2.tuckBothArms()
	   msgTryTimer = PyPR2.addTimer( 1, -1, 2  ) 	#changed just for testing the isStationeryCase()
	
      	'''	
Exemplo n.º 8
0
def onHumanTracking(tracking_objs):
    global start_time, last_action_counter, movement_tracker, msgTryTimer, d, x, y, track_x, track_y, track_d, elapsed_time, focus_obj, HUMAN_DETECTION_COUNTER

    if len(tracking_objs) == 0:
        PyPR2.removeTimer(msgTryTimer)
        HUMAN_DETECTION_COUNTER = 0

    elapsed_time = time.time() - start_time
    object_index = closest_obj_index(tracking_objs)
    focus_obj = tracking_objs[object_index]
    x = focus_obj['est_pos'][0]
    y = focus_obj['est_pos'][1]
    track_x.append(x)
    track_y.append(y)
    #track_d.append((elapsed_time,x,y))
    mid_x = focus_obj['bound'][0] + focus_obj['bound'][2] / 2

    mid_y = focus_obj['bound'][1] + focus_obj['bound'][3] / 2
    #print "track obj {} mid pt ({}.{})".format(focus_obj['track_id'],mid_x,mid_y)
    ofs_x = mid_x - 320
    ofs_y = mid_y - 240
    chx = chy = 0.0

    if math.fabs(ofs_x) > 10:
        chx = -ofs_x * 90.0 / 640 * 0.01745329252
    #head_yaw_list.append(chx)

    if math.fabs(ofs_y) > 10:
        chy = ofs_y * 90.0 / 640 * 0.01745329252
    PyPR2.updateHeadPos(chx, chy)
    PyPR2.onTimer = timerActions
    if msgTryTimer == -1:
        #PyPR2.tuckBothArms()
        msgTryTimer = PyPR2.addTimer(
            1, -1, 2)  #changed just for testing the isStationeryCase()
    '''	
Exemplo n.º 9
0
def onHumanTracking(tracking_objs):
 	global HUMAN_COUNTER, st_time,msgTryTimer,x,y,Numpeople,avg_y,avg_x,actionIdentifier,isNearest
 
	#focus_obj = tracking_objs[object_inde x]
	Numpeople = len(tracking_objs)
	avgPos(tracking_objs)
	
 	if len(tracking_objs) == 0:
 		#PyPR2.cancelMoveBodyAction()
		if HUMAN_COUNTER !=0:
			PyPR2.removeTimer(msgTryTimer)
			PyPR2.moveArmWithJointPos(**initial_left)
			PyPR2.moveArmWithJointPos(**initial_right)
			#msgTryTimer = -1
			#elapsed_time = time.time()-st_time

			HUMAN_COUNTER =0
			
		
			

 	elif len(tracking_objs) > 0:
		if HUMAN_COUNTER ==0:
			
			PyPR2.onTimer = timerActions
			msgTryTimer = PyPR2.addTimer(1,-1,0.5)
			#a +=1
			#st_time = time.time()
			#no_objTracker.append(elapsed_time)
			HUMAN_COUNTER= Numpeople
			
		object_index = closest_obj_index(tracking_objs)
		focus_obj = tracking_objs[object_index]


		x = focus_obj['est_pos'][0]
		y = focus_obj['est_pos'][1]
		d = math.sqrt((math.pow(x,2))+(math.pow(y,2)))

		if d<0.1:
			PyPR2.cancelMoveBodyAction()
			PyPR2.cancelMoveArmAction(True)
			PyPR2.cancelMoveArmAction(False)
			#c+=1
#		track_y.append(y)
	
		mid_x = focus_obj['bound'][0] + focus_obj['bound'][2] / 2
      			
		mid_y = focus_obj['bound'][1] + focus_obj['bound'][3] / 2
     				#print "track obj {} mid pt ({}.{})".format(focus_obj['track_id'],mid_x,mid_y)
      		ofs_x = mid_x - 320
      		ofs_y = mid_y - 240
      		chx = chy = 0.0
			
      		if math.fabs(ofs_x) > 10:
      			chx = -ofs_x * 90.0 / 640 * 0.01745329252	
				#head_yaw_list.append(chx)
				
      		if math.fabs(ofs_y) > 10:
 				chy = ofs_y * 90.0 / 640 * 0.01745329252
		PyPR2.updateHeadPos( chx, chy )
		

		if Numpeople ==1:

			if x>3.5:
				if isNearest == False:
					if y>0:
						PyPR2.moveArmWithJointPos(**initial_left)
						actionIdentifier= "initial_left"
					else:

						PyPR2.moveArmWithJointPos(**initial_right)
						actionIdentifier= "initial_right"
			elif 2.5<x<3.5:
				PyPR2.moveTorsoBy(0.1,2)
				if y>0:
					PyPR2.moveArmWithJointPos(**second_left)
					actionIdentifier = "second_left"
				else:
					PyPR2.moveArmWithJointPos(**second_right)
					actionIdentifier = "second_right"
			
			elif 1.5<x<2.5:
				PyPR2.moveTorsoBy(0.1,2)
				isNearest = True
				if y>0:
					PyPR2.moveArmWithJointPos(**third_left)
					actionIdentifier = "third_left"
				else:
					PyPR2.moveArmWithJointPos(**third_right)
					actionIdentifier = "third_right"
			else:
				isNearest = True

				PyPR2.moveArmWithJointPos(**full_stretch_left)
				PyPR2.moveArmWithJointPos(**full_stretch_right)
				actionIdentifier = "full_stretch"

		if 1<Numpeople<3:

			if x>3.5:
				if isNearest ==False:

					PyPR2.moveArmWithJointPos(**initial_left)
					PyPR2.moveArmWithJointPos(**initial_right)
					actionIdentifier = "Both_initial"

			elif 2.5<x<3.5:
				PyPR2.moveArmWithJointPos(**second_left)
				PyPR2.moveArmWithJointPos(**second_right)
				PyPR2.moveTorsoBy(0.1,2)
				actionIdentifier = "Multiple_Second"

			elif 1.5<x<2.5:
				isNearest = True
				PyPR2.moveArmWithJointPos(**third_right)
				PyPR2.moveArmWithJointPos(**third_left)
				PyPR2.moveTorsoBy(0.1,2)
				actionIdentifier = "Multiple_third"
			else:
				isNearest = True
				PyPR2.moveArmWithJointPos(**full_stretch_left)
				PyPR2.moveArmWithJointPos(**full_stretch_right)
				actionIdentifier = "Full_Multiple"
		elif Numpeople > 3:
			isNearest = True
			PyPR2.moveArmWithJointPos(**full_stretch_left)
			PyPR2.moveArmWithJointPos(**full_stretch_right)
			actionIdentifier = "TooManyPeopleBehaviour"