Robotics StackExchange | Archived questions

Usage of rosbridge with python

I have a ROS installation on 1 pc. I want to subscribe to the ROS messages in my 2nd PC where there is no ROS installed. I just came across Rosbridge.

  1. Is this the ideal way for my use case ?
  2. There are many js examples online, is there also a simple python example wherein I can just receive some ros messages (just for the first test, maybe on the chatter topic). I just need to understand the workflow.

Asked by aks on 2018-09-28 05:14:29 UTC

Comments

Answers

I know the question is old, but anyway:

  1. Yes

  2. Take a look at roslibpy

Asked by knxa on 2019-10-07 03:35:51 UTC

Comments

re: roslibpy: this may actually be more/also interesting. Plain rospy Windows.

Asked by gvdhoorn on 2019-10-07 04:10:48 UTC

I am also trying to make python and rosbridge work together However, in the terminal, type this when I run: importerror: no module named roslibpy What could be the problem

Asked by bela on 2021-10-11 07:37:14 UTC

Try this for python.

 pip3 install roslibpy

roslibpy works for non-ros/windows env too.

import time
import roslibpy

client = roslibpy.Ros(host='localhost', port=9090)  #same as rosbridge port
client.run()

talker = roslibpy.Topic(client, '/chatter', 'std_msgs/String')

while client.is_connected:
    talker.publish(roslibpy.Message({'data': 'Hello World!'}))
    print('Sending message...')
    time.sleep(1)

talker.unadvertise()

client.terminate()

Asked by siddharthcb on 2021-10-11 06:33:37 UTC

Comments