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


Python Packet.write_double方法代码示例

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


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

示例1: controlLoop

# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import write_double [as 别名]
def controlLoop(ip):
    global LIN_V, ANG_V
    word = None
    while('end' != word and 'exit' != word):
        if len(cmd_buffer)> 0 : 
            word = cmd_buffer.pop(0)
            print word
            lv = 0
            av = 0
            if('forward' == word or 'charge' == word):
                lv = LIN_V * 1
            elif('backward' == word or 'reverse' == word):
                lv = LIN_V * -1
            elif('right' == word):
                av = ANG_V * -1
            elif('left' == word):
                av = ANG_V * 1
            elif('faster' == word):
                LIN_V += 0.2
                ANG_V += 0.2
                print LIN_V, ANG_V
            elif('slower' == word):
                LIN_V = LIN_V - 0.2    
                ANG_V = ANG_V - 0.2
                print LIN_V, ANG_V
            elif('stop' == word):
                lv = 0
                av = 0
            elif('sing' == word):
                pkt = Packet()
                pkt.write_ubyte(CMD.SOUND)
                val = randint(0, 6)
                pkt.write_ubyte(val)
                sock.sendto(str(pkt), ip)
                
            else:
                pass
            
            pkt = Packet()
            pkt.write_ubyte(CMD.MOTION)
            pkt.write_double(lv)
            pkt.write_double(av)
            sock.sendto(str(pkt), ip)
            
    print('leaving control loop')
开发者ID:fultonms,项目名称:stark,代码行数:47,代码来源:voiceNode.py

示例2: print

# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import write_double [as 别名]
        print(sys.argv)
        addr = (sys.argv[1],int(float(sys.argv[2])))
        print(addr)
else:
        print('useage is leapNode address port')
        print('using default')
try:
	keepAlive()
	while True:
		lv = 0
		av =0
		frame = controller.frame()
		hand = frame.hands[0]
		if hand.palm_position.z < -30:
			lv = -1
		elif hand.palm_position.z > 30:
			lv = 1
		elif hand.palm_position.x < -30:
			av = -1
		elif hand.palm_position.x > 30:
			av = 1
		LIN_V,ANG_V = speed(hand.palm_position.y)
		pkt = Packet()
		pkt.write_ubyte(CMD.MOTION)
		pkt.write_double(-LIN_V * lv)
		pkt.write_double(-ANG_V * av)
		sock.sendto(str(pkt), addr)
		time.sleep(1)
except KeyboardInterrupt:
	print("ending")
开发者ID:fultonms,项目名称:stark,代码行数:32,代码来源:leapNode.py


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