sr_hand_optoforce_tactile_example.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright 2019 Shadow Robot Company Ltd.
3 #
4 # This program is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the Free
6 # Software Foundation version 2 of the License.
7 #
8 # This program is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 # more details.
12 #
13 # You should have received a copy of the GNU General Public License along
14 # with this program. If not, see <http://www.gnu.org/licenses/>.
15 
16 # Reading the optoforce tactiles from the hand.
17 
18 import rospy
19 from geometry_msgs.msg import WrenchStamped
20 
21 
22 def callback(data):
23  rospy.loginfo("At:" + str(data.header.stamp.secs) + "." + str(data.header.stamp.nsecs) +
24  " sensor:" + str(data.header.frame_id) +
25  " Force:" + str(data.wrench.force.x) + "," +
26  str(data.wrench.force.y) + "," + str(data.wrench.force.z))
27 
28 
29 def listener():
30  num_sensors = 5
31  rospy.init_node("optoforce_tactile_reader", anonymous=True)
32  for sensor_num in range(num_sensors):
33  rospy.Subscriber("optoforce_" + str(sensor_num), WrenchStamped, callback)
34  rospy.spin()
35 
36 if __name__ == '__main__':
37  listener()


sr_example
Author(s): Ugo Cupcic
autogenerated on Wed Oct 14 2020 04:05:12