Ros server client communication using rosbridge
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?
Just a note: in publish-subscribe there are no clients nor servers. There are only peers or participants.