diff --git a/scripts/stream_node.py b/scripts/stream_node.py index 1332a7b0c45790ef2bdb09d2fa76ef1c2ecd2c52..b299ec6f48ff538d086086bb8a30ca21a2f53b50 100755 --- a/scripts/stream_node.py +++ b/scripts/stream_node.py @@ -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