My robot works by means of a telnet connection; from the robot's software, to my scripts (an API session). I send commands to the socket that control the robot's software, or I watch the socket for any sent messages (from the robot's sensors). For the most part, this works alright; if you know what message you want to wait
for (a move completion notice, for example). However, for monitoring sensory data, it does not work so well. Basically, the Python object library contains a module for controlling a telnet session (telnetlib), and all of the functions for reading data from the socket work the same. It basically waits, until a defined message is received
. Otherwise, it does nothing
else (works good for movement, since the movement cannot be interupted). What I am trying to do is monitor the telnet socket for sensory data, while my script runs. Here's a simple pseudocode example of what I'm trying to do (This code makes the robot rotate, unless sensory data is detected by and sent from the robot's software; which makes it stop moving and the program ends):
IF (sensory data detected) THEN:
sendCommand('speak "I have detected something"')
In order to implement this, it seems like I have to use multiprocessing/threading techniques (one script endlessly monitors the socket, and the other script uses this data at the same time). However, this shouldn't be necessary; other robot scripts I've seen monitor sensory data and make decisions accordingly, without multiprocessing/threading.
Any help will be appreciated, since this problem is above my programming abilities at the moment (I've never encountered a problem like this).