Ask Your Question
0

How does a ROS node import/export data?

asked 2019-02-24 17:28:10 -0500

porkPy gravatar image

updated 2019-02-25 02:21:25 -0500

gvdhoorn gravatar image

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.

edit retag flag offensive close merge delete

Comments

why are you use your NN from out of ros you can write python in ros?

hamid gravatar imagehamid ( 2019-02-25 02:41:00 -0500 )edit

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

porkPy gravatar imageporkPy ( 2019-02-25 03:49:47 -0500 )edit

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.

porkPy gravatar imageporkPy ( 2019-02-25 03:52:43 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-03-28 09:12:15 -0500

Miguel Prada gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-02-24 17:28:10 -0500

Seen: 267 times

Last updated: Mar 28