Skip to content

Commit

Permalink
add demo service
Browse files Browse the repository at this point in the history
  • Loading branch information
nzjrs committed Jan 24, 2013
1 parent 5afe619 commit a7a91c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<author>John Stowers</author>

<depend package="std_msgs"/>
<depend package="std_srvs"/>
<depend package="geometry_msgs"/>

<depend package="rospy"/>
Expand Down
8 changes: 8 additions & 0 deletions tests/testnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import rospy
import std_msgs.msg
import std_srvs.srv

import random
import string
Expand All @@ -19,9 +20,16 @@ def __init__(self):
self._pubs.append( p )
self._pubst[p] = t

self._fs = rospy.Publisher("~foo",std_msgs.msg.Float32)
s = rospy.Service('~set_foo', std_srvs.srv.Empty, self._change_foo)

self._timer = rospy.Timer(rospy.Duration(0.2),
self._new_msg)

def _change_foo(self, req):
self._fs.publish(random.random())
return std_srvs.srv.EmptyResponse()

def _new_msg(self, evt):
p = random.choice( self._pubs )
msg = self._pubst[p]()
Expand Down

0 comments on commit a7a91c5

Please sign in to comment.