Skip to content

Example 1: Creating an SA Reader explicitly in Python

jmessias edited this page Jun 29, 2015 · 1 revision
#import the necessary message types
from monarch_situational_awareness.msg import ReaderProperties

#1) declare a service proxy
rospy.wait_for_service('create_reader')
cr = rospy.ServiceProxy('create_reader', CreateReader)

#2) Instantiate your ReaderProperties
rp = ReaderProperties(slot_name="Slot A")

#3) Call the service
r = CreateReaderResponse()
rate = rospy.Rate(1) # 1hz

while r.success is False:
    r = cr(rp)
    rate.sleep()

#4) Subscribe to the topic contained in the response
sa = rospy.Subscriber(r.topic_name, std_msgs.msg.String, callback)