I have a web interface that allows the user to send remote commands to 1 or 2 robots. Currently the tasks are saved in the database (for logging as well) and the robot(s) keeps polling the django backend using GET requests every 125ms which gives acceptable response time without overly stressing the backend. In short:
Action(User) -> [Remote Control UI] -> Django -> DB (based on user input)
To get the actions the robot then does a GET request to Django as something like:
while(ros::ok())
{
response = requests.get(task_url, timeout=5)
// input task(s) to state machine
// execute task if possible
rate.sleep();
}
My question is: is there a better way? The remote control is sometimes disabled as the robot goes out of Wi-Fi so the solution needs some degree of flexibility to re-connection, IP changes and connection errors. I though about possible alternatives but not sure they are feasible:
- Require robots to register and save their IP (?) and send the command to the robot if registered
- Multicast the command to the entire Wi-Fi subnet (?) and let the robot read it
- Use django channels or some similar technology? I only found examples with [django or flask] + javascript. I am not sure its possible to do from, for example, Django to Flask or something like that.
Any feedback is appreciated