0
$\begingroup$

Rosanswers logo

I'm using a Neural Network NN to control a UR5 robot arm. I'm struggling to understand how to exchange information between my ROS network and my neural network. Suppose I'm using ur_modern_driver to read joint_states from the robot, how do I export that data so my NN can use it as an input? Likewise, how do I get a ros node to subscribe to data from the output of my NN which will be the 6d joint commands that need to be plugged into ur_modern_driver/urscript?

I suspect I will need to write my own pubsub node which will interface between ur_modern_driver and my NN but I just can't tell what I should tell the node to pub or sub to. How can a node read/write from/to an external source such as a python script that's being executed, especially when that source is constantly changing? Do I need to edit my script to write the NN output to a specific location, maybe a com port? Can a ros node then listen to that port for incoming data? and vice-versa, for writing to the NN's input?

FYI, I'm not experienced with writing my own ROS nodes or even programming so please be simple. Many thanks.


Originally posted by porkPy on ROS Answers with karma: 5 on 2019-02-24

Post score: 0


Original comments

Comment by Hamid Didari on 2019-02-25:
why are you use your NN from out of ros you can write python in ros?

Comment by porkPy on 2019-02-25:
My NN is part of Garage/rllab from Berkeley and has its own deps. if I were to try and recreate it inside ros I know it will not work because I don't fully understand how all the different parts of Garage/rllab communicate. Therefore, it seemed more sensible to have ros read and write to Garge/rllab

Comment by porkPy on 2019-02-25:
rllab used to have ros utils but these have been removed in the newer 'Garage' version. Also, I could never get the original rllab to compile.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The most common way to exchange information with a running ROS node is by exchanging messages published to topics. You can find descriptions of the relevant concepts in the start guide and in particular, examples of how to subscribe and publish to topics using Python in the tutorials.

In your particular use-case, you should probably subscribe to the /joint_states topic to receive information about the current state of the robot and then reformat it and send it to the NN in whichever format it expects.

In order to command your robot with the output of your NN you'll need to do a bit more work. The default configuration of the ur_modern_driver uses a configuration expecting complete joint trajectories to be sent to it, and then the driver will take care of commanding the robot to follow that trajectory. Not sure what your NN is producing and how fast. You can definitely abuse the joint trajectory controller by sending single point trajectory messages. Alternatively, you can configure a new controller that accepts 6d joint position commands in a similar way as the joint_group_vel_controller is defined.


Originally posted by Miguel Prada with karma: 1071 on 2019-03-28

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.