[ros-users] rospy Publisher/Subscriber node?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: User discussions
Date:  
To: ros-users@code.ros.org
Subject: [ros-users] rospy Publisher/Subscriber node?
Is it possible to make one node both a publisher and a subscriber? That is, would the following code fragment work?


rospy.init_node('relay')
pub = rospy.Publisher('talker', someMsg)
oldMessages = set()

def callback(data):
    if not data in oldMessages:
        pub.publish(data)    
    oldMessages.add(data)    


sub = rospy.Subscriber('listener', someMsg, callback)

if __name__ == '__main__':
    rospy.spin()


Thanks,
Cem Karan