Main Page
Namespaces
Classes
Files
File List
File Members
scripts
sr_tactile_sensors
virtual_ShadowPST_publisher.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# This node combines 5 virtual touch sensors into a ShadowPST message compatible with etherCAT hand
3
4
import
rospy
5
from
std_msgs.msg
import
Float64
6
from
sr_robot_msgs.msg
import
ShadowPST
7
import
thread
8
9
10
class
MergeMessages
(object):
11
def
__init__
(self):
12
rospy.init_node(
'ShadowPST_publisher'
, anonymous=
True
)
13
self.
ff_sub
= rospy.Subscriber(
'/sr_tactile/touch/ff'
, Float64, self.
ff_cb
)
14
self.
mf_sub
= rospy.Subscriber(
'/sr_tactile/touch/mf'
, Float64, self.
mf_cb
)
15
self.
rf_sub
= rospy.Subscriber(
'/sr_tactile/touch/rf'
, Float64, self.
rf_cb
)
16
self.
lf_sub
= rospy.Subscriber(
'/sr_tactile/touch/lf'
, Float64, self.
lf_cb
)
17
self.
th_sub
= rospy.Subscriber(
'/sr_tactile/touch/th'
, Float64, self.
th_cb
)
18
self.
rate
= rospy.Rate(25.0)
19
self.
pub
= rospy.Publisher(
"/tactile"
, ShadowPST)
20
self.
pst
= [0.0, 0.0, 0.0, 0.0, 0.0]
21
self.
mutex
= thread.allocate_lock()
22
23
def
ff_cb
(self, msg):
24
self.mutex.acquire()
25
self.
pst
[0] = msg.data
26
self.mutex.release()
27
28
def
mf_cb
(self, msg):
29
self.mutex.acquire()
30
self.
pst
[1] = msg.data
31
self.mutex.release()
32
33
def
rf_cb
(self, msg):
34
self.mutex.acquire()
35
self.
pst
[2] = msg.data
36
self.mutex.release()
37
38
def
lf_cb
(self, msg):
39
self.mutex.acquire()
40
self.
pst
[3] = msg.data
41
self.mutex.release()
42
43
def
th_cb
(self, msg):
44
self.mutex.acquire()
45
self.
pst
[4] = msg.data
46
self.mutex.release()
47
48
def
shadowpst_publisher
(self):
49
pst_state_msg = ShadowPST()
50
pst_state_msg.temperature = [0, 0, 0, 0, 0, 0]
51
pressure = []
52
self.mutex.acquire()
53
for
i
in
range(0, 5):
54
pressure.append(self.
pst
[i]*100)
55
pst_state_msg.pressure = pressure
56
# print pst_state_msg.pressure
57
self.mutex.release()
58
59
pst_state_msg.header.stamp = rospy.Time.now()
60
self.pub.publish(pst_state_msg)
61
62
if
__name__ ==
'__main__'
:
63
merger =
MergeMessages
()
64
while
not
rospy.is_shutdown():
65
merger.shadowpst_publisher()
66
merger.rate.sleep()
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.mf_sub
mf_sub
Definition:
virtual_ShadowPST_publisher.py:14
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.th_sub
th_sub
Definition:
virtual_ShadowPST_publisher.py:17
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.lf_cb
def lf_cb(self, msg)
Definition:
virtual_ShadowPST_publisher.py:38
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.th_cb
def th_cb(self, msg)
Definition:
virtual_ShadowPST_publisher.py:43
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.rf_sub
rf_sub
Definition:
virtual_ShadowPST_publisher.py:15
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.pst
pst
Definition:
virtual_ShadowPST_publisher.py:20
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.__init__
def __init__(self)
Definition:
virtual_ShadowPST_publisher.py:11
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.rate
rate
Definition:
virtual_ShadowPST_publisher.py:18
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.ff_sub
ff_sub
Definition:
virtual_ShadowPST_publisher.py:13
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages
Definition:
virtual_ShadowPST_publisher.py:10
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.lf_sub
lf_sub
Definition:
virtual_ShadowPST_publisher.py:16
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.shadowpst_publisher
def shadowpst_publisher(self)
Definition:
virtual_ShadowPST_publisher.py:48
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.pub
pub
Definition:
virtual_ShadowPST_publisher.py:19
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.ff_cb
def ff_cb(self, msg)
Definition:
virtual_ShadowPST_publisher.py:23
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.rf_cb
def rf_cb(self, msg)
Definition:
virtual_ShadowPST_publisher.py:33
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.mutex
mutex
Definition:
virtual_ShadowPST_publisher.py:21
sr_tactile_sensors.virtual_ShadowPST_publisher.MergeMessages.mf_cb
def mf_cb(self, msg)
Definition:
virtual_ShadowPST_publisher.py:28
sr_tactile_sensors
Author(s): Ugo Cupcic
autogenerated on Tue Oct 13 2020 03:55:46