简体   繁体   English

Python RC 汽车超声波传感器阻止快速远程命令

[英]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.

相关问题 带有无源蜂鸣器的Arduino超声波距离传感器可实现不同的音调 - Arduino Ultrasonic Distance Sensor with Passive Buzzer to achieve different tones Arduino在超声波和温度/湿度传感器上给我带来非常奇怪的错误 - Arduino giving me very strange errors on ultrasonic and temperature/humidity sensor 如何让超声波传感器与Arduino Uno一起正常工作? - How to get Ultrasonic Sensor to work properly with Arduino Uno? 带有超声波传感器的 Blynk 通知 - Blynk notification with ultrasonic sensor Raspberry Pi上的两个超声波传感器,带有Python脚本 - Two Ultrasonic sensors on Raspberry Pi with Python script Raspberry Pi 超声波传感器输出在多次 while 循环迭代后停顿 - Raspberry Pi Ultrasonic Sensor Output Stalls After Several While Loop Iterations 尝试使用 Arduino Nano 让 OLED 显示来自超声波范围传感器的输入 - Trying to get OLED to display input from ultrasonic range sensor using Arduino Nano 如何从铜 web 应用程序(coap 协议)上的超声波传感器获取输入值 - how to get input value from ultrasonic sensor on copper web application (coap protocol) Arduino超声波传感器pulseIn仅为3或4 - Arduino Ultrasonic Sensor pulseIn is only 3 or 4 如何检测超声波测距传感器是否超出范围? - How to detect ultrasonic range sensor is out of range or not?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM