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
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 import m3.toolbox as m3t
00032 import mekabot.hrl_robot as hr
00033 import time
00034 import math, numpy as np
00035 import hrl_lib.util as ut, hrl_lib.transforms as tr
00036
00037 def record_initial(firenze):
00038 equilibrium_pos_list = []
00039 for i in range(50):
00040 equilibrium_pos_list.append(firenze.end_effector_pos('right_arm'))
00041
00042 eq_pos = np.column_stack(equilibrium_pos_list).mean(1)
00043 ut.save_pickle(eq_pos,'eq_pos_'+ut.formatted_time()+'.pkl')
00044 firenze.bias_wrist_ft('right_arm')
00045
00046
00047
00048 def record_joint_displacements():
00049 print 'hit ENTER to start the recording process'
00050 k=m3t.get_keystroke()
00051
00052 pos_list = []
00053 force_list = []
00054
00055 while k == '\r':
00056 print 'hit ENTER to record configuration, something else to exit'
00057 k=m3t.get_keystroke()
00058 firenze.proxy.step()
00059 pos_list.append(firenze.end_effector_pos('right_arm'))
00060 force_list.append(firenze.get_wrist_force('right_arm', base_frame=True))
00061
00062 ut.save_pickle({'pos_list':pos_list,'force_list':force_list},'stiffness_'+ut.formatted_time()+'.pkl')
00063 firenze.stop()
00064
00065
00066
00067 if __name__ == '__main__':
00068
00069 settings_r = hr.MekaArmSettings(stiffness_list=[0.1939,0.6713,0.997,0.7272,0.75])
00070 firenze = hr.M3HrlRobot(connect = True, right_arm_settings = settings_r)
00071
00072 print 'hit a key to power up the arms.'
00073 k = m3t.get_keystroke()
00074 firenze.power_on()
00075
00076 print 'hit a key to test IK'
00077 k = m3t.get_keystroke()
00078
00079 rot = tr.Ry(math.radians(-90))
00080 p = np.matrix([0.3,-0.40,-0.2]).T
00081
00082 firenze.motors_on()
00083
00084
00085
00086 jep = [-0.30365041761032346, 0.3490658503988659, 0.59866827092412689, 1.7924513637028943, 0.4580617747379146, -0.13602429148726047, -0.48610218950666179]
00087 firenze.go_jointangles('right_arm', jep)
00088
00089
00090 print 'hit a key to record equilibrium position'
00091 k = m3t.get_keystroke()
00092 record_initial(firenze)
00093
00094 record_joint_displacements()
00095
00096 print 'hit a key to end everything'
00097 k = m3t.get_keystroke()
00098 firenze.stop()
00099
00100