本文整理汇总了Python中proxy.Proxy.send方法的典型用法代码示例。如果您正苦于以下问题:Python Proxy.send方法的具体用法?Python Proxy.send怎么用?Python Proxy.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类proxy.Proxy
的用法示例。
在下文中一共展示了Proxy.send方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Robosapien
# 需要导入模块: from proxy import Proxy [as 别名]
# 或者: from proxy.Proxy import send [as 别名]
class Robosapien(Thread):
'''
'''
def __init__(self):
# Create the communications thread.
self.proxy = Proxy(IPConnection("10.42.0.1", 50001))
self.x = 0.0
self.y = 0.0
self.heading = 1.57
self.offset = 0.0 # Offset to record when the odometry has been forced.
Thread.__init__(self)
'''
Processes a command received down the communications channel, if
it is valid an action is taken.
'''
def process_command(self, command):
state = ""
if command[0] == 'w':
self.invoke_lirc(WALK_FORWARD)
state = "Going Forward\n"
elif command[0] == 's':
self.invoke_lirc(WALK_BACKWARD)
state = "Going Backward\n"
elif command[0] == 'a':
self.invoke_lirc(TURN_LEFT)
state = "Turning Left\n"
elif command[0] == 'd':
self.invoke_lirc(TURN_RIGHT)
state = "Turning Right\n"
elif command[0] == 'q':
self.invoke_lirc(STOP)
state = "Halted\n"
elif command[0] == 'r':
self.face(command)
elif command[0] == 'e':
self.scan()
elif command[0] == 't':
self.travel(command)
elif command[0] == 'p':
self.ping()
elif command[0] == 'c':
self.change_odometry(command)
if state != "":
self.proxy.send(state) # Inform host of state change.
'''
'''
@staticmethod
def invoke_lirc(command):
os.popen('/usr/bin/' + IR_SEND + " " + SEND_ONCE + " " + REMOTE_NAME + " " + command, 'w')
'''
Updates just the robot's heading, called from a separate thread.
'''
def update_heading(self, heading):
self.heading = heading
'''
Updates the robot's odometry (x, y).
'''
def update_odometry(self, steps):
# Do this based on the number of steps we have taken, and
# the robots current heading.
self.x += (steps / DISTANCE_PER_STEP) * math.cos(self.heading)
self.y += (steps / DISTANCE_PER_STEP) * math.sin(self.heading)
'''
Sends the robot's current odometry to the host.
'''
def send_odometry(self):
self.proxy.send("o,%.2f" % self.x + ",%.2f" % self.y + ",%.2f" % self.heading + "\n")
'''
Changes the robot's odometry by force.
'''
def change_odometry(self, x, y, heading):
self.x = x
self.y = x
self.offset = self.heading - heading
self.heading = heading
'''
Rotates the robot to face a particular heading.
'''
def face(self, command):
#.........这里部分代码省略.........