[ros-users] rospy Publisher/Subscriber node?
Michael Carroll
carroll.michael at gmail.com
Wed Oct 26 21:24:32 UTC 2011
A node can have any number of publishers or subscribers.
In the future, this would be best asked on answers.ros.org so that people
may easily find it in the future.
~mc
On Wednesday, October 26, 2011, Karan, Cem F USA CIV (US) <
cem.f.karan.civ at mail.mil> wrote:
> 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
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20111026/612ade0a/attachment-0004.html>
More information about the ros-users
mailing list