Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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_hand')
00025 import rospy
00026 import time
00027
00028 from sr_robot_msgs.msg import joint, sendupdate, contrlr
00029
00030 def talker():
00031 """
00032 The Publisher publishes to the different topics on which the sr_subscriber subscribes. It sends commands to
00033 the hand.
00034
00035 Please set the message you want to test.
00036 """
00037 test_what = "sendupdate"
00038
00039 """
00040 Test the sendupdate command
00041 """
00042 if test_what == "sendupdate":
00043 pub1 = rospy.Publisher('srh/sendupdate', sendupdate)
00044 rospy.init_node('shadowhand_command_publisher_python')
00045
00046 new_target = 0
00047
00048 time.sleep(1)
00049 print "publishing"
00050 data_to_send = [ joint(joint_name="FFJ0", joint_target=new_target),
00051 joint(joint_name="FFJ3", joint_target=new_target) ]
00052
00053 pub1.publish(sendupdate(len(data_to_send), data_to_send))
00054
00055 """
00056 Tests the contrlr command
00057 """
00058 if test_what == "contrlr":
00059 pub2 = rospy.Publisher('contrlr', contrlr)
00060
00061 data_to_send = ["p:0","i:0"]
00062
00063 pub2.publish( contrlr( contrlr_name="smart_motor_ff2" ,
00064 list_of_parameters = data_to_send,
00065 length_of_list = len(data_to_send) ) )
00066
00067
00068
00069 if __name__ == '__main__':
00070 try:
00071 talker()
00072 except rospy.ROSInterruptException: pass