Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
irstea-ros
labjack_driver
Commits
32049198
Commit
32049198
authored
Jul 30, 2018
by
Rousseau Vincent
Browse files
Use non blocking function with timer
parent
110e4112
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/stream_node.py
View file @
32049198
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment