Commit 32049198 authored by Rousseau Vincent's avatar Rousseau Vincent
Browse files

Use non blocking function with timer

parent 110e4112
......@@ -36,7 +36,6 @@ class Labjack(object):
self.d.streamStart()
# Anonymous topic ?
self.pub = rospy.Publisher('chatter', Float32, queue_size=10)
#timer_period = 0.01 # in second
......@@ -59,7 +58,30 @@ class Labjack(object):
self.pub.publish(msg)
class LabjackAIN(object):
def __init__(self, channel, resolution=16):
self.channel_name = "AIN"+str(channel)
self.d = ue9.UE9()
self.d.getCalibrationData()
self.pub = rospy.Publisher('chatter', Float32, queue_size=10)
timer_period = 0.01 # in second
self.timer = rospy.Timer(rospy.Duration(timer_period), self.timer_callback)
rospy.spin()
self.d.close()
def timer_callback(self, event):
msg = Float32()
# Conversion in milli volt for gain 1
data = self.d.getAIN(1)
if data is not None:
msg.data = data
rospy.loginfo('Publishing: "{0}"'.format(msg.data))
self.pub.publish(msg)
if __name__ == '__main__':
rospy.init_node('labjack', anonymous=True)
node = Labjack(1)
\ No newline at end of file
node = LabjackAIN(1)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment