shadowhand_publisher.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2011 Shadow Robot Company Ltd.
00004 #
00005 # This program is free software: you can redistribute it and/or modify it
00006 # under the terms of the GNU General Public License as published by the Free
00007 # Software Foundation, either version 2 of the License, or (at your option)
00008 # any later version.
00009 #
00010 # This program is distributed in the hope that it will be useful, but WITHOUT
00011 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00013 # more details.
00014 #
00015 # You should have received a copy of the GNU General Public License along
00016 # with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 #
00018 # -*- coding: utf-8 -*-
00019 """
00020 This is an example showing how to publish command messages to the hand.
00021 """
00022 
00023 
00024 import roslib; roslib.load_manifest('sr_example')
00025 import rospy
00026 import time
00027 import math
00028 
00029 from std_msgs.msg import Float64
00030 
00031 # type of controller that is running
00032 controller_type = "_position_controller"
00033 
00034 def talker():
00035     """
00036     The Publisher publishes two commands to move joint FFJ0 and RFJ0
00037 
00038     """
00039     joint1 = 'ffj0'
00040     joint2 = 'rfj0'
00041 
00042     #Initalize the ROS node
00043     rospy.init_node('shadowhand_command_publisher_python')
00044 
00045     pub1 = rospy.Publisher('sh_'+ joint1 + controller_type + '/command', Float64, latch=True)
00046     pub2 = rospy.Publisher('sh_'+ joint2 + controller_type + '/command', Float64, latch=True)
00047 
00048 
00049     # define a new target value for the joint position.
00050     # The position controllers expect their commands in radians
00051     new_target_1 = math.radians(0.0)
00052     new_target_2 = math.radians(0.0)
00053 
00054     time.sleep(1)
00055     print "publishing"
00056 
00057     #This will move the joint ffj0 to the defined target (0 degrees)
00058     pub1.publish(new_target_1)
00059 
00060     #This will move the joint rfj0 to the defined target (0 degrees)
00061     pub2.publish(new_target_2)
00062 
00063 
00064 if __name__ == '__main__':
00065     try:
00066         talker()
00067     except rospy.ROSInterruptException: pass


sr_example
Author(s): Ugo Cupcic
autogenerated on Fri Aug 21 2015 12:25:43