本文整理汇总了Python中Robot.Robot.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Robot.stop方法的具体用法?Python Robot.stop怎么用?Python Robot.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Robot.Robot
的用法示例。
在下文中一共展示了Robot.stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Gui
# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import stop [as 别名]
class Gui():
def __init__(self, port="sim"):
"""
A gui used to control the robot.
Contributor: Matthew O'Brien, Xiangqing Zhang, Tianyu Liu
"""
self.speed = None
self.rotation = None
self.time = None
self.distance = None
self.robot = Robot(port)
self.robot.connect()
self.root = tkinter.Tk()
self.root.title("Robot GUI")
self.frame = None
FO = open("mainwindow.xml", "r")
xml_string = FO.read()
FO.close()
self.add_widget(XML(xml_string), self.root).grid()
self.config_widget("btn_connect", {"command": lambda: self.robot.connect()})
self.config_widget("btn_stop", {"command": lambda: self.robot.stop()})
self.config_widget("wilma_bio", {"command": lambda: self.robot.log_information()})
self.speed = tkinter.IntVar()
self.config_widget("speed_entry", {"textvariable": self.speed})
self.rotation = tkinter.IntVar()
self.config_widget("rotation_entry", {"textvariable": self.rotation})
self.time = tkinter.IntVar()
self.config_widget("time_entry", {"textvariable": self.time})
self.config_widget("btn_move_autonomously", {"command": lambda: self.robot.move_autonomously(self.speed.get(), self.rotation.get(), self.time.get())})
self.coordinates = tkinter.StringVar()
self.config_widget("grid_entry", {"textvariable": self.coordinates})
self.config_widget("grid_button", {"command": lambda: self.robot.grid_movement(self.coordinates.get(), self.speed.get(), self.rotation.get())})
self.message = tkinter.StringVar()
self.config_widget("de_en_code_message_entry", {"textvariable": self.message})
self.config_widget("btn_de_en_code_message", {"command": lambda: self.robot.de_en_code_message(self.message)})
self.darkness = tkinter.IntVar()
self.config_widget("darkness_entry", {"textvariable": self.darkness})
self.config_widget("btn_go_forward_until_black_line", {"command": lambda: self.robot.go_forward_until_black_line(self.speed.get(), self.darkness.get())})
self.bumper = tkinter.StringVar()
self.config_widget("bumper_entry", {"textvariable": self.bumper})
self.config_widget("btn_go_forward_until_bumps", {"command": lambda: self.robot.go_forward_until_bumps(self.speed.get(), self.bumper.get())})
self.bytecode = tkinter.StringVar()
self.config_widget("bytecode_entry", {"textvariable": self.bytecode})
self.config_widget("btn_bytecode_entry", {"command": lambda: self.robot.chat_with_another_robot(self.bytecode.get())})
self.config_widget("btn_go_forward_until_ir_signal", {"command": lambda: self.robot.go_forward_until_ir_signal(self.speed.get(), self.bytecode.get())})
self.config_widget("btn_go_forward_until_stuck", {"command": lambda: self.robot.go_forward_until_stuck(self.speed.get())})
self.config_widget("btn_forward", {"command": lambda: self.robot.teleport("Forward")})
self.config_widget("btn_backward", {"command": lambda: self.robot.teleport("Backward")})
self.config_widget("btn_left", {"command": lambda: self.robot.teleport("Left")})
self.config_widget("btn_right", {"command": lambda: self.robot.teleport("Right")})
self.config_widget("btn_follow", {"command": lambda: self.robot.follow_black_line(self.speed.get(), self.darkness.get())})
self.chat_message = tkinter.StringVar()
self.config_widget("chat_with_robot_entry", {"textvariable": self.chat_message})
self.frame.children["chat_with_robot_entry"].bind("<Key-Return>", lambda event: self.robot.chat_with_robot(self.chat_message))
self.config_widget("btn_chat_with_robot_entry", {"command": lambda: self.robot.chat_with_robot(self.chat_message)})
self.config_widget("btn_follow_other_robot", {"command": lambda: self.robot.follow_other_robot(self.speed.get(), self.bytecode.get())})
self.config_widget("btn_take_other_robot", {"command": lambda: self.robot.take_other_robot(self.speed.get(), self.bytecode.get())})
self.config_widget("btn_map_GUI", {"command": lambda: self.map_gui_to_robot()})
self.config_widget("btn_sing_and_dance", {"command": lambda: self.robot.sing_and_dance()})
self.log_frame = ttk.Frame(self.root)
self.log_frame.grid()
self.log_text = tkinter.Text(self.log_frame, width=150, height=20, wrap=tkinter.CHAR) # state=tkinter.DISABLED)
# self.log_text.insert(tkinter.INSERT, "DEBUG")
self.log_text.grid()
robotLogger.logger_list["GuiLogger"].gui = self
info_time = Timer(2, lambda: self.robot.team_info())
info_time.start()
self.root.mainloop()
def map_gui_to_robot(self):
"""
This function calls the main function from the file 'map_GUI' to obtain the list of points
that the user clicked and then calls the 'grid_movement' function to exectute the task.
Feature 7-b
Contributor: Matthew O'Brien
"""
points = map_GUI.main()
#.........这里部分代码省略.........
示例2: mode
# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import stop [as 别名]
prediction_count += 1
if prediction_count >= buffer_size:
prediction = mode(buffer)[0]
prediction_count = 0
else:
prediction = 3
else:
prediction = 3
if prediction == 0:
print("robot turning left")
robot.turn_left()
elif prediction == 1:
print("robot moving forward")
robot.move_forward()
elif prediction == 2:
print("robot turning right")
robot.turn_right()
elif prediction == 3:
print("robot stopping")
robot.beep()
robot.stop()
if robot.read_sensor(0):
break
bufhelp.sendevent('stimulus.feedback', 'end')
leds.blink = False
print("feedback END")
bufhelp.sendevent('startPhase.cmd', 'exit')