[英]Python RC Car Ultrasonic sensor blocking fast remote commands
I've made a RC car and recently I just got a kit that has all the stuff I need to add collision warnings, the problem is, is that it blocks codes and it will go forward with a lot of lag from the controller.我已经制造了一辆遥控车,最近我刚刚得到了一个套件,其中包含我需要添加碰撞警告的所有东西,问题是它会阻止代码,并且它将 go 向前推进,与 controller 相比有很多滞后。 I tried adding a thread to it but it still blocks the code.
我尝试向它添加一个线程,但它仍然阻塞了代码。
I couldn't format my code correctly for the site so heres a github link https://github.com/OoDone/RcCarPython/tree/master我无法为该站点正确格式化我的代码,所以这里有一个 github 链接https://github.com/OoDone/RcCarPython/tree/master
Not knowing how many CPU cores are used on your Arduino, I could imagine that one and the same core executes both Python threads, so that the busy loops in the function pulseIn
slow the main loop.不知道您的 Arduino 上使用了多少 CPU 内核,我可以想象一个相同的内核执行两个 Python 线程,因此
pulseIn
中的繁忙循环脉冲慢主循环。 You could try inserting eg a sleep(0.001)
in the您可以
sleep(0.001)
在
while(GPIO.input(pin) != level):
and和
while(GPIO.input(pin) == level):
loops.循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.