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

Ros server client communication using rosbridge

asked 2018-10-20 11:11:33 -0500

Anuja_Rane gravatar image

updated 2018-10-20 11:16:19 -0500

Hello, I am trying to do communication between client and server using rosbridge

server: I am sending normal string here.

 from __future__ import print_function

 import roslibpy

 from std_msgs.msg import String

 ros1 = roslibpy.Ros(host='localhost', port=9090)

 ros1.connect()

 prime = 'Hello'

 msg = roslibpy.Message(values = {"prime_no":prime})

 topic1 = roslibpy.Topic(ros1, 'prime1', String, queue_size=1)

 topic1.publish(msg)

 topic1.advertise()

 topic1.is_advertised

 ros1.run_forever()

For client:

 from __future__ import print_function

 import roslibpy

 import json

 from std_msgs.msg import String

 def callback(data):

        print (data.data)

 ros = roslibpy.Ros(host='localhost', port=9090)

 ros.connect()

 topic1 = roslibpy.Topic(ros, 'prime1', String, queue_size=1)

 topic1.subscribe(callback)

 ros.run_forever()

I am getting error as- "No handlers could be found for logger "roslibpy"" for both client and server. On rosbridge as - [ERROR] [1540049844.335207]: [Client 0] [id: publish:prime1:2] publish: Cannot infer topic type for topic prime1 as it is not yet advertised.

How to resolve this?

edit retag flag offensive close merge delete

Comments

Just a note: in publish-subscribe there are no clients nor servers. There are only peers or participants.

gvdhoorn gravatar image gvdhoorn  ( 2018-10-21 05:54:05 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-10-20 22:06:06 -0500

KinWah gravatar image

Hi.

I am a newbie in ROS too. Currently, i am doing a project where laptop as master, raspberry and arduino on mobile robot as sleeves.

For your information, i do not use rosbridge for them to communicate in a localhost environment, what I did is as this tutorial. I believe it is easier than rosbridge. That's why I provide this suggestion.

It enables you to publish and subscribe topic among machines that setup in localhost env. So far, it i working fine for me. Below shows the steps required to set this up. Hopefully, it is useful for you.

Step

1) After connected to localhost,at master, export ROS_MASTER_URI with master's ifconfig address along with 11311 port.

2) roscore

3) may start some nodes at master (Optional)

4) SSH to slave, export ROS_MASTER_URI with master's ifconfig address along with 11311 port (After the slave connected to the localhost).

5) export ROS_HOSTNAME Slave's IP addr

6) export ROS_IP Slave's IP addr Slave's IP addr will be used for both ROS_HOSTNAME and ROS_IP

7) SSH to slave and you may start some nodes at slave by using rosrun or roslaunch

Usage:

All nodes connected to the Master may access all the data. By using ssh from workspace (Ex. ssh 192.168.1.17), we may control other machines such as initialize nodes.

I apologize if my explanation is very complicated. feel free to seek for help ;)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-10-20 11:11:33 -0500

Seen: 1,469 times

Last updated: Oct 20 '18