I am creating a project that involves autonomous navigation through the use of ultrasonic sensors and motor encoders. I am doing the project in python. I have created a function that controls the speed of dc motors using the motor encoders that works well. I would like have this function running constantly on its own thread so i can do the navigation on a different thread and just change the speed of the motors as needed.
The problem i have is when the motor speed thread is running it screws up readings from the ultrasonic sensors. I believe this is because this is because the motor speed thread interrupts the ultrasonic senors while they are waiting for an echo.
Does anyone have any advice? Maybe there is a way to block all other threads while the ultrasonic sensors are reading?