我正在控制一个机器人,我希望能够在控制台中显示它的遥测,同时接受来自人类控制器的文本输入。
我以为我可以通过使用多个线程来做到这一点?但也许有更好的方法来做到这一点。 (仍然是编程新手)
import threading
def main(self):
#run initalize function
## program should quit if arduino isn't connected
self.initalize()
inputThread = threading.Thread(target = self.rps) #rps:Read,Print,Save
DAQThread = threading.Thread(target = self.controller_input)
while True:
#### SET UP MULTIPLE THREADS HERE ####
try:
inputThread.start()
#Read, print and save the data
DAQThread.start()
#controller_input() #ask for user to input control code
except:
print "error starting Multithreading..."
print "program will terminate..."
raise SystemExit
每当我运行它时,我都会收到自己的错误消息:
error starting Multithreading...
program will terminate...
我觉得我设置错误的线程。有什么建议吗?