Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Best practices for ethernet based tool

#1
There is a sensor/scanner at the end of the robot.  The goal is to move to a target, have the sensor take a measurement, move to another target, and so on.

To control the sensor, a Python script will make a socket connection to the IP address and port number of the sensor.  This all works when there is one Python script that makes the connection, sends commands, and the closes the connection at the end.

My question is how to handle this in the context of robot instructions inside RoboDK.  From a RDK point of view I have the structure shown below:

   

There is an initialize script that creates the socket connection and sets parameters in the sensor.  Then a script that tells the sensor to take a measurement - called after each robot movement.

Here is the question - as soon as the initialize script ends the socket connection is destroyed.  So every time the robot moves and needs to take a measurement a script has to establish a new connection.  Of course, that is also destroyed after that script ends.  How can I accomplish a procedure like this (move - measure - move) and keep the socket connection alive?

Thanks for your help.
#2
To maintain the connection with your device you could trigger one script which will always be running in the background and will check for certain parameters to be activated/deactivated to consume certain flags. Another option is to have inter-process communication between different scripts with a shared memory buffer to communicate between them.

I attached 2 scripts that show this shared memory buffer integration as an example. This is part of an add-in we'll release to add sound effects to station and VR stations.

On the other hand, I don't see a problem connecting to the device and disconnecting every time. For some devices this is a very fast operation.


Attached Files
.zip   sound_emitter.zip (Size: 2.57 KB / Downloads: 12)
#3
Thank you Albert.

I have never used ShareableLists before but it seems like a good solution. I'll try this approach.

The next step is to understand how Add-ins work. I wish there were more YouTube videos talking about the Python API.

Thank you for the examples - these are invaluable.
#4
Thank you for your feedback.

We recently added this quick step by step guide to create an basic app/add-in from scratch:
https://robodk.com/doc/en/Add-ins.html#CreateApp

We'll try to keep improving the information we provide to create addins.
  




Users browsing this thread:
1 Guest(s)