本文整理汇总了Python中proxy.Proxy.start方法的典型用法代码示例。如果您正苦于以下问题:Python Proxy.start方法的具体用法?Python Proxy.start怎么用?Python Proxy.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类proxy.Proxy
的用法示例。
在下文中一共展示了Proxy.start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Robosapien
# 需要导入模块: from proxy import Proxy [as 别名]
# 或者: from proxy.Proxy import start [as 别名]
#.........这里部分代码省略.........
def ping(self):
return
'''
Drives the robot forward a certain distance.
'''
def travel(self, command):
print(command)
if len(command) >= 3:
command = command.strip("t\n")
distance = float(command)
if distance > 0:
message_time = time.time()
interrupted = False
if distance < DISTANCE_PER_STEP:
number_of_steps = 1
else:
number_of_steps = distance / DISTANCE_PER_STEP
steps_taken = 0
self.invoke_lirc(FORWARD_STEP)
step_time = time.time()
# Will just have to wait for some predefined time
# or check the accelerometer. Drift will happen!
while True:
# Check for any commands that could cancel this.
with self.proxy.command_mutex:
if len(self.proxy.command_queue) > 0:
interrupted = True
break
# Either wait for a predefined time to elapse
# or probe the accelerometer for movement.
if time.time() - step_time >= TIME_PER_STEP:
steps_taken += 1
if steps_taken < number_of_steps:
self.invoke_lirc(FORWARD_STEP)
step_time = time.time()
else:
break
if time.time() - message_time >= MESSAGE_RATE:
self.update_odometry(steps_taken)
self.send_odometry()
message_time = time.time()
# Compute new odometry based on the number steps that were taken.
self.update_odometry(steps_taken)
self.invoke_lirc(STOP)
self.proxy.send("travelled: %.2f" % (steps_taken / DISTANCE_PER_STEP) + "\n")
if interrupted:
print("interrupted during travel!")
with self.proxy.command_mutex:
self.process_command(self.proxy.command_queue.pop())
'''
'''
def run(self):
self.proxy.start()
message_time = time.time()
while True:
try:
command = ""
# Check the command poll.
with self.proxy.command_mutex:
if len(self.proxy.command_queue) > 0:
command = self.proxy.command_queue.pop()
# If it exists then process it.
if COMMANDS.count(command[0]) < 1:
self.process_command(command)
if time.time() - message_time >= MESSAGE_RATE:
self.send_odometry()
message_time = time.time()
except Exception as err:
print(str(err))
break
self.proxy.socket.close()
print("Cleaning up GPIO!")
io.cleanup()
print("Exiting Now!")
示例2: run
# 需要导入模块: from proxy import Proxy [as 别名]
# 或者: from proxy.Proxy import start [as 别名]
def run(self):
p = Proxy(logger)
p.start()