example_reading_sensors.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright 2019 Shadow Robot Company Ltd.
4 #
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation version 2 of the License.
8 #
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 # more details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 import roslib
18 import rospy
19 from std_msgs.msg import Float64
20 from sr_robot_msgs.msg import JointMusclePositionControllerState
21 import math
22 
23 # A callback function for the state messages we are reading.
24 status = None
25 
26 
27 def state_cb(data):
28  global status
29  status = data
30 
31 rospy.init_node('example_reading_sensors')
32 
33 # Set up the subscriber so we can read the data, each joint publishes its
34 # own state.
35 rospy.Subscriber('/sh_ffj3_muscle_position_controller/state',
36  JointMusclePositionControllerState, state_cb)
37 
38 print "Try moving ffj3"
39 r = rospy.Rate(1) # hz
40 while not rospy.is_shutdown():
41  if status:
42  print "ffj3 position:%s radians pressure0:%s pressure1:%s" % (status.process_value,
43  status.muscle_pressure_0,
44  status.muscle_pressure_1)
45  r.sleep()


sr_edc_muscle_tools
Author(s): Mark Pitchless
autogenerated on Tue Oct 13 2020 04:01:56