Commit 110e4112 authored by Rousseau Vincent's avatar Rousseau Vincent
Browse files

Update without timer since read is blocking

parent f43ac1a0
......@@ -21,7 +21,7 @@ import ue9
class Labjack(object):
def __init__(self, channel, resolution=16, scan_freq=150):
def __init__(self, channel, resolution=16, scan_freq=366):
self.channel_name = "AIN"+str(channel)
self.d = ue9.UE9()
self.d.getCalibrationData()
......@@ -39,21 +39,24 @@ class Labjack(object):
# Anonymous topic ?
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()
#timer_period = 0.01 # in second
#self.timer = rospy.Timer(rospy.Duration(timer_period), self.timer_callback)
#rospy.spin()
while rospy.is_shutdown() is False:
self.timer_callback()
self.d.streamStop()
self.d.close()
def timer_callback(self, event):
def timer_callback(self):
msg = Float32()
# Conversion in milli volt for gain 1
for data in self.d.streamData():
if data is not None:
msg.data = sum(data[self.channel_name])/len(data[self.channel_name])
rospy.loginfo('Publishing: "{0}"'.format(msg.data))
self.pub.publish(msg)
data = next(self.d.streamData())
if data is not None:
msg.data = sum(data[self.channel_name])/len(data[self.channel_name])
rospy.loginfo('Publishing: "{0}"'.format(msg.data))
self.pub.publish(msg)
if __name__ == '__main__':
......
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