ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How can I use rospylib to transmit data from raspberry pi to ROS running on laptop.

asked 2022-08-09 19:26:29 -0500

akumar3.1428 gravatar image

updated 2022-08-10 08:36:54 -0500

Greetings, I hope you are doing well. I am using rospylib for transmitting data into a ros topic , however, it is working when the ROSbridge and publisher created using rospylib are working on the same machine. However, I want to use rospylib to publish data from a raspberry pi to ROS bridge running on laptop. The code looks like this

import time

import roslibpy

client = roslibpy.Ros(host='localhost', port=9090)   #### should I change the local address with the IP address of the laptop? 

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()
edit retag flag offensive close merge delete

Comments

Please edit your question by selecting your python code and clicking on the "preformatted text" button on the editor. This button has 101010 text written over it.

ravijoshi gravatar image ravijoshi  ( 2022-08-09 22:17:46 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-08-09 22:21:34 -0500

ravijoshi gravatar image

Quoting from the documentation of the roslibpy below

These examples assume ROS is running on the same computer where you run the examples. If that is not the case, change the host argument from 'localhost' to the IP Address of your ROS instance.

Therefore, please use the appropriate value of host .

edit flag offensive delete link more

Comments

Let me be more descriptive, suppose I updated the code as you suggested with the IP Address of my ROS instance and port number, now when I will try to establish a connection with ROS Bridge (that will be constantly listening to some desired port or default port 9090) how I can authenticate it such that my publisher publish the data in the remote computer. I feel like there would be some authentication way to get into my computer, the most basic could be to ssh into the computer and then move forward to use rospylib and ros bridge. Thank you

akumar3.1428 gravatar image akumar3.1428  ( 2022-08-09 22:32:05 -0500 )edit

There is no such "authentication". The ROS publisher is a broadcaster in a way. The message published by a publisher can be received by any subscriber who uses the correct topic name.

ravijoshi gravatar image ravijoshi  ( 2022-08-09 22:51:31 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-08-09 19:26:29 -0500

Seen: 45 times

Last updated: Aug 10 '22