0
$\begingroup$

Rosanswers logo

Hello,

Maybe this question is more about algorithms than ROS, but I think it's interesting to ask for ROS external compatibility.

I'm currently trying to connect ROS with a third-party neural network simulator. This Neural Network simulator is organized similarly the ROS in the fact that is runs several scripts (equivalents to nodes) that are interacting through f_send and f_recv functions. Theses functions define links (eq. to topics) between scripts and use sockets on the technical point of view.

The current solution for interconnecting both software is to have a hybrid program included in the NN simulator that uses the ROS subscribers and publishers. This would allow data to come from ROS to the simulator with a ROS publisher and a f_recv box whereas the opposite direction would be done with a ROS subscriber and a f_send box. That's for the cute theory. This solution avoids big changes in the NN simulator structure and allows the ROS node to use the communication functions f_send and f_recv, to be quite independent from the technical point of view.

The problem comes because both f_send/recv functions are done in C and are not a class that I could inherit to had an attribute to store the publisher/subscriber pointer. There is a kind of class instantiation mechanism but all information is deduced from the input group number. So the only place I can insert ROS pub/subs is in the send/recv function, which is called at each iteration of the NN simulation. This means initialising the publisher and the subscriber at each call, and want to know if it a reasonable method or a bad patch ? Is there a clever feature or tool in ROS that would help ?


Originally posted by Erwan R. on ROS Answers with karma: 697 on 2012-07-11

Post score: 1

$\endgroup$

3 Answers 3

0
$\begingroup$

Rosanswers logo

It is bad, because the publisher/subscribers will need some time to "find" there connection. If you create new ones all the time, and immediately publish, you'll probably get zero messages through.

If that is you only insertion point, you could create them static or call some init() function once, that sets up the publishers.

On a side note: you might want to set that up as Nodelets as it seems to be that you'll be passing a lot of stuff around.


Originally posted by dornhege with karma: 31395 on 2012-07-11

This answer was NOT ACCEPTED on the original site

Post score: 2

$\endgroup$
0
$\begingroup$

Rosanswers logo

Even in C you could declare static variables allowing the publish or subscribe to happen only on the first call.


Originally posted by joq with karma: 25443 on 2012-07-11

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

Thanks both of you for answering.

I had a discussion with one of the NN simulator developers and he told me that there is a mechanism to transmit data between their functions without modifying the whole structure of the simulator. That's what I'm gonna use. But another question about message type will probably come ;) ...


Originally posted by Erwan R. with karma: 697 on 2012-07-16

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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