Access to data received by rosbridge TCP server

asked 2020-05-26 12:30:29 -0500

jgauthier gravatar image

Greetings,

I launched a rosbridge TCP server, and I can send data to it. But where is that data? Ie: How can I retrieve that data so I can manipulate it, process it, and do things with it? I've traced the code in rosbridge_server, which starts a threaded socket listener. The handler for that is in tcp_hander.py, which gobbles up the message and passes it to self.protocol.incoming() which is in protcol.py. Finally, it's passed to some operation: self.operationsop

Which seems that it can be registered?

 def register_operation(self, opcode, handler):
       self.operations[opcode] = handler

Not sure this is even the right path. Thanks!

Thanks!

edit retag flag offensive close merge delete

Comments

1

This question is a bit strange: rosbridge is used to allow remote javascript/whatever programs to communicate with a ROS node graph/application. There is a limited set of operations you can send rosbridge, some of which are publishing a message, subscribing to topics, invoking a service and retrieving the value of a parameter (there are more, these are just examples).

You don't send rosbridge arbitrary data, so the question "where is that data?" is at least unexpected.

If you've sent rosbridge an op to publish a message (for instance), the "data" would be the JSON dict which describes the message to publish, the topic, etc. The corresponding ROS message would then be created by rosbridge upon reception of your JSON dict, and it would publish the ROS message to the ROS application.

What happens to the message after it has been published depends on whether there are ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2020-05-27 04:48:31 -0500 )edit

I see. Okay, thanks. I guess the question more is: What is the proper way to send data arbitrary data from a non-ROS platform to ROS to be published? In this case, I am looking to send IMU data and publish it as an imu message.

I took the rosbridge TCP server, and overwrote the handler. I grabbed the data and published it. This wasn't bad, but don't necessarily believe it's the "correct" way.

jgauthier gravatar image jgauthier  ( 2020-05-27 08:09:29 -0500 )edit

What is the proper way to send data arbitrary data from a non-ROS platform to ROS to be published?

rosbridge would be one such way. It's pretty often used for the kind of thing you describe.

I took the rosbridge TCP server, and overwrote the handler. I grabbed the data and published it. This wasn't bad, but don't necessarily believe it's the "correct" way.

well it isn't necessary. As that is exactly what rosbridge already does for you, provided you use the correct JSON message (ie: the correct op and other fields).

It would help if you could better describe what you are trying to do -- in particular, on which platform, with which programming language and over which connections.

Right now, your post is a good example of an xy-problem, and we should try to avoid answering those.

Please add more information to your original ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2020-05-27 08:17:23 -0500 )edit

Understood. My goal is take take the IMU data from a quadrotor and get it into the an IMU topic in ROS. My platform is MATLAB/Simulink. Due to the nature of my specific platform (hardware deployment to the quadrotor) I cannot use ROS toolbox. Additionally, as far as networking goes, I only have access to "stream clients" and "stream servers" (Blasts values over the network, more or less).

I will have to do some digging to see if I can format and send JSON through the platform, but I feel like it may be a limitation.

jgauthier gravatar image jgauthier  ( 2020-05-27 08:26:34 -0500 )edit
1

If you're limited to raw bytes over a socket, then writing a small (Python) script which reads from that socket and converts it into ROS messages may be the most efficient/straightforward.

You could of course hack rosbridge, but that seems rather unclean to me.

gvdhoorn gravatar image gvdhoorn  ( 2020-05-27 09:38:15 -0500 )edit

Great. Thanks for the advice!

jgauthier gravatar image jgauthier  ( 2020-05-27 09:49:25 -0500 )edit