subscribing to a topic at every iteration of a loop
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 ?