How to publish topics with received json object using Rosbridge library?

asked 2017-10-23 02:28:50 -0500

Megacephalo gravatar image

Hi all,

Due to certain network configurations on the robot side, which I am not allowed to modify whatsoever, its ROS_MASTER_URI is set to http://localhost:11311 which subsequently cannot share topics across the network, I am trying to use Rosbridge to work around such limitation. Unfortunately Rosbridge_suite does not offer much documentation on how to do it.

Taking for instance to subscribe a laserScan topic from the robot side and publish it at my client side, what I've achieved so far are the following:

  1. Launch rosbridge_tcp by the robot side

  2. use Python socket to subscribe to robot's topic and decode the Json formatted string into Python object by my client side

  3. I can acquire elements within the received and de-serialized Python object

  4. I have the topic advertised using rosbridge library capabilities' protocol and advertise module

  5. I have the topic published using rosbridge library capabilities' publish module

But at this point, there is nothing publishing at my client side. What should be the proper way to publish any topic? Thank you in advance!

edit retag flag offensive close merge delete

Comments

Just making sure: you have seen the Basic ROS functionality with roslibjs tutorial that is linked from the Running Rosbridge tutorial?

gvdhoorn gravatar image gvdhoorn  ( 2017-10-23 04:09:47 -0500 )edit

@gvdhoorn Thank you for your reply. In fact, since I am developing on Python, I hadn't looked into the tutorial you pointed out. But if I can conclude from what this article teaches me about publishing topic, I would infer that we still need to fill in a great number of ...

Megacephalo gravatar image Megacephalo  ( 2017-10-23 04:16:29 -0500 )edit

attributes so as to publish the topic. I do not think this is what Rosbridge's authors intended for the user to implement, but by going through the test codes, I am reluctantly forced to belive that this is exactly the route we should take to publish any arbitrary topic.

Megacephalo gravatar image Megacephalo  ( 2017-10-23 04:17:46 -0500 )edit

rosbridge_suite provides the bridge that allows any external program to communicate with it over a JSON/TCP socket. It is not a drop-in replacement of a regular ROS client library (such as roscpp or rospy). Clients will have to implement some things themselves. An example for C# is ..

gvdhoorn gravatar image gvdhoorn  ( 2017-10-23 04:23:42 -0500 )edit

.. follesoe/rosbridge_client_dot_net. That makes things relatively simple, but it's still not a full ROS client lib.

gvdhoorn gravatar image gvdhoorn  ( 2017-10-23 04:24:07 -0500 )edit

Seeing as you're working in Python, you could try and see whether using rosbridge_library simplifies some of the work of interacting with a rosbridge_server.

But as rosbridge is quite limited, it will probably never reach parity with rospy or roscpp.

gvdhoorn gravatar image gvdhoorn  ( 2017-10-23 04:26:10 -0500 )edit

@Megacephalo , can you attach the HTML code used to subscribe/publish on a ROS Topic using ROS Bridge?

Ruben Alves gravatar image Ruben Alves  ( 2017-10-23 05:31:47 -0500 )edit

@Ruben Alves: @Megacephalo is using Python as his client library. Where would the html be used?

gvdhoorn gravatar image gvdhoorn  ( 2017-10-23 05:34:58 -0500 )edit