当前位置: 首页>>代码示例>>Python>>正文


Python PyPR2.cancelMoveBodyAction方法代码示例

本文整理汇总了Python中PyPR2.cancelMoveBodyAction方法的典型用法代码示例。如果您正苦于以下问题:Python PyPR2.cancelMoveBodyAction方法的具体用法?Python PyPR2.cancelMoveBodyAction怎么用?Python PyPR2.cancelMoveBodyAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyPR2的用法示例。


在下文中一共展示了PyPR2.cancelMoveBodyAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: onHumanTracking

# 需要导入模块: import PyPR2 [as 别名]
# 或者: from PyPR2 import cancelMoveBodyAction [as 别名]
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:
#.........这里部分代码省略.........
开发者ID:Sidiitd,项目名称:shooting_experiment,代码行数:103,代码来源:door_block.py


注:本文中的PyPR2.cancelMoveBodyAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。