本文整理汇总了Python中myo.six.print_函数的典型用法代码示例。如果您正苦于以下问题:Python print_函数的具体用法?Python print_怎么用?Python print_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_connect
def on_connect(self, myo, timestamp):
print_("Connected to Myo")
myo.vibrate('short')
myo.set_stream_emg(stream_emg.enabled)
myo.request_rssi()
global start
start = time.time()
示例2: on_pose
def on_pose(self, myo, timestamp, pose):
self.nowpose=pose
print_('on_pose', pose)
if pose == "fist":
self.fistcount=self.fistcount+1
if self.fistcount==1:
self.state=0
print("Entering state 0")
示例3: on_pose
def on_pose(self, myo, timestamp, pose):
print_('on_pose', pose)
self.data["on_pose"] = { "timestamp" : timestamp, "data" : pose }
msgs = []
if pose == pose_t.double_tap:
msgs += [ HMTLprotocol.get_rgb_msg(self.options.hmtladdress,
1,
255,0,255) ]
elif pose == pose_t.rest:
msgs += [
HMTLprotocol.get_rgb_msg(self.options.hmtladdress,
1,
0,0,0),
HMTLprotocol.get_value_msg(69,
0,
0),
HMTLprotocol.get_value_msg(69,
1,
0)
]
elif pose == pose_t.wave_in:
msgs += [ HMTLprotocol.get_rgb_msg(self.options.hmtladdress,
1,
0,255,0) ]
elif pose == pose_t.wave_out:
msgs += [ HMTLprotocol.get_rgb_msg(self.options.hmtladdress,
1,
0,0,255) ]
elif pose == pose_t.fist:
msgs += [
HMTLprotocol.get_rgb_msg(self.options.hmtladdress,
1,
255,0,0),
HMTLprotocol.get_value_msg(69,
1,
255)
]
elif pose == pose_t.fingers_spread:
msgs += [
HMTLprotocol.get_rgb_msg(self.options.hmtladdress,
1,
255,255,255),
HMTLprotocol.get_value_msg(69,
0,
128)
]
if (len(msgs) != 0):
for msg in msgs:
self.client.send_and_ack(msg, False)
print("Sent and acked to client")
示例4: main
def main():
hub = myo.Hub()
hub.run(1000, Listener())
# Listen to keyboard interrupts and stop the
# hub in that case.
try:
while hub.running:
myo.time.sleep(0.2)
except KeyboardInterrupt:
print_("Quitting ...")
hub.stop(True)
示例5: on_pose
def on_pose(self, myo, timestamp, pose):
self.nowpose=pose
print_('on_pose', pose)
## if pose == pose_t.double_tap:
## print_("Enabling EMG")
## myo.set_stream_emg(stream_emg.enabled)
## elif pose == pose_t.fingers_spread:
## myo.set_stream_emg(stream_emg.disabled)
if pose == "fist":
self.fistcount=self.fistcount+1
if self.fistcount==1:
self.state=0
print("Entering state 0")
示例6: on_pair
def on_pair(self, myo, timestamp):
print_("Paired")
print_(
"If you don't see any responses to your movements, try re-running the program or making sure the Myo works with Myo Connect (from Thalmic Labs)."
)
print_("Double tap enables EMG.")
print_("Spreading fingers disables EMG.\n")
示例7: main
def main():
#address = "192.168.1.110"
address = "localhost"
port = 0
hub = myo.Hub()
hub.run(10000000, Listener(address, port))
# Listen to keyboard interrupts and stop the
# hub in that case.
try:
while hub.running:
myo.time.sleep(0.2)
except KeyboardInterrupt:
print_("Quitting ...")
hub.stop(True)
示例8: main
def main():
options = handle_args()
print("%s\nOpening client. Address=%d\n%s" % ("*"*80, options.hmtladdress, "*"*80))
client = HMTLClient(options)
hub = myo.Hub()
hub.set_locking_policy(myo.locking_policy.none)
hub.run(1000, Listener(client, options))
# Listen to keyboard interrupts and stop the
# hub in that case.
try:
while hub.running:
myo.time.sleep(0.2)
except KeyboardInterrupt:
print_("Quitting ...")
hub.stop(True)
示例9: opponentChoice
def opponentChoice(userChoice,myo):
choice=random.randint(1,3)
if choice==1:
print_("Opponent chose Scissors!")
if choice==userChoice:
write_message("Tie!", GAME.me, GAME.opponent)
print_c_scissors(display_width-250, 150)
print_scissors(75, 150)
elif 2==userChoice:
GAME.opponent+=1
write_message("You Lose!", GAME.me, GAME.opponent)
print_c_scissors(display_width-250, 150)
print_paper(75, 150)
myo.vibrate('long')
else:
GAME.me+=1
write_message("You Win!", GAME.me, GAME.opponent)
print_c_scissors(display_width-250, 150)
print_rock(75, 150)
elif choice==2:
print_("Opponent chose Paper!")
if choice==userChoice:
write_message("Tie!", GAME.me, GAME.opponent)
print_c_paper(display_width-250, 150)
print_paper(75, 150)
elif 1==userChoice:
GAME.me+=1
write_message("You Win!", GAME.me, GAME.opponent)
print_c_paper(display_width-250, 150)
print_scissors(75, 150)
else:
GAME.opponent+=1
write_message("You Lose!", GAME.me, GAME.opponent)
print_c_paper(display_width-250, 150)
print_rock(75, 150)
myo.vibrate('long')
else:
print_("Opoonent chose Rock!")
if choice==userChoice:
write_message("Tie!", GAME.me, GAME.opponent)
print_c_rock(display_width-250, 150)
print_rock(75, 150)
elif 2==userChoice:
GAME.me+=1
write_message("You Win!", GAME.me, GAME.opponent)
print_c_rock(display_width-250, 150)
print_paper(75, 150)
else:
GAME.opponent+=1
write_message("You Lose!", GAME.me, GAME.opponent)
print_c_rock(display_width-250, 150)
print_scissors(75, 150)
myo.vibrate('long')
示例10: on_pose
def on_pose(self, myo, timestamp, pose):
print_('on_pose', pose)
if pose == pose_t.double_tap:
print_("=" * 80)
print_("Reset Orientation")
or1x[0] = orx[0]
or1y[0] = ory[0]
or1z[0] = orz[0]
or1w[0] = orw[0]
#myo.set_stream_emg(stream_emg.enabled)
elif pose == pose_t.fingers_spread:
egg = 0
示例11: on_pose
def on_pose(self, myo, timestamp, pose):
if pose == pose_t.wave_in:
#print_('on_pose', pose)
print_("You chose Scissors!")
opponentChoice(1,myo)
myo.set_stream_emg(stream_emg.disabled)
elif pose == pose_t.fingers_spread:
#print_('on_pose', pose)
print_("You chose Paper!")
opponentChoice(2,myo)
myo.set_stream_emg(stream_emg.disabled)
elif pose == pose_t.fist:
#print_('on_pose', pose)
print_("You chose Rock!")
opponentChoice(3,myo)
myo.set_stream_emg(stream_emg.disabled)
示例12: on_pair
def on_pair(self, myo, timestamp):
print_('on_pair')
示例13: on_rssi
def on_rssi(self, myo, timestamp, rssi):
print_("RSSI:", rssi)
示例14: on_orientation_data
def on_orientation_data(self, myo, timestamp, orientation):
self.odr=orientation
if self.state==-1:
calib_start=input('Press 1 for calibration: ')
self.state=0
print("Beginning Calibration!!!")
if self.counter2<50:
output=convert_to_rpy(self.odr)
roll1=output[0]
pitch1=output[1]
yaw1=output[2]
#print_(roll1,pitch1,yaw1)
self.rcfull[self.counter2] = math.cos(math.radians(roll1))
self.rsfull[self.counter2] = math.sin(math.radians(roll1))
self.pcfull[self.counter2] = math.cos(math.radians(pitch1))
self.psfull[self.counter2] = math.sin(math.radians(pitch1))
self.ycfull[self.counter2] = math.cos(math.radians(yaw1))
self.ysfull[self.counter2] = math.sin(math.radians(yaw1))
self.counter2=self.counter2+1
if self.counter2 == 50:
rc = numpy.mean(self.rcfull)
pc = numpy.mean(self.pcfull)
yc = numpy.mean(self.ycfull)
rs = numpy.mean(self.rsfull)
ps = numpy.mean(self.psfull)
ys = numpy.mean(self.ysfull)
if self.state==0: # calibration
self.rollb = math.degrees(math.atan2(rs,rc))
self.pitchb = math.degrees(math.atan2(ps,pc))
self.yawb = math.degrees(math.atan2(ys,yc))
baseline=[self.rollb,self.pitchb,self.yawb]
print(baseline)
print("Calibration Complete! You have 2 seconds to change your gesture and then record a new one for 2")
self.counter2=0
self.state=1
self.start_time = time.time()
elif self.state == 1:
#for i in range(1,1000):
# for j in range(1,10000):
# a=i
time.sleep(2)
self.counter2 = 0
self.state = 2
elif self.state == 2: # data collection, identification and transfer
self.roll = math.degrees(math.atan2(rs,rc))-self.rollb
self.pitch = math.degrees(math.atan2(ps,pc))-self.pitchb
self.yaw = math.degrees(math.atan2(ys,yc))-self.yawb
a=numpy.matrix([self.roll,self.pitch,self.yaw])
b=a.transpose()
d=numpy.matlib.repmat(b,1,4) #hardcoded------CHANGE LATER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
pose_number=assign_pose_number(self.nowpose)
self.W=numpy.matrix([[-2.38946624937314,172.907592400722,-12.1921835866013,30.7345074055692],[-1.60615657009811, 70.7802307763561,-10.0331866141660,-71.1455632604777],[5.87052357307342,52.4896992580217,-45.3268722289868,-67.7618396439250]])
diff=self.W-d
squared=numpy.square(diff)
summed=sum(squared)
#rooted=numpy.sqrt(summed)
#rooted=rooted.tolist()
rooted=summed.tolist()
print("rooted", rooted)
P = min(rooted[0])
#print ("P ", P)
Q = rooted[0].index(P)
#print ("Q", Q)
R = Q + 1
#print("R" , R)
#indx=rooted.index(min(rooted))+1#1-front; 2-up; 3-side; 4-down
indx=R
print ("indx",indx)
print ("pose num ", pose_number)
if indx==1:#front
if pose_number==1:
gesture_number=1
gesture_name='FRONT_finger_spread'
print_(gesture_name)
self._sock.sendto("Gesture: 1\n", ("<broadcast>", 10000))
#.........这里部分代码省略.........
示例15: on_lock
def on_lock(self, myo, timestamp):
print_('locked')