I would like to know if it is possible to run multiple scripts on pi at the same time with a script capable of interrupting another script. If possible an example would be great.
What I would like to do is use one script to measure distance from a sensor continuously and another script running a collision avoidance algorithm. The first script measuring the distance will be able to send a stop command for the vehicle if the distance falls below a certain threshold say 50cm. The second script should then run a code for turning left and moving forward 100cm for example. But if there is an object detected in front of the vehicle, the first script should come into play and immediately stop the vehicle (whether or not the 100cm movement is completed) and then restart the second script.
Thanks in advance.