Home > other >  How to relay user actions from the server to an external device
How to relay user actions from the server to an external device

Time:09-29

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

CodePudding user response:

Search ROS mult machine will help with this case.

http://wiki.ros.org/ROS/Tutorials/MultipleMachines

In short, you set other devices IP in the local devices /etc/hosts In this file, you can assign correct IP to each other

Do it for all devices.

Then at one machine runs roscore

In this roscore, you will have a rosip see the message coming out from roscore usually you core IP address 11311

Then at second machine, set ROS_MASTER_URI to the ros IP port that you find.

THen two machines can share topics and services.

Ps. if you encounter port 22 issues when trying to ssh when following the tutorial. reinstall open-ssh-server and open-ssh-client

  • Related