def fill_cells_random(): scope=m3t.M3Scope2(xwidth=100,yrange=None) ns=30#5#K*2 #Build desired vector log={'ns':ns,'type':'fill_cells_random', 'actuator':'MA12J1','L':L,'K':K,'CW':cw,'a':list(a),'b':list(b),'u_max':u_max,'u_min':u_min,'ut':[],'wt':[],'gt':[],'des':[]} des=[u_min] for nn in range(ns): while True: x=u_min+(u_max-u_min)*(random.random()) #randomly in range if abs(des[-1]-x)>5*cw: #make excursion at least 5 cells des.append(x) break log['des']=des print 'Des',des print 'Enable power. Hit enter to continue' raw_input() for ii in range(len(des)): print ii,'Des: ',des[ii] uu,ww,gg=ramp_to_torque(des[ii],scope) print len(uu),len(ww),len(gg) log['ut'].append(list(uu)) #input log['wt'].append(list(ww)) #output log['gt'].append(list(gg)) #hysteron states print 'Save data [y]?' if m3t.get_yes_no('y'): fn=m3t.get_m3_config_path()+'data/preisach_data_random_ma12j1_'+m3t.time_string()+'.yml' print 'Enter annotation string [None]' note=m3t.get_string('None') log['note']=note f=file(fn,'w') print 'Saving...',fn f.write(yaml.safe_dump(log, default_flow_style=False,width=200)) f.close() return log
def generate_joint(zlift_name=None,version=None, jid=None, pwr_name=None): if version is None: version=get_version(versions) if zlift_name is None: zlift_name=get_zlift_name() if jid is None: jid=get_joint_id() if pwr_name is None: pwr_name=get_pwr_name() actuator_ec=copy.deepcopy(config_zlift_def[version]['actuator_ec'][jid]) actuator=copy.deepcopy(config_zlift_def[version]['actuator'][jid]) joint=copy.deepcopy(config_zlift_def[version]['joint'][jid]) name_actuator_ec='m3actuator_ec_'+zlift_name+'_j'+str(jid) name_actuator='m3actuator_'+zlift_name+'_j'+str(jid) name_joint='m3joint_'+zlift_name+'_j'+str(jid) print 'Enter Serial Number of EC board for joint ','J'+str(jid),'(e.g. 300 for EC300):' x=m3t.get_int() actuator_ec['ethercat']['serial_number']=x actuator_ec['name']=name_actuator_ec actuator_ec['pwr_component']=pwr_name actuator['name']=name_actuator actuator['ec_component']=name_actuator_ec actuator['joint_component']=name_joint joint['name']=name_joint joint['actuator_component']=name_actuator joint['transmission']['act_name']=name_actuator config_dir=m3t.get_m3_config_path()+zlift_name+'/' return config_dir, [actuator_ec, actuator, joint]
def __init__(self): try: self.name = m3tt.get_m3_config()['sys_test'] except KeyError: print 'Key sys_test not defined in m3_config.yml. Exiting...' exit() path = m3tt.get_m3_config_path() filename = path + 'sys/m3_sys_test_' + self.name + '.yml' try: f = file(filename, 'r') self.config = yaml.safe_load(f.read()) f.close() except IOError: print 'File ', filename, 'not found. Exiting...' exit() self.log = [] #load included self.config_include = {'not_val': [], 'in_range': []} if self.config.has_key('include'): for fi in self.config['include']: filename = path + 'sys/m3_sys_test_' + fi + '.yml' try: f = file(filename, 'r') print 'Including: ', filename c = yaml.safe_load(f.read()) f.close() if c.has_key('not_val'): self.config_include['not_val'].append(c['not_val']) if c.has_key('in_range'): self.config_include['in_range'].append(c['in_range']) except IOError: print 'File ', filename, 'not found. Exiting...' exit()
def __init__(self): try: self.name=m3tt.get_m3_config()['sys_test'] except KeyError: print 'Key sys_test not defined in m3_config.yml. Exiting...' exit() path=m3tt.get_m3_config_path() filename= path+'sys/m3_sys_test_'+self.name+'.yml' try: f=file(filename,'r') self.config= yaml.safe_load(f.read()) f.close() except IOError: print 'File ',filename,'not found. Exiting...' exit() self.log=[] #load included self.config_include={'not_val':[],'in_range':[]} if self.config.has_key('include'): for fi in self.config['include']: filename= path+'sys/m3_sys_test_'+fi+'.yml' try: f=file(filename,'r') print 'Including: ',filename c= yaml.safe_load(f.read()) f.close() if c.has_key('not_val'): self.config_include['not_val'].append(c['not_val']) if c.has_key('in_range'): self.config_include['in_range'].append(c['in_range']) except IOError: print 'File ',filename,'not found. Exiting...' exit()
def generate_joint(base_name=None, version=None, jid=None, pwr_name=None): if version is None: version = get_version(versions) if base_name is None: base_name = get_base_name() if jid is None: jid = get_joint_id() if pwr_name is None: pwr_name = get_pwr_name() actuator_ec = copy.deepcopy( config_omnibase_def[version]['actuator_ec'][jid]) actuator = copy.deepcopy(config_omnibase_def[version]['actuator'][jid]) joint = copy.deepcopy(config_omnibase_def[version]['joint'][jid]) name_actuator_ec = 'm3actuator_ec_' + base_name + '_j' + str(jid) name_actuator = 'm3actuator_' + base_name + '_j' + str(jid) name_joint = 'm3joint_' + base_name + '_j' + str(jid) print 'Enter Serial Number of EC board for joint ', 'J' + str( jid), '(e.g. 300 for EC300):' x = m3t.get_int() actuator_ec['ethercat']['serial_number'] = x actuator_ec['name'] = name_actuator_ec actuator_ec['pwr_component'] = pwr_name actuator['name'] = name_actuator actuator['ec_component'] = name_actuator_ec actuator['joint_component'] = name_joint joint['name'] = name_joint joint['actuator_component'] = name_actuator joint['transmission']['act_name'] = name_actuator config_dir = m3t.get_m3_config_path() + base_name + '/' return config_dir, [actuator_ec, actuator, joint]
def generate_zlift_full(): version=get_version(versions) zlift_name=get_zlift_name() pwr_name=get_pwr_name() config_dir=m3t.get_m3_config_path()+zlift_name+'/' data=[] cd,x=generate_joint(zlift_name,version,0,pwr_name) data.extend(x) return config_dir,data
def generate_zlift_full(): version = get_version(versions) zlift_name = get_zlift_name() pwr_name = get_pwr_name() config_dir = m3t.get_m3_config_path() + zlift_name + '/' data = [] cd, x = generate_joint(zlift_name, version, 0, pwr_name) data.extend(x) return config_dir, data
def generate_dynamatics(head_name=None,version=None): if version is None: version=get_version(versions) if head_name is None: head_name=get_head_name() dyn=copy.deepcopy(config_head_def[version]['dynamatics']) dyn['chain_component']='m3head_'+head_name dyn['name']=dyn['name'].replace('xxx',head_name) config_dir=m3t.get_m3_config_path()+head_name+'/' return config_dir, [dyn]
def generate_dynamatics(head_name=None, version=None): if version is None: version = get_version(versions) if head_name is None: head_name = get_head_name() dyn = copy.deepcopy(config_head_def[version]['dynamatics']) dyn['chain_component'] = 'm3head_' + head_name dyn['name'] = dyn['name'].replace('xxx', head_name) config_dir = m3t.get_m3_config_path() + head_name + '/' return config_dir, [dyn]
def get_test_results(self): fn=m3t.get_m3_config_path()+'data/unit_test_results_'+self.comp_rt.name+'.yml' try: f=file(fn,'r') raw_data= yaml.safe_load(f.read()) f.close() return raw_data except (IOError, EOFError): raw_data={} print 'Test results file',fn,'not available' return None
def get_raw_calibration(self): fn=m3t.get_m3_config_path()[-1]+'data/calibration_data_raw_'+self.comp_ec.name+'.yml' try: f=file(fn,'r') raw_data= yaml.safe_load(f.read()) f.close() return raw_data except (IOError, EOFError): raw_data={} print 'Raw data file',fn,'not available' return None
def get_test_results(self): fn = m3t.get_m3_config_path( ) + 'data/unit_test_results_' + self.comp_rt.name + '.yml' try: f = file(fn, 'r') raw_data = yaml.safe_load(f.read()) f.close() return raw_data except (IOError, EOFError): raw_data = {} print 'Test results file', fn, 'not available' return None
def generate_omnibase_full(): version=get_version(versions) base_name=get_base_name() pwr_name=get_pwr_name() config_dir=m3t.get_m3_config_path()+base_name+'/' data=[] ndof=len(config_omnibase_def[version]['actuator']) for jid in range(ndof): cd,x=generate_joint(base_name,version,jid,pwr_name) data.extend(x) cd,x=generate_omnibase(base_name,version) data.extend(x) return config_dir,data
def generate_omnibase_full(): version = get_version(versions) base_name = get_base_name() pwr_name = get_pwr_name() config_dir = m3t.get_m3_config_path() + base_name + '/' data = [] ndof = len(config_omnibase_def[version]['actuator']) for jid in range(ndof): cd, x = generate_joint(base_name, version, jid, pwr_name) data.extend(x) cd, x = generate_omnibase(base_name, version) data.extend(x) return config_dir, data
def generate_torso(torso_name=None,version=None): if version is None: version=get_version(versions) if torso_name is None: torso_name=get_torso_name() torso=copy.deepcopy(config_torso_def[version]['torso']) torso['name']='m3torso_'+torso_name torso['limb_name']='torso' torso['dynamatics_component']=select_dynamatics(torso_name,version) torso['joint_components']['J0']='m3joint_'+torso_name+'_j0' torso['joint_components']['J1']='m3joint_'+torso_name+'_j1' torso['joint_components']['J2']='m3joint_slave_'+torso_name+'_j2' config_dir=m3t.get_m3_config_path()+torso_name+'/' return config_dir, [torso]
def generate_dynamatics(torso_name=None,version=None): if version is None: version=get_version(versions) if torso_name is None: torso_name=get_torso_name() dyn=copy.deepcopy(config_torso_def[version]['dynamatics']) ret=[] for k in dyn.keys(): d=dyn[k] d['chain_component']='m3torso_'+torso_name d['name']='m3dynamatics_'+k+'_'+torso_name ret.append(d) config_dir=m3t.get_m3_config_path()+torso_name+'/' return config_dir, ret
def generate_hand_full(): version=get_version(versions) hand_name=get_hand_name() limb_name=get_limb_name(limbs) pwr_name=get_pwr_name() config_dir=m3t.get_m3_config_path()+hand_name+'/' data=[] ndof=len(config_hand_def[version]['actuator_ec']) for jid in range(ndof): cd,x=generate_joint(hand_name,version,jid,pwr_name) data.extend(x) cd,x=generate_hand(hand_name,version, limb_name) data.extend(x) return config_dir,data
def generate_dynamatics(torso_name=None, version=None): if version is None: version = get_version(versions) if torso_name is None: torso_name = get_torso_name() dyn = copy.deepcopy(config_torso_def[version]['dynamatics']) ret = [] for k in dyn.keys(): d = dyn[k] d['chain_component'] = 'm3torso_' + torso_name d['name'] = 'm3dynamatics_' + k + '_' + torso_name ret.append(d) config_dir = m3t.get_m3_config_path() + torso_name + '/' return config_dir, ret
def generate_torso(torso_name=None, version=None): if version is None: version = get_version(versions) if torso_name is None: torso_name = get_torso_name() torso = copy.deepcopy(config_torso_def[version]['torso']) torso['name'] = 'm3torso_' + torso_name torso['limb_name'] = 'torso' torso['dynamatics_component'] = select_dynamatics(torso_name, version) torso['joint_components']['J0'] = 'm3joint_' + torso_name + '_j0' torso['joint_components']['J1'] = 'm3joint_' + torso_name + '_j1' torso['joint_components']['J2'] = 'm3joint_slave_' + torso_name + '_j2' config_dir = m3t.get_m3_config_path() + torso_name + '/' return config_dir, [torso]
def fill_cells_random(): scope = m3t.M3Scope2(xwidth=100, yrange=None) ns = 30 #5#K*2 #Build desired vector log = { 'ns': ns, 'type': 'fill_cells_random', 'actuator': 'MA12J1', 'L': L, 'K': K, 'CW': cw, 'a': list(a), 'b': list(b), 'u_max': u_max, 'u_min': u_min, 'ut': [], 'wt': [], 'gt': [], 'des': [] } des = [u_min] for nn in range(ns): while True: x = u_min + (u_max - u_min) * (random.random()) #randomly in range if abs(des[-1] - x) > 5 * cw: #make excursion at least 5 cells des.append(x) break log['des'] = des print 'Des', des print 'Enable power. Hit enter to continue' raw_input() for ii in range(len(des)): print ii, 'Des: ', des[ii] uu, ww, gg = ramp_to_torque(des[ii], scope) print len(uu), len(ww), len(gg) log['ut'].append(list(uu)) #input log['wt'].append(list(ww)) #output log['gt'].append(list(gg)) #hysteron states print 'Save data [y]?' if m3t.get_yes_no('y'): fn = m3t.get_m3_config_path( ) + 'data/preisach_data_random_ma12j1_' + m3t.time_string() + '.yml' print 'Enter annotation string [None]' note = m3t.get_string('None') log['note'] = note f = file(fn, 'w') print 'Saving...', fn f.write(yaml.safe_dump(log, default_flow_style=False, width=200)) f.close() return log
def generate_head(head_name=None,version=None): if version is None: version=get_version(versions) if head_name is None: head_name=get_head_name() head=copy.deepcopy(config_head_def[version]['head']) head['name']='m3head_'+head_name head['limb_name']='head' head['dynamatics_component']=head['dynamatics_component'].replace('xxx',head_name) #head['dynamatics_component']=select_dynamatics(head_name,version) for jn in head['joint_components']: head['joint_components'][jn]='m3joint_'+head_name+'_'+jn.lower() config_dir=m3t.get_m3_config_path()+head_name+'/' return config_dir, [head]
def generate_omnibase(base_name=None,version=None, pwr_name=None): if version is None: version=get_version(versions) if base_name is None: base_name=get_base_name() if pwr_name is None: pwr_name=get_pwr_name() omnibase=copy.deepcopy(config_omnibase_def[version]['base']) omnibase['name']='m3omnibase_'+base_name omnibase['pwr_component']=pwr_name ndof=len(config_omnibase_def[version]['actuator_ec']) for jid in range(ndof): omnibase['joint_components']['J'+str(jid)]='m3joint_'+base_name+'_j'+str(jid) config_dir=m3t.get_m3_config_path()+base_name+'/' return config_dir, [omnibase]
def generate_torso_full(): version=get_version(versions) torso_name=get_torso_name() pwr_name=get_pwr_name() config_dir=m3t.get_m3_config_path()+torso_name+'/' data=[] ndof=len(config_torso_def[version]['joint']) for jid in range(ndof): cd,x=generate_joint(torso_name,version,jid,pwr_name) data.extend(x) cd,x=generate_torso(torso_name,version) data.extend(x) cd,x=generate_dynamatics(torso_name,version) data.extend(x) return config_dir,data
def generate_torso_full(): version = get_version(versions) torso_name = get_torso_name() pwr_name = get_pwr_name() config_dir = m3t.get_m3_config_path() + torso_name + '/' data = [] ndof = len(config_torso_def[version]['joint']) for jid in range(ndof): cd, x = generate_joint(torso_name, version, jid, pwr_name) data.extend(x) cd, x = generate_torso(torso_name, version) data.extend(x) cd, x = generate_dynamatics(torso_name, version) data.extend(x) return config_dir, data
def generate_hand(hand_name=None,version=None, limb_name=None): if version is None: version=get_version(versions) if hand_name is None: hand_name=get_hand_name() if limb_name is None: limb_name=get_limb_name(limbs) hand=copy.deepcopy(config_hand_def[version]['hand']) hand['name']='m3hand_'+hand_name hand['limb_name']=limb_name ndof=len(config_hand_def[version]['actuator_ec']) for jid in range(ndof): hand['joint_components']['J'+str(jid)]='m3joint_'+hand_name+'_j'+str(jid) config_dir=m3t.get_m3_config_path()+hand_name+'/' return config_dir, [hand]
def generate_omnibase(base_name=None, version=None, pwr_name=None): if version is None: version = get_version(versions) if base_name is None: base_name = get_base_name() if pwr_name is None: pwr_name = get_pwr_name() omnibase = copy.deepcopy(config_omnibase_def[version]['base']) omnibase['name'] = 'm3omnibase_' + base_name omnibase['pwr_component'] = pwr_name ndof = len(config_omnibase_def[version]['actuator_ec']) for jid in range(ndof): omnibase['joint_components'][ 'J' + str(jid)] = 'm3joint_' + base_name + '_j' + str(jid) config_dir = m3t.get_m3_config_path() + base_name + '/' return config_dir, [omnibase]
def generate_head(head_name=None, version=None): if version is None: version = get_version(versions) if head_name is None: head_name = get_head_name() head = copy.deepcopy(config_head_def[version]['head']) head['name'] = 'm3head_' + head_name head['limb_name'] = 'head' head['dynamatics_component'] = head['dynamatics_component'].replace( 'xxx', head_name) #head['dynamatics_component']=select_dynamatics(head_name,version) for jn in head['joint_components']: head['joint_components'][jn] = 'm3joint_' + head_name + '_' + jn.lower( ) config_dir = m3t.get_m3_config_path() + head_name + '/' return config_dir, [head]
def generate_arm(arm_name=None,version=None, limb_name=None): if version is None: version=get_version(versions) if arm_name is None: arm_name=get_arm_name() if limb_name is None: limb_name=get_limb_name(limbs) arm=copy.deepcopy(config_arm_def[version]['arm']) arm['name']='m3arm_'+arm_name arm['limb_name']=limb_name arm['dynamatics_component']=select_dynamatics(arm_name,version,limb_name) ndof=len(config_arm_def[version]['actuator_ec']) for jid in range(ndof): arm['joint_components']['J'+str(jid)]='m3joint_'+arm_name+'_j'+str(jid) config_dir=m3t.get_m3_config_path()+arm_name+'/' return config_dir, [arm]
def generate(): ec=copy.deepcopy(config_loadx6_ec_a2r3) rt=copy.deepcopy(config_loadx6_a2r3) arm_name=get_arm_name() name_ec='m3loadx6_ec_'+arm_name+'_l0' name_rt='m3loadx6_'+arm_name+'_l0' print 'Enter Serial Number of EC board (e.g. 300)' x=m3t.get_int() print 'Enter Serial Number of Loadcell (e.g. 3333 for FT333)' y=m3t.get_int() rt['calib']['wrench']['serial_number'] ec['ethercat']['serial_number']='FT'+str(y) ec['name']=name_ec rt['name']=name_rt rt['ec_component']=name_ec config_dir=m3t.get_m3_config_path()+arm_name+'/' return config_dir, [ec, rt]
def write_raw_calibration(self,data): print 'Save raw data [y]?' if m3t.get_yes_no('y'): fn=m3t.get_m3_config_path()[-1]+'data/calibration_data_raw_'+self.comp_ec.name+'.yml' try: f=file(fn,'r') raw_data= yaml.safe_load(f.read()) f.close() except (IOError, EOFError): raw_data={} pass f=file(fn,'w') for k in data.keys(): raw_data[k]=data[k] print 'Saving...',fn f.write(yaml.safe_dump(data, default_flow_style=False,width=200)) f.close()
def generate_arm(arm_name=None, version=None, limb_name=None): if version is None: version = get_version(versions) if arm_name is None: arm_name = get_arm_name() if limb_name is None: limb_name = get_limb_name(limbs) arm = copy.deepcopy(config_arm_def[version]['arm']) arm['name'] = 'm3arm_' + arm_name arm['limb_name'] = limb_name arm['dynamatics_component'] = select_dynamatics(arm_name, version, limb_name) ndof = len(config_arm_def[version]['actuator_ec']) for jid in range(ndof): arm['joint_components'][ 'J' + str(jid)] = 'm3joint_' + arm_name + '_j' + str(jid) config_dir = m3t.get_m3_config_path() + arm_name + '/' return config_dir, [arm]
def set_bootloader_eeprom(boards, p3): # Check if eeprom files are available filename = m3t.get_m3_config_path() + "eeprom/eeprom_bld_sn_0.hex" eepf = glob.glob(filename) if len(eepf) != 1: print "BLD EEPROM file not found", filename return else: bld_eeprom = eepf[0] for k in boards.keys(): cmd = "sudo ethercat -f -p " + str(boards[k]["slave_id"]) + " sii_write " + bld_eeprom print "Executing: ", cmd os.system(cmd) print "Power cycle now. Hit return when ready" raw_input() time.sleep(4.0) if p3: m3rt.ethercat_bus_init(verbose=True) list_slaves()
def set_bootloader_eeprom(boards, p3): #Check if eeprom files are available filename = m3t.get_m3_config_path() + 'eeprom/eeprom_bld_sn_0.hex' eepf = glob.glob(filename) if len(eepf) != 1: print 'BLD EEPROM file not found', filename return else: bld_eeprom = eepf[0] for k in boards.keys(): cmd = 'sudo ethercat -f -p ' + str( boards[k]['slave_id']) + ' sii_write ' + bld_eeprom print 'Executing: ', cmd os.system(cmd) print 'Power cycle now. Hit return when ready' raw_input() time.sleep(4.0) if p3: m3rt.ethercat_bus_init(verbose=True) list_slaves()
def generate_dynamatics(arm_name=None,version=None,limb_name=None): if version is None: version=get_version(versions) if arm_name is None: arm_name=get_arm_name() if limb_name is None: limb_name=get_limb_name(limbs) dyn=copy.deepcopy(config_arm_def[version]['dynamatics']) ret=[] kk=dyn.keys() if limb_name=='right_arm': xx=[yy for yy in kk if yy.find('right')>=0] if limb_name=='left_arm': xx=[yy for yy in kk if yy.find('left')>=0] for x in xx: d=dyn[x] d['chain_component']='m3arm_'+arm_name d['name']='m3dynamatics_'+x+'_'+arm_name ret.append(d) config_dir=m3t.get_m3_config_path()+arm_name+'/' return config_dir, ret
def generate_dynamatics(arm_name=None, version=None, limb_name=None): if version is None: version = get_version(versions) if arm_name is None: arm_name = get_arm_name() if limb_name is None: limb_name = get_limb_name(limbs) dyn = copy.deepcopy(config_arm_def[version]['dynamatics']) ret = [] kk = dyn.keys() if limb_name == 'right_arm': xx = [yy for yy in kk if yy.find('right') >= 0] if limb_name == 'left_arm': xx = [yy for yy in kk if yy.find('left') >= 0] for x in xx: d = dyn[x] d['chain_component'] = 'm3arm_' + arm_name d['name'] = 'm3dynamatics_' + x + '_' + arm_name ret.append(d) config_dir = m3t.get_m3_config_path() + arm_name + '/' return config_dir, ret
def generate(): version = get_version() if version == '0.3': ec = copy.deepcopy(config_pwr_ec_v0_3) rt = copy.deepcopy(config_pwr_v0_3) if version == '0.4': ec = copy.deepcopy(config_pwr_ec_v0_4) rt = copy.deepcopy(config_pwr_v0_4) if version == '0.5': ec = copy.deepcopy(config_pwr_ec_v0_5) rt = copy.deepcopy(config_pwr_v0_5) print 'Enter PWR board ID (e.g., 10 for pwr010)' x = m3t.get_int() name_ec = 'm3pwr_ec_pwr' + '0' * (3 - len(str(x))) + str(x) name_rt = 'm3pwr_pwr' + '0' * (3 - len(str(x))) + str(x) print 'Enter Serial Number of EC board (e.g. 300)' x = m3t.get_int() ec['ethercat']['serial_number'] = x ec['name'] = name_ec rt['name'] = name_rt rt['ec_component'] = name_ec config_dir = m3t.get_m3_config_path() + 'pwr/' return config_dir, [ec, rt]
def generate(): version=get_version() if version=='0.3': ec=copy.deepcopy(config_pwr_ec_v0_3) rt=copy.deepcopy(config_pwr_v0_3) if version=='0.4': ec=copy.deepcopy(config_pwr_ec_v0_4) rt=copy.deepcopy(config_pwr_v0_4) if version=='0.5': ec=copy.deepcopy(config_pwr_ec_v0_5) rt=copy.deepcopy(config_pwr_v0_5) print 'Enter PWR board ID (e.g., 10 for pwr010)' x=m3t.get_int() name_ec='m3pwr_ec_pwr'+'0'*(3-len(str(x)))+str(x) name_rt='m3pwr_pwr'+'0'*(3-len(str(x)))+str(x) print 'Enter Serial Number of EC board (e.g. 300)' x=m3t.get_int() ec['ethercat']['serial_number']=x ec['name']=name_ec rt['name']=name_rt rt['ec_component']=name_ec config_dir=m3t.get_m3_config_path()+'pwr/' return config_dir, [ec, rt]
def get_boards(): print 'Finding burnable board from m3_config.yml...' name_ec = m3t.get_ec_component_names() boards = {} for n in name_ec: config = m3t.get_component_config(n) try: fw = config['firmware'] + '.hex' except KeyError: print 'Missing firmware key for', n, '...skipping' fw = None sn = config['ethercat']['serial_number'] try: chid = config['chid'] except KeyError: chid = 0 ssn = get_slave_sn() sid = None for s in ssn: if sn == s[0]: sid = s[1] ff = m3t.get_m3_config_path() + 'eeprom/eeprom*_sn_' + str(sn) + '.hex' eepf = glob.glob(ff) if len(eepf) == 0: print 'EEPROM file not found', ff, 'skipping board...' if len(eepf) > 1: print 'Multiple eeproms found for', ff print 'Select correct eeprom ID' for i in range(len(eepf)): print i, ' : ', eepf[i] idx = m3t.get_int() eepf = [eepf[idx]] if sid != None and len(eepf) == 1 and fw is not None and chid == 0: boards[n] = { 'firmware': fw, 'sn': sn, 'slave_id': sid, 'eeprom': eepf[0], 'connected': False, 'write_success': False } print 'Found the following valid configurations: ' print boards.keys() print print 'Selection type' print '-----------------' print 'a: all boards' print 's: single board' print 'm: multiple boards' t = raw_input() if t != 'a' and t != 's' and t != 'm': print 'Invalid selection' return {} rem = [] if t == 'm': for k in boards.keys(): print '-----------------------' print 'Burn ', k, 'board [y]?' if not m3t.get_yes_no('y'): rem.append(k) for r in rem: boards.pop(r) if t == 's': k = m3t.user_select_components_interactive(boards.keys(), single=True) if len(k) == 0: return {} boards = {k[0]: boards[k[0]]} print '-------------------------------' print 'Burning the following boards: ' for k in boards.keys(): print k return boards
#! /usr/bin/python import pylab as pyl import m3.toolbox as m3t import m3.toolbox_ctrl as m3tc import yaml import glob path= m3t.get_m3_config_path()+'data/' files=glob.glob(path+'calibration_data_raw_m3actuator_ec_*.yml') files.sort() if len(files)==0: print 'No calibration files found' exit() comps=[] for f in files: comps.append(f[f.find('calibration_data_raw')+21:len(f)-4]) print 'Enter component ID' print '------------------' for i in range(len(comps)): print i,' : ',comps[i] idd=m3t.get_int() if idd<0 or idd>=len(comps): print 'Invalid ID' exit() fn=files[idd] print 'Display calibration file: ',fn try: f=file(fn,'r') d= yaml.safe_load(f.read()) f.close()
def generate_humanoid(): robot_name=get_robot_name() has_torso=False has_right_arm=False has_left_arm=False has_head=False print 'Torso present [y]?' if m3t.get_yes_no('y'): has_torso=True torso_name=get_torso_name() torso_version=get_version(['T2.R2','T2.R3']) print 'Right arm present [y]?' if m3t.get_yes_no('y'): has_right_arm=True print 'For right arm: ', right_arm_name=get_arm_name() right_arm_version=get_version(['A2.R2','A2.R3']) print 'Left arm present [y]?' if m3t.get_yes_no('y'): has_left_arm=True print 'For left arm: ', left_arm_name=get_arm_name() left_arm_version=get_version(['A2.R2','A2.R3']) print 'Head present [y]?' if m3t.get_yes_no('y'): has_head=True print 'For head: ', head_name=get_head_name() head_version='S2.R1' pwr_name=get_pwr_name() config_dir=m3t.get_m3_config_path()+robot_name+'/' data=[] #descending number of limbs #4 if has_left_arm and has_right_arm and has_torso and has_head: if torso_version=='T2.R3' and right_arm_version=='A2.R3' and left_arm_version=='A2.R3' and head_version=='S2.R1': x=copy.deepcopy(config_robot_A3T3['Humanoid.A2R3-Bimanual.T2R3.S2R1']) x['name']='m3humanoid_bimanual_torso_head_'+robot_name x['pwr_component']=pwr_name x['chains']['right_arm']['chain_component']='m3arm_'+right_arm_name x['chains']['left_arm']['chain_component']='m3arm_'+left_arm_name x['chains']['torso']['chain_component']='m3torso_'+torso_name x['chains']['head']['chain_component']='m3head_'+head_name data.append(x) return config_dir,data if torso_version=='T2.R2' and right_arm_version=='A2.R2' and left_arm_version=='A2.R2' and head_version=='S2.R1': x=copy.deepcopy(config_robot_A2T2['Humanoid.A2R2-Bimanual.T2R2.S2R1']) x['name']='m3humanoid_bimanual_torso_head_'+robot_name x['pwr_component']=pwr_name x['chains']['right_arm']['chain_component']='m3arm_'+right_arm_name x['chains']['left_arm']['chain_component']='m3arm_'+left_arm_name x['chains']['torso']['chain_component']='m3torso_'+torso_name x['chains']['head']['chain_component']='m3head_'+head_name data.append(x) return config_dir,data #3 if has_right_arm and has_torso and has_head: if torso_version=='T2.R3' and right_arm_version=='A2.R3' and head_version=='S2.R1': x=copy.deepcopy(config_robot_A3T3['Humanoid.A2R3-Right.T2R3.S2R1']) x['name']='m3humanoid_right_arm_torso_head_'+robot_name x['pwr_component']=pwr_name x['chains']['right_arm']['chain_component']='m3arm_'+right_arm_name x['chains']['torso']['chain_component']='m3torso_'+torso_name x['chains']['head']['chain_component']='m3head_'+head_name data.append(x) return config_dir,data if torso_version=='T2.R2' and right_arm_version=='A2.R2' and head_version=='S2.R1': x=copy.deepcopy(config_robot_A2T2['Humanoid.A2R2-Right.T2R2.S2R1']) x['name']='m3humanoid_right_arm_torso_head_'+robot_name x['pwr_component']=pwr_name x['chains']['right_arm']['chain_component']='m3arm_'+right_arm_name x['chains']['torso']['chain_component']='m3torso_'+torso_name x['chains']['head']['chain_component']='m3head_'+head_name data.append(x) return config_dir,data if has_left_arm and has_right_arm and has_torso: x=copy.deepcopy(config_robot_A3T3['Humanoid.A2R3-Bimanual.T2R3']) x['name']='m3humanoid_bimanual_torso_'+robot_name x['pwr_component']=pwr_name x['chains']['right_arm']['chain_component']='m3arm_'+right_arm_name x['chains']['left_arm']['chain_component']='m3arm_'+left_arm_name x['chains']['torso']['chain_component']='m3torso_'+torso_name data.append(x) return config_dir,data #2 if has_left_arm and has_torso: x=copy.deepcopy(config_robot_A3T3['Humanoid.A2R3-Left.T2R3']) x['name']='m3humanoid_left_arm_torso_'+robot_name x['pwr_component']=pwr_name x['chains']['torso']['chain_component']='m3torso_'+torso_name x['chains']['left_arm']['chain_component']='m3arm_'+left_arm_name data.append(x) return config_dir,data if has_right_arm and has_torso: x=copy.deepcopy(config_robot_A3T3['Humanoid.A2R3-Right.T2R3']) x['name']='m3humanoid_right_arm_torso_'+robot_name x['pwr_component']=pwr_name x['chains']['torso']['chain_component']='m3torso_'+torso_name x['chains']['right_arm']['chain_component']='m3arm_'+right_arm_name data.append(x) return config_dir,data if has_left_arm and has_right_arm: x=copy.deepcopy(config_robot_A3T3['Humanoid.A2R3-Bimanual']) x['name']='m3humanoid_bimanual_'+robot_name x['pwr_component']=pwr_name x['chains']['right_arm']['chain_component']='m3arm_'+right_arm_name x['chains']['left_arm']['chain_component']='m3arm_'+left_arm_name data.append(x) return config_dir,data #1 if has_torso: x=copy.deepcopy(config_robot_A3T3['Humanoid.T2R3']) x['name']='m3humanoid_torso_'+robot_name x['pwr_component']=pwr_name x['chains']['torso']['chain_component']='m3torso_'+torso_name data.append(x) return config_dir,data if has_right_arm: x=copy.deepcopy(config_robot_A3T3['Humanoid.A2R3-Right']) x['name']='m3humanoid_right_arm_'+robot_name x['pwr_component']=pwr_name x['chains']['right_arm']['chain_component']='m3arm_'+right_arm_name data.append(x) return config_dir,data if has_left_arm: x=copy.deepcopy(config_robot_A3T3['Humanoid.A2R3-Left']) x['name']='m3humanoid_left_arm_'+robot_name x['pwr_component']=pwr_name x['chains']['left_arm']['chain_component']='m3arm_'+left_arm_name data.append(x) return config_dir,data if has_head: x=copy.deepcopy(config_robot_A3T3['Humanoid.S2R1']) x['name']='m3humanoid_head_'+robot_name x['pwr_component']=pwr_name x['chains']['head']['chain_component']='m3head_'+head_name data.append(x) return config_dir,data
def get_boards(): print "Finding burnable board from m3_config.yml..." name_ec = m3t.get_ec_component_names() boards = {} for n in name_ec: config = m3t.get_component_config(n) try: fw = config["firmware"] + ".hex" except KeyError: print "Missing firmware key for", n, "...skipping" fw = None sn = config["ethercat"]["serial_number"] try: chid = config["chid"] except KeyError: chid = 0 ssn = get_slave_sn() sid = None for s in ssn: if sn == s[0]: sid = s[1] ff = m3t.get_m3_config_path() + "eeprom/eeprom*_sn_" + str(sn) + ".hex" eepf = glob.glob(ff) if len(eepf) == 0: print "EEPROM file not found", ff, "skipping board..." if len(eepf) > 1: print "Multiple eeproms found for", ff print "Select correct eeprom ID" for i in range(len(eepf)): print i, " : ", eepf[i] idx = m3t.get_int() eepf = [eepf[idx]] if sid != None and len(eepf) == 1 and fw is not None and chid == 0: boards[n] = { "firmware": fw, "sn": sn, "slave_id": sid, "eeprom": eepf[0], "connected": False, "write_success": False, } print "Found the following valid configurations: " print boards.keys() print print "Selection type" print "-----------------" print "a: all boards" print "s: single board" print "m: multiple boards" t = raw_input() if t != "a" and t != "s" and t != "m": print "Invalid selection" return {} rem = [] if t == "m": for k in boards.keys(): print "-----------------------" print "Burn ", k, "board [y]?" if not m3t.get_yes_no("y"): rem.append(k) for r in rem: boards.pop(r) if t == "s": k = m3t.user_select_components_interactive(boards.keys(), single=True) if len(k) == 0: return {} boards = {k[0]: boards[k[0]]} print "-------------------------------" print "Burning the following boards: " for k in boards.keys(): print k return boards
#! /usr/bin/python import pylab as pyl import m3.toolbox as m3t import m3.toolbox_ctrl as m3tc import yaml import glob path = m3t.get_m3_config_path() + 'data/' files = glob.glob(path + 'calibration_data_raw_m3actuator_ec_*.yml') files.sort() if len(files) == 0: print 'No calibration files found' exit() comps = [] for f in files: comps.append(f[f.find('calibration_data_raw') + 21:len(f) - 4]) print 'Enter component ID' print '------------------' for i in range(len(comps)): print i, ' : ', comps[i] idd = m3t.get_int() if idd < 0 or idd >= len(comps): print 'Invalid ID' exit() fn = files[idd] print 'Display calibration file: ', fn try: f = file(fn, 'r') d = yaml.safe_load(f.read()) f.close()