Interfacing with GPIO pins makes robot stutter


Hi. I have added two ultrasonic sensors to the raspberry with GPIO pins 23,24 and 17,27.
When I make the robot drive, in whatever way, it stutters extremely when I start the python script that reads (and writes) to the ultrasonic sensors via the GPIO pins. When I stop this script this stuttering doesn’t stop until I restart the python script that makes the motor drive.

I want to use this robot with ROS, I’ve tried this script with and without ROS integration and gives the same issue. (I’ve asked the same question on the ROS forums:

Whats going on?