How to use Frame method in root

Best JavaScript code snippet using root

gui.py

Source:gui.py Github

copy

Full Screen

...38 self.dir = getcwd() #todo: make this global?39 self.boxes = [] #todo: put this somewhere else?40 self.rowconfigure(0, weight=1)41 self.columnconfigure(0, weight=1)42 self.mainFrame = ttk.Frame()43 self.load(0)44 def load(self, page):45 '''Takes an int page number, loads that page.'''46 self.mainFrame.grid_remove()47 self.page = page48 if page in self.pages:49 self.mainFrame = self.pages[page]50 self.mainFrame.grid()51 self.title(self.titles[page])52 else:53 newFrame, title, config = self.pageFuns[page](self)54 newFrame.grid(row=0, column=0, cnf=config)55 self.pages[page] = newFrame56 self.mainFrame = newFrame57 self.title(title)58 self.titles[page] = title59 def nextPage(self):60 '''Loads the next page.'''61 if self.page < self.lastPage:62 self.load(self.page + 1)63 def prevPage(self):64 '''Loads the previous page.'''65 if self.page > 0:66 self.load(self.page - 1)67class Nav(ttk.Frame):68 '''A class for navigational Frames. Takes a master Frame and two69 navigational functions.'''70 def __init__(self, master, backFun, nextFun):71 super().__init__(master, padding=MAIN_PAD)72 73 self.columnconfigure(0, weight=1)74 self.columnconfigure(1, weight=1)75 backButton = ttk.Button(self, text='<-- Back', command=backFun)76 backButton.grid(row=0, column=0, sticky='w')77 self.backButton = backButton78 nextButton = ttk.Button(self, text='Next -->', command=nextFun)79 nextButton.grid(row=0, column=1, sticky='e')80 self.nextButton = nextButton81 def disable(self, direction, boolean):82 '''Takes a string 'back' or 'next' and a bool, disables the Button if83 boolean is True, enables it if boolean is False.'''84 button = getattr(self, direction + 'Button')85 if boolean:86 button.state(['disabled'])87 else:88 button.state(['!disabled'])89 90 def hide(self, direction, boolean):91 '''Takes a string 'back' or 'next' and a bool, hides the Button if92 boolean is True, unhides it if boolean is False.'''93 button = getattr(self, direction + 'Button')94 if boolean:95 button.grid_remove()96 else:97 button.grid()98def getDir(fileName):99 '''Takes a string file name, returns the string directory of that file.'''100 i = fileName.rfind('\\')101 if i == -1:102 return fileName[:fileName.rfind('/')]103 else:104 return fileName[:i]105#todo: get rid of this if you don't end up using it semi-frequently106def setState(boolean, state, widgets):107 '''Takes a bool, a string, and a list of widgets, enables the state for108 each widget if the bool is True, disables the state if False.'''109 if boolean:110 for w in widgets:111 w.state([state])112 else:113 for w in widgets:114 w.state(['!'+state])115def main():116 '''Sets up the initial window, runs the program.'''117 root = Root([titleWindow, fileWindow, boxWindow, overwriteWindow,118 confirmWindow, transferWindow, doneWindow])119 root.geometry('{}x{}'.format(WIDTH, HEIGHT))120 root.resizable(False, False)121 root.mainloop()122def titleWindow(root):123 '''Creates the title window.'''124 baseFrame = ttk.Frame(root)125 baseFrame.rowconfigure(0, weight=1)126 baseFrame.columnconfigure(0, weight=1)127 128 mainFrame = ttk.Frame(baseFrame, padding=MAIN_PAD)129 mainFrame.grid(row=0, column=0, sticky='n')130 titleLabel = ttk.Label(mainFrame, text='Pok\u00E9Bridge')131 titleLabel.grid(row=0, column=1)132 bodyText = '''Hello, and welcome to Pok\u00E9Bridge! This simple application will allow you to transfer your Pok\u00E9mon from Generation II to Generation III, moving entire Boxes at a time. To get started, press the Next button.'''133 bodyLabel = ttk.Label(mainFrame, text=bodyText, justify='center',134 wraplength=500)135 bodyLabel.grid(row=1, column=0, columnspan=3)136 pic1 = PhotoImage(file='res/old025.gif')137 pic1Label = ttk.Label(mainFrame, image=pic1)138 pic1Label.grid(row=0, column=0)139 pic2 = PhotoImage(file='res/025.gif')140 pic2Label = ttk.Label(mainFrame, image=pic2)141 pic2Label.grid(row=0, column=2)142 143 mainFrame.pics = [pic1, pic2] #avoiding garbage collection144 navFrame = Nav(baseFrame, root.prevPage, root.nextPage)145 navFrame.grid(row=1, column=0, sticky='we')146 navFrame.hide('back', True)147 return (baseFrame, 'Pok\u00E9Bridge', {'sticky':'nsew'})148def fileWindow(root):149 '''Makes the window that lets the user specify save files and options.'''150 def nextPage():151 global oldGen2, oldGen3, newGame, language, gender152 oldGen2 = fromText.get()153 oldGen3 = toText.get()154 newGame = gameCombo.get()155 language = langCombo.get()156 gender = genderCombo.get()157 with open(oldGen2, 'br') as file:158 root.boxes = getBoxes(file.read())159 root.nextPage()160 def nextToggle(*args):161 if fromText.get() == '' or toText.get() == '':162 navFrame.disable('next', True)163 else:164 navFrame.disable('next', False)165 def fromDialog():166 askOpen = filedialog.askopenfilename167 file = askOpen(title='Gen II Save File', initialdir=root.dir,168 filetypes=[('GB Save', '.sav'), ('All Files', '.*')])169 if file != '':170 fromText.set(file)171 fromEntry.after_idle(fromEntry.xview_moveto, 1)172 root.dir = getDir(file)173 174 def toDialog():175 askOpen = filedialog.askopenfilename176 file = askOpen(title='Gen III Save File', initialdir=root.dir,177 filetypes=[('GBA Save', '.sav'), ('All Files', '.*')])178 if file != '':179 toText.set(file)180 toEntry.after_idle(toEntry.xview_moveto, 1)181 root.dir = getDir(file)182 def getBoxes(data):183 from pokeBridge import Box, OldSaveFile184 boxes = []185 for offset in OldSaveFile.BOX_OFFSETS:186 box = []187 count = data[offset]188 for i in range(count):189 box.append(data[offset + 1 + i])190 for i in range(Box.OLD_SIZE - len(box)): #pad with 0191 box.append(0x0)192 boxes.append(box)193 return boxes194 baseFrame = ttk.Frame(root)195 baseFrame.rowconfigure(0, weight=1)196 baseFrame.columnconfigure(0, weight=1)197 198 199 mainFrame = ttk.Frame(baseFrame, padding=MAIN_PAD)200 mainFrame.grid(row=0, column=0)201 mainFrame.rowconfigure(0, weight=1)202 mainFrame.columnconfigure(0, weight=1)203 204 pickerFrame = ttk.Frame(mainFrame)205 pickerFrame.grid(row=0, column=0, sticky='s')206 pickText = "Select the Gen II save file to transfer Pok\u00E9mon from and the Gen III save file to transfer Pok\u00E9mon to."207 pickLabel = ttk.Label(pickerFrame, text=pickText, wraplength=WIDTH-50,208 justify='center')209 pickLabel.grid(row=0, column=0, columnspan=2, pady=10)210 fromButton = ttk.Button(pickerFrame, text='From...', command=fromDialog)211 fromButton.grid(row=1, column=0, sticky='e', padx=5, pady=5)212 fromText = StringVar()213 fromText.trace('w', nextToggle)214 fromEntry = ttk.Entry(pickerFrame, textvariable=fromText, state='readonly')215 fromEntry.grid(row=1, column=1, sticky='w', padx=5, pady=5)216 217 toButton = ttk.Button(pickerFrame, text='To...', command=toDialog)218 toButton.grid(row=2, column=0, sticky='e', padx=5, pady=5)219 toText = StringVar()220 toText.trace('w', nextToggle)221 toEntry = ttk.Entry(pickerFrame, textvariable=toText, state='readonly')222 toEntry.grid(row=2, column=1, sticky='w', padx=5, pady=5)223 optionFrame = ttk.Frame(mainFrame)224 optionFrame.grid(row=1, column=0)225 optionText = "Select the appropriate options from the drop-down menus below."226 optionLabel = ttk.Label(optionFrame, text=optionText)227 optionLabel.grid(row=0, column=0, columnspan=2, pady=10)228 gameChoices = ['Ruby', 'Sapphire', 'Emerald', 'FireRed', 'LeafGreen']229 langChoices = ['English', 'Japanese', 'French', 'Italian', 'German',230 'Korean', 'Spanish']231 genderChoices = ['Male', 'Female']232 gameLabel = ttk.Label(optionFrame, text='Destination Game')233 gameLabel.grid(row=1, column=0, sticky='e', padx=5, pady=5)234 235 gameCombo = ttk.Combobox(optionFrame, values=gameChoices,236 state='readonly')237 gameCombo.set(gameChoices[0])238 gameCombo.grid(row=1, column=1, sticky='w', padx=5, pady=5)239 240 langLabel = ttk.Label(optionFrame, text='Game Language')241 langLabel.grid(row=2, column=0, sticky='e', padx=5, pady=5)242 243 langCombo = ttk.Combobox(optionFrame, values=langChoices,244 state='readonly')245 langCombo.set(langChoices[0])246 langCombo.grid(row=2, column=1, sticky='w', padx=5, pady=5)247 248 genderLabel = ttk.Label(optionFrame, text='OT Gender')249 genderLabel.grid(row=3, column=0, sticky='e', padx=5, pady=5)250 251 genderCombo = ttk.Combobox(optionFrame, values=genderChoices,252 state='readonly')253 genderCombo.set(genderChoices[0])254 genderCombo.grid(row=3, column=1, sticky='w', padx=5, pady=5)255 navFrame = Nav(baseFrame, root.prevPage, nextPage)256 navFrame.grid(row=1, column=0, sticky='we')257 if debug:258 fromText.set('C:/Users/Sidnoea/Documents/GitHub/pokeBridge/Old Gen 2.sav')259 toText.set('C:/Users/Sidnoea/Documents/GitHub/pokeBridge/Old Gen 3.sav')260 nextToggle()261 return (baseFrame, 'Select Save Files', {'sticky':'nsew'})262def boxWindow(root):263 '''Creates the window for selecting the boxes to be transferred.'''264 from pokeBridge import Box, SaveGame265 from pokeBridge import oldNameTrans266 global oldGen2267 boxLen = Box.OLD_SIZE268 numBoxes = SaveGame.NUMBER_OF_BOXES269 def makeButtonFun(i):270 def buttonFun():271 boxDisplay['text'] = comboChoices[i+1]272 boxPics = []273 boxIDs = root.boxes[i]274 for j in range(boxLen):275 pkmnNum = boxIDs[j]276 pic = PhotoImage(file='res/{:0>3}.gif'.format(pkmnNum))277 boxPics.append(pic)278 boxDisplay.boxPics = boxPics #avoiding garbage collection279 for pic in boxDisplay.winfo_children():280 pic.destroy()281 for j in range(4):282 for k in range(5):283 pic = ttk.Label(boxDisplay, image=boxPics[5*j+k])284 pic.grid(row=j, column=k)285 286 return buttonFun287 def nextPage():288 global oldBoxNums, newBoxNums289 choices = {i+1:j.current() for i,j in toCombos.items()}290 oldBoxNums = [i for i in choices if choices[i] != 0]291 newBoxNums = [choices[i] for i in oldBoxNums]292 root.nextPage()293 def loadDisplay(*args):294 fromButtons[0].invoke()295 baseFrame = ttk.Frame(root)296 baseFrame.rowconfigure(0, weight=1)297 baseFrame.columnconfigure(0, weight=1)298 baseFrame.bind('<Expose>', loadDisplay)299 300 mainFrame = ttk.Frame(baseFrame, padding=MAIN_PAD)301 mainFrame.grid(row=0, column=0, sticky='nsew')302 mainFrame.rowconfigure(0, weight=1)303 mainFrame.columnconfigure(0, weight=1)304 mainFrame.columnconfigure(1, weight=1)305 boxesFrame = ttk.Frame(mainFrame)306 boxesFrame.grid(row=0, column=0, sticky='w')307 ttk.Label(boxesFrame, text='From').grid(row=0, column=0)308 ttk.Label(boxesFrame, text='To').grid(row=0, column=1)309 310 fromButtons = {}311 toCombos = {}312 #todo: get actual box names313 oldBoxes = ['BOX {}'.format(i+1) for i in range(numBoxes)]314 newBoxes = ['BOX {}'.format(i+1) for i in range(numBoxes)]315 comboChoices = ['None'] + newBoxes316 for i in range(numBoxes):317 fromButtons[i] = ttk.Button(boxesFrame, text='BOX {}'.format(i+1),318 command=makeButtonFun(i))319 fromButtons[i].grid(row=i+1, column=0, padx=5)320 toCombos[i] = ttk.Combobox(boxesFrame, values=comboChoices, width=10,321 state='readonly')322 toCombos[i].set(comboChoices[0])323 toCombos[i].grid(row=i+1, column=1, padx=5)324 #todo: make sure the same box isn't picked twice325 326 displayFrame = ttk.Frame(mainFrame)327 displayFrame.grid(row=0, column=1)328 DISP_WIDTH = 350329 instrText = 'Use the drop-down menus under the "To" column to choose where the Pok\u00E9mon in the corresponding "From" box will be sent. Boxes marked with "None" will not be transferred. Click the name of the From box to see its contents in the display below.'330 instrLabel = ttk.Label(displayFrame, text=instrText,331 wraplength=DISP_WIDTH)332 instrLabel.grid(row=0, column=0)333 boxDisplay = ttk.Labelframe(displayFrame)334 boxDisplay.grid(row=1, column=0, pady=20)335 336 #todo: make warning red?337 warning = "WARNING! Any Pok\u00E9mon that previously inhabited chosen boxes in the Gen III save file will be ERASED. It is recommended that you only select empty Gen III boxes."338 warningLabel = ttk.Label(displayFrame, text=warning,339 wraplength=DISP_WIDTH)340 warningLabel.grid(row=2, column=0)341 navFrame = Nav(baseFrame, root.prevPage, nextPage)342 navFrame.grid(row=1, column=0, sticky='we')343 return (baseFrame, 'Box Selection', {'sticky':'nsew'})344def overwriteWindow(root):345 '''Creates the window for deciding to overwrite or not.'''346 def toggle(*args): 347 setState(choice.get(), 'disabled', [gen2Label, gen3Label,348 gen2Button, gen3Button,349 gen2Entry, gen3Entry])350 setState(not choice.get(), 'disabled', [warningLabel])351 if not choice.get() and (gen2Text.get() == '' or gen3Text.get() == ''):352 navFrame.disable('next', True)353 else:354 navFrame.disable('next', False)355 def gen2Dialog():356 askSave = filedialog.asksaveasfilename357 file = askSave(title='Gen II Save File', initialdir=root.dir,358 filetypes=[('GB Save', '.sav'), ('All Files', '.*')],359 defaultextension='.sav')360 if file != '':361 gen2Text.set(file)362 gen2Entry.after_idle(gen2Entry.xview_moveto, 1)363 root.dir = getDir(file)364 def gen3Dialog():365 askSave = filedialog.asksaveasfilename366 file = askSave(title='Gen III Save File', initialdir=root.dir,367 filetypes=[('GBA Save', '.sav'), ('All Files', '.*')],368 defaultextension='.sav')369 if file != '':370 gen3Text.set(file)371 gen3Entry.after_idle(gen3Entry.xview_moveto, 1)372 root.dir = getDir(file)373 def nextPage():374 global newGen2, newGen3, oldGen2, oldGen3375 if choice.get():376 newGen2 = oldGen2377 newGen3 = oldGen3378 else:379 newGen2 = gen2Entry.get()380 newGen3 = gen3Entry.get()381 root.nextPage()382 baseFrame = ttk.Frame(root)383 baseFrame.rowconfigure(0, weight=1)384 baseFrame.columnconfigure(0, weight=1)385 386 387 mainFrame = ttk.Frame(baseFrame, padding=MAIN_PAD)388 mainFrame.grid(row=0, column=0, sticky='ns')389 mainFrame.rowconfigure(0, weight=2)390 mainFrame.rowconfigure(3, weight=1)391 instrText = 'Select whether to overwrite the original save files, or to create new save files.'392 instrLabel = ttk.Label(mainFrame, text=instrText)393 instrLabel.grid(row=0, column=0)394 choiceFrame = ttk.Frame(mainFrame)395 choiceFrame.grid(row=1, column=0)396 choice = BooleanVar(value=True)397 choice1Radio = ttk.Radiobutton(choiceFrame, text='Overwrite',398 variable=choice, command=toggle,399 value=True)400 choice1Radio.grid(row=0, column=0, pady=5, sticky='w')401 warningText = 'WARNING! Once new data is created, this program can not recover old save data.'402 warningLabel = ttk.Label(choiceFrame, text=warningText, wraplength=300)403 warningLabel.grid(row=1, column=0, pady=5)404 405 choice2Radio = ttk.Radiobutton(choiceFrame, text='Do not overwrite',406 variable=choice, command=toggle,407 value=False)408 choice2Radio.grid(row=2, column=0, pady=5, sticky='w')409 pickerFrame = ttk.Frame(mainFrame)410 pickerFrame.grid(row=2, column=0)411 gen2Label = ttk.Label(pickerFrame, text='New Gen II file:')412 gen2Label.grid(row=0, column=0, columnspan=2)413 414 gen2Button = ttk.Button(pickerFrame, text='To...', command=gen2Dialog)415 gen2Button.grid(row=1, column=0, sticky='e', padx=5, pady=5)416 gen2Text = StringVar(pickerFrame)417 gen2Text.trace('w', toggle)418 gen2Entry = ttk.Entry(pickerFrame, textvariable=gen2Text, state='readonly')419 gen2Entry.grid(row=1, column=1, sticky='w', padx=5, pady=5)420 gen3Label = ttk.Label(pickerFrame, text='New Gen III file:')421 gen3Label.grid(row=2, column=0, columnspan=2)422 423 gen3Button = ttk.Button(pickerFrame, text='To...', command=gen3Dialog)424 gen3Button.grid(row=3, column=0, sticky='e', padx=5, pady=5)425 gen3Text = StringVar(pickerFrame)426 gen3Text.trace('w', toggle)427 gen3Entry = ttk.Entry(pickerFrame, textvariable=gen3Text, state='readonly')428 gen3Entry.grid(row=3, column=1, sticky='w', padx=5, pady=5)429 #todo: make sure user doesn't put the same file for both entries430 fillerFrame = ttk.Frame(mainFrame)431 fillerFrame.grid(row=3, column=0, sticky='ns')432 navFrame = Nav(baseFrame, root.prevPage, nextPage)433 navFrame.grid(row=1, column=0, sticky='we')434 if debug:435 gen2Text.set('C:/Users/Sidnoea/Documents/GitHub/pokeBridge/New Gen 2.sav')436 gen3Text.set('C:/Users/Sidnoea/Documents/GitHub/pokeBridge/New Gen 3.sav')437 choice.set(False)438 toggle()439 return (baseFrame, 'Overwrite?', {'sticky':'nsew'})440#todo: flesh this out441def confirmWindow(root):442 '''Displays the confirmation page.'''443 def nextPage():444 '''Brings up the transfer window, initiates the transfer, goes to the445 finalization window when done.'''446 from pokeBridge import transfer447 global oldGen2, newGen2, oldGen3, newGen3448 global oldBoxNums, newBoxNums, newGame, language, gender449 450 root.nextPage()451 transfer(oldGen2, newGen2, oldGen3, newGen3, oldBoxNums, newBoxNums,452 newGame, language, gender)453 root.nextPage()454 baseFrame = ttk.Frame(root)455 baseFrame.rowconfigure(0, weight=1)456 baseFrame.columnconfigure(0, weight=1)457 458 mainFrame = ttk.Frame(baseFrame)459 mainFrame.grid(row=0, column=0, sticky='nsew')460 mainFrame.rowconfigure(0, weight=1)461 mainFrame.columnconfigure(0, weight=1)462 ttk.Label(mainFrame, text='placeholder text').grid()463 navFrame = Nav(baseFrame, root.prevPage, nextPage)464 navFrame.grid(row=1, column=0, sticky='sew')465 return (baseFrame, 'Confirmation', {'sticky':'nsew'})466def transferWindow(root):467 '''Makes the transfer window.'''468 baseFrame = ttk.Frame(root)469 baseFrame.rowconfigure(0, weight=1)470 baseFrame.columnconfigure(0, weight=1)471 ttk.Label(baseFrame, text='Transferring...').grid()472 473 return (baseFrame, 'Transferring...', {'sticky':'nsew'})474def doneWindow(root):475 '''Makes the succeeded/failed window.'''476 baseFrame = ttk.Frame(root)477 baseFrame.rowconfigure(0, weight=1)478 baseFrame.columnconfigure(0, weight=1)479 ttk.Label(baseFrame, text='Done').grid()480 return (baseFrame, 'Transfer Complete', {'sticky':'nsew'})481def nameHandler(name, message):482 '''Takes a string name and character, provides an interface for correcting483 the illegal name, returns a new legal string name.'''484 #todo: create a proper validate method485 def destroy(*args):486 root.destroy()487 root = Toplevel()488 root.title('Bad Name')489 root.resizable(False, False)490 root.after(100, root.focus_force) #todo: temp?491 mainFrame = ttk.Frame(root, padding=MAIN_PAD)492 mainFrame.grid(column=0, row=0, sticky='nwes')493 newname = StringVar(value=name)494 nameEntry = ttk.Entry(mainFrame, textvariable=newname)495 nameEntry.grid(row=1, sticky='we')496 ttk.Label(mainFrame, text=message).grid(row=0)497 for child in mainFrame.winfo_children():498 child.grid(padx=5, pady=5)499 nameEntry.after(100, nameEntry.focus) #todo: temp?500 root.bind('<Return>', destroy)501 root.wait_window()502 #todo: disable the ability to close the window instead? add abort option?503 if len(newname.get()) < 1:504 return nameHandler(name, message)505 else:...

Full Screen

Full Screen

talib_indicators.py

Source:talib_indicators.py Github

copy

Full Screen

...29 #print('PLEASE install TALIB to call these methods')30def AD(DataFrame):31 res = talib.AD(DataFrame.high.values, DataFrame.low.values,32 DataFrame.close.values, DataFrame.volume.values)33 return pd.DataFrame({'AD': res}, index=DataFrame.index)34def ADOSC(DataFrame, N1=3, N2=10):35 res = talib.ADOSC(DataFrame.high.values, DataFrame.low.values,36 DataFrame.close.values, DataFrame.volume.values, N1, N2)37 return pd.DataFrame({'ADOSC': res}, index=DataFrame.index)38def ADX(DataFrame, N=14):39 res = talib.ADX(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)40 return pd.DataFrame({'ADX': res}, index=DataFrame.index)41def ADXR(DataFrame, N=14):42 res = talib.ADXR(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)43 return pd.DataFrame({'ADXR': res}, index=DataFrame.index)44def AROON(DataFrame, N=14):45 """阿隆指标46 47 Arguments:48 DataFrame {[type]} -- [description]49 50 Keyword Arguments:51 N {int} -- [description] (default: {14})52 53 Returns:54 [type] -- [description]55 """56 ar_up, ar_down = talib.AROON(DataFrame.high.values, DataFrame.low.values, N)57 return pd.DataFrame({'AROON_UP': ar_up,'AROON_DOWN': ar_down}, index=DataFrame.index)58def AROONOSC(DataFrame, N=14):59 res = talib.AROONOSC(DataFrame.high.values, DataFrame.low.values, N)60 return pd.DataFrame({'AROONOSC': res}, index=DataFrame.index)61def ATR(DataFrame, N=14):62 res = talib.ATR(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)63 return pd.DataFrame({'ATR': res}, index=DataFrame.index)64def AVGPRICE(DataFrame):65 res = talib.AVGPRICE(DataFrame.open.values, DataFrame.high.values,66 DataFrame.low.values, DataFrame.close.values)67 return pd.DataFrame({'AVGPRICE': res}, index=DataFrame.index)68def BOP(DataFrame):69 res = talib.BOP(DataFrame.open.values, DataFrame.high.values,70 DataFrame.low.values, DataFrame.close.values)71 return pd.DataFrame({'BOP': res}, index=DataFrame.index)72def CCI(DataFrame, N=14):73 res = talib.CCI(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)74 return pd.DataFrame({'CCI': res}, index=DataFrame.index)75def CDL2CROWS(DataFrame):76 res = talib.CDL2CROWS(DataFrame.open.values, DataFrame.high.values,77 DataFrame.low.values, DataFrame.close.values)78 return pd.DataFrame({'CDL2CROWS': res}, index=DataFrame.index)79def CDL3BLACKCROWS(DataFrame):80 res = talib.CDL3BLACKCROWS(81 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)82 return pd.DataFrame({'CDL3BLACKCROWS': res}, index=DataFrame.index)83def CDL3INSIDE(DataFrame):84 res = talib.CDL3INSIDE(85 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)86 return pd.DataFrame({'CDL3INSIDE': res}, index=DataFrame.index)87def CDL3LINESTRIKE(DataFrame):88 res = talib.CDL3LINESTRIKE(89 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)90 return pd.DataFrame({'CDL3LINESTRIKE': res}, index=DataFrame.index)91def CDL3OUTSIDE(DataFrame):92 res = talib.CDL3OUTSIDE(93 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)94 return pd.DataFrame({'CDL3OUTSIDE': res}, index=DataFrame.index)95def CDL3STARSINSOUTH(DataFrame):96 res = talib.CDL3STARSINSOUTH(97 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)98 return pd.DataFrame({'CDL3STARSINSOUTH': res}, index=DataFrame.index)99def CDL3WHITESOLDIERS(DataFrame):100 res = talib.CDL3WHITESOLDIERS(101 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)102 return pd.DataFrame({'CDL3WHITESOLDIERS': res}, index=DataFrame.index)103def CDLABANDONEDBABY(DataFrame):104 res = talib.CDLABANDONEDBABY(105 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)106 return pd.DataFrame({'CDLABANDONEDBABY': res}, index=DataFrame.index)107def CDLADVANCEBLOCK(DataFrame):108 res = talib.CDLADVANCEBLOCK(109 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)110 return pd.DataFrame({'CDLADVANCEBLOCK': res}, index=DataFrame.index)111def CDLBELTHOLD(DataFrame):112 res = talib.CDLBELTHOLD(113 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)114 return pd.DataFrame({'CDLBELTHOLD': res}, index=DataFrame.index)115def CDLBREAKAWAY(DataFrame):116 res = talib.CDLBREAKAWAY(117 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)118 return pd.DataFrame({'CDLBREAKAWAY': res}, index=DataFrame.index)119def CDLCLOSINGMARUBOZU(DataFrame):120 """121 Closing Marubozu (Pattern Recognition)122 Arguments:123 DataFrame {[type]} -- [description]124 """125 res = talib.CDLCLOSINGMARUBOZU(126 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)127 return pd.DataFrame({'CDLCLOSINGMARUBOZU': res}, index=DataFrame.index)128def CDLCONCEALBABYSWALL(DataFrame):129 res = talib.CDLCONCEALBABYSWALL(130 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)131 return pd.DataFrame({'CDLCONCEALBABYSWALL': res}, index=DataFrame.index)132def CDLCOUNTERATTACK(DataFrame):133 res = talib.CDLCOUNTERATTACK(134 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)135 return pd.DataFrame({'CDLCOUNTERATTACK': res}, index=DataFrame.index)136def CDLDARKCLOUDCOVER(DataFrame):137 res = talib.CDLDARKCLOUDCOVER(138 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)139 return pd.DataFrame({'CDLDARKCLOUDCOVER': res}, index=DataFrame.index)140def CDLDOJI(DataFrame):141 res = talib.CDLDOJI(DataFrame.open.values, DataFrame.high.values,142 DataFrame.low.values, DataFrame.close.values)143 return pd.DataFrame({'CDLDOJI': res}, index=DataFrame.index)144def CDLDOJISTAR(DataFrame):145 res = talib.CDLDOJISTAR(146 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)147 return pd.DataFrame({'CDLDOJISTAR': res}, index=DataFrame.index)148def CDLDRAGONFLYDOJI(DataFrame):149 res = talib.CDLDRAGONFLYDOJI(150 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)151 return pd.DataFrame({'CDLDRAGONFLYDOJI': res}, index=DataFrame.index)152def CDLENGULFING(DataFrame):153 res = talib.CDLENGULFING(154 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)155 return pd.DataFrame({'CDLENGULFING': res}, index=DataFrame.index)156def CDLEVENINGDOJISTAR(DataFrame):157 res = talib.CDLEVENINGDOJISTAR(158 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)159 return pd.DataFrame({'CDLEVENINGDOJISTAR': res}, index=DataFrame.index)160def CDLEVENINGSTAR(DataFrame):161 res = talib.CDLEVENINGSTAR(162 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)163 return pd.DataFrame({'CDLEVENINGSTAR': res}, index=DataFrame.index)164def CDLGAPSIDESIDEWHITE(DataFrame):165 res = talib.CDLGAPSIDESIDEWHITE(166 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)167 return pd.DataFrame({'CDLGAPSIDESIDEWHITE': res}, index=DataFrame.index)168def CDLGRAVESTONEDOJI(DataFrame):169 res = talib.CDLGRAVESTONEDOJI(170 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)171 return pd.DataFrame({'CDLGRAVESTONEDOJI': res}, index=DataFrame.index)172def CDLHAMMER(DataFrame):173 res = talib.CDLHAMMER(DataFrame.open.values, DataFrame.high.values,174 DataFrame.low.values, DataFrame.close.values)175 return pd.DataFrame({'CDLHAMMER': res}, index=DataFrame.index)176def CDLHANGINGMAN(DataFrame):177 res = talib.CDLHANGINGMAN(178 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)179 return pd.DataFrame({'CDLHANGINGMAN': res}, index=DataFrame.index)180def CDLHARAMI(DataFrame):181 res = talib.CDLHARAMI(DataFrame.open.values, DataFrame.high.values,182 DataFrame.low.values, DataFrame.close.values)183 return pd.DataFrame({'CDLHARAMI': res}, index=DataFrame.index)184def CDLHARAMICROSS(DataFrame):185 res = talib.CDLHARAMICROSS(186 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)187 return pd.DataFrame({'CDLHARAMICROSS': res}, index=DataFrame.index)188def CDLHIGHWAVE(DataFrame):189 res = talib.CDLHIGHWAVE(190 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)191 return pd.DataFrame({'CDLHIGHWAVE': res}, index=DataFrame.index)192def CDLHIKKAKE(DataFrame):193 res = talib.CDLHIKKAKE(DataFrame.open.values, DataFrame.high.values,194 DataFrame.low.values, DataFrame.close.values)195 return pd.DataFrame({'CDLHIKKAKE': res}, index=DataFrame.index)196def CDLHIKKAKEMOD(DataFrame):197 res = talib.CDLHIKKAKEMOD(198 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)199 return pd.DataFrame({'CDLHIKKAKEMOD': res}, index=DataFrame.index)200def CDLHOMINGPIGEON(DataFrame):201 res = talib.CDLHOMINGPIGEON(202 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)203 return pd.DataFrame({'CDLHOMINGPIGEON': res}, index=DataFrame.index)204def CDLIDENTICAL3CROWS(DataFrame):205 res = talib.CDLIDENTICAL3CROWS(206 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)207 return pd.DataFrame({'CDLIDENTICAL3CROWS': res}, index=DataFrame.index)208def CDLINNECK(DataFrame):209 res = talib.CDLINNECK(DataFrame.open.values, DataFrame.high.values,210 DataFrame.low.values, DataFrame.close.values)211 return pd.DataFrame({'CDLINNECK': res}, index=DataFrame.index)212def CDLINVERTEDHAMMER(DataFrame):213 res = talib.CDLINVERTEDHAMMER(214 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)215 return pd.DataFrame({'CDLINVERTEDHAMMER': res}, index=DataFrame.index)216def CDLKICKING(DataFrame):217 res = talib.CDLKICKING(DataFrame.open.values, DataFrame.high.values,218 DataFrame.low.values, DataFrame.close.values)219 return pd.DataFrame({'CDLKICKING': res}, index=DataFrame.index)220def CDLKICKINGBYLENGTH(DataFrame):221 res = talib.CDLKICKINGBYLENGTH(222 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)223 return pd.DataFrame({'CDLKICKINGBYLENGTH': res}, index=DataFrame.index)224def CDLLADDERBOTTOM(DataFrame):225 res = talib.CDLLADDERBOTTOM(226 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)227 return pd.DataFrame({'CDLLADDERBOTTOM': res}, index=DataFrame.index)228def CDLLONGLEGGEDDOJI(DataFrame):229 res = talib.CDLLONGLEGGEDDOJI(230 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)231 return pd.DataFrame({'CDLLONGLEGGEDDOJI': res}, index=DataFrame.index)232def CDLLONGLINE(DataFrame):233 res = talib.CDLLONGLINE(234 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)235 return pd.DataFrame({'CDLLONGLINE': res}, index=DataFrame.index)236def CDLMARUBOZU(DataFrame):237 res = talib.CDLMARUBOZU(238 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)239 return pd.DataFrame({'CDLMARUBOZU': res}, index=DataFrame.index)240def CDLMATCHINGLOW(DataFrame):241 res = talib.CDLMATCHINGLOW(242 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)243 return pd.DataFrame({'CDLMATCHINGLOW': res}, index=DataFrame.index)244def CDLMATHOLD(DataFrame):245 res = talib.CDLMATHOLD(DataFrame.open.values, DataFrame.high.values,246 DataFrame.low.values, DataFrame.close.values)247 return pd.DataFrame({'CDLMATHOLD': res}, index=DataFrame.index)248def CDLMORNINGDOJISTAR(DataFrame):249 res = talib.CDLMORNINGDOJISTAR(250 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)251 return pd.DataFrame({'CDLMORNINGDOJISTAR': res}, index=DataFrame.index)252def CDLMORNINGSTAR(DataFrame):253 res = talib.CDLMORNINGSTAR(254 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)255 return pd.DataFrame({'CDLMORNINGSTAR': res}, index=DataFrame.index)256def CDLONNECK(DataFrame):257 res = talib.CDLONNECK(DataFrame.open.values, DataFrame.high.values,258 DataFrame.low.values, DataFrame.close.values)259 return pd.DataFrame({'CDLONNECK': res}, index=DataFrame.index)260def CDLPIERCING(DataFrame):261 res = talib.CDLPIERCING(262 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)263 return pd.DataFrame({'CDLPIERCING': res}, index=DataFrame.index)264def CDLRICKSHAWMAN(DataFrame):265 res = talib.CDLRICKSHAWMAN(266 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)267 return pd.DataFrame({'CDLRICKSHAWMAN': res}, index=DataFrame.index)268def CDLRISEFALL3METHODS(DataFrame):269 res = talib.CDLRISEFALL3METHODS(270 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)271 return pd.DataFrame({'CDLRISEFALL3METHODS': res}, index=DataFrame.index)272def CDLSEPARATINGLINES(DataFrame):273 res = talib.CDLSEPARATINGLINES(274 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)275 return pd.DataFrame({'CDLSEPARATINGLINES': res}, index=DataFrame.index)276def CDLSHOOTINGSTAR(DataFrame):277 res = talib.CDLSHOOTINGSTAR(278 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)279 return pd.DataFrame({'CDLSHOOTINGSTAR': res}, index=DataFrame.index)280def CDLSHORTLINE(DataFrame):281 res = talib.CDLSHORTLINE(282 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)283 return pd.DataFrame({'CDLSHORTLINE': res}, index=DataFrame.index)284def CDLSPINNINGTOP(DataFrame):285 res = talib.CDLSPINNINGTOP(286 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)287 return pd.DataFrame({'CDLSPINNINGTOP': res}, index=DataFrame.index)288def CDLSTALLEDPATTERN(DataFrame):289 res = talib.CDLSTALLEDPATTERN(290 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)291 return pd.DataFrame({'CDLSTALLEDPATTERN': res}, index=DataFrame.index)292def CDLSTICKSANDWICH(DataFrame):293 res = talib.CDLSTICKSANDWICH(294 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)295 return pd.DataFrame({'CDLSTICKSANDWICH': res}, index=DataFrame.index)296def CDLTAKURI(DataFrame):297 res = talib.CDLTAKURI(DataFrame.open.values, DataFrame.high.values,298 DataFrame.low.values, DataFrame.close.values)299 return pd.DataFrame({'CDLTAKURI': res}, index=DataFrame.index)300def CDLTASUKIGAP(DataFrame):301 res = talib.CDLTASUKIGAP(302 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)303 return pd.DataFrame({'CDLTASUKIGAP': res}, index=DataFrame.index)304def CDLTHRUSTING(DataFrame):305 res = talib.CDLTHRUSTING(306 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)307 return pd.DataFrame({'CDLTHRUSTING': res}, index=DataFrame.index)308def CDLTRISTAR(DataFrame):309 res = talib.CDLTRISTAR(DataFrame.open.values, DataFrame.high.values,310 DataFrame.low.values, DataFrame.close.values)311 return pd.DataFrame({'CDLTRISTAR': res}, index=DataFrame.index)312def CDLUNIQUE3RIVER(DataFrame):313 res = talib.CDLUNIQUE3RIVER(314 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)315 return pd.DataFrame({'CDLUNIQUE3RIVER': res}, index=DataFrame.index)316def CDLUPSIDEGAP2CROWS(DataFrame):317 res = talib.CDLUPSIDEGAP2CROWS(318 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)319 return pd.DataFrame({'CDLUPSIDEGAP2CROWS': res}, index=DataFrame.index)320def CDLXSIDEGAP3METHODS(DataFrame):321 res = talib.CDLXSIDEGAP3METHODS(322 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)323 return pd.DataFrame({'CDLXSIDEGAP3METHODS': res}, index=DataFrame.index)324def DX(DataFrame, N=14):325 res = talib.DX(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)326 return pd.DataFrame({'DX': res}, index=DataFrame.index)327# SAR - Parabolic SAR328def SAR(DataFrame, acceleration=0, maximum=0):329 res = talib.SAR(DataFrame.high.values, DataFrame.low.values, acceleration, maximum)330 return pd.DataFrame({'SAR': res}, index=DataFrame.index)331def SAREXT(DataFrame, startvalue=0, offsetonreverse=0, accelerationinitlong=0,332 accelerationlong=0, accelerationmaxlong=0, accelerationinitshort=0, accelerationshort=0, accelerationmaxshort=0):333 res = talib.SAREXT(DataFrame.high.values, DataFrame.low.values,334 startvalue, offsetonreverse, accelerationinitlong, accelerationlong, accelerationmaxlong,335 accelerationinitshort, accelerationshort, accelerationmaxshort)336 return pd.DataFrame({'SAREXT': res}, index=DataFrame.index)337def STOCH(DataFrame, fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0):338 slowk, slowd = talib.STOCH(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values,339 fastk_period, slowk_period, slowk_matype, slowd_period, slowd_matype)340 return pd.DataFrame({'STOCH_SLOWK': slowk, 'STOCH_SLOWD': slowd}, index=DataFrame.index)341def STOCHF(DataFrame, fastk_period=5, fastd_period=3, fastd_matype=0):342 fastk, fastd = talib.STOCHF(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values,343 fastk_period, fastd_period, fastd_matype)...

Full Screen

Full Screen

animation_file_conversion_helpers.py

Source:animation_file_conversion_helpers.py Github

copy

Full Screen

1# Copyright (c) 2022 Boston Dynamics, Inc. All rights reserved.2#3# Downloading, reproducing, distributing or otherwise using the SDK Software4# is subject to the terms and conditions of the Boston Dynamics Software5# Development Kit License (20191101-BDSDK-SL).6"""A set helpers which convert specific lines from an animation7file into the animation-specific protobuf messages.8NOTE: All of these helpers are to convert specific values read from a `cha`9file into fields within the choreography_sequence_pb2.Animation protobuf10message. They are used by the animation_file_to_proto.py file.11"""12from bosdyn.api.spot import (choreography_sequence_pb2, choreography_service_pb2,13 choreography_service_pb2_grpc)14def start_time_handler(val, animation_frame):15 animation_frame.time = val16 return animation_frame17def fl_angles_handler(vals, animation_frame):18 animation_frame.legs.fl.joint_angles.hip_x = vals[0]19 animation_frame.legs.fl.joint_angles.hip_y = vals[1]20 animation_frame.legs.fl.joint_angles.knee = vals[2]21 return animation_frame22def fr_angles_handler(vals, animation_frame):23 animation_frame.legs.fr.joint_angles.hip_x = vals[0]24 animation_frame.legs.fr.joint_angles.hip_y = vals[1]25 animation_frame.legs.fr.joint_angles.knee = vals[2]26 return animation_frame27def hl_angles_handler(vals, animation_frame):28 animation_frame.legs.hl.joint_angles.hip_x = vals[0]29 animation_frame.legs.hl.joint_angles.hip_y = vals[1]30 animation_frame.legs.hl.joint_angles.knee = vals[2]31 return animation_frame32def hr_angles_handler(vals, animation_frame):33 animation_frame.legs.hr.joint_angles.hip_x = vals[0]34 animation_frame.legs.hr.joint_angles.hip_y = vals[1]35 animation_frame.legs.hr.joint_angles.knee = vals[2]36 return animation_frame37def fl_pos_handler(vals, animation_frame):38 animation_frame.legs.fl.foot_pos.x.value = vals[0]39 animation_frame.legs.fl.foot_pos.y.value = vals[1]40 animation_frame.legs.fl.foot_pos.z.value = vals[2]41 return animation_frame42def fr_pos_handler(vals, animation_frame):43 animation_frame.legs.fr.foot_pos.x.value = vals[0]44 animation_frame.legs.fr.foot_pos.y.value = vals[1]45 animation_frame.legs.fr.foot_pos.z.value = vals[2]46 return animation_frame47def hl_pos_handler(vals, animation_frame):48 animation_frame.legs.hl.foot_pos.x.value = vals[0]49 animation_frame.legs.hl.foot_pos.y.value = vals[1]50 animation_frame.legs.hl.foot_pos.z.value = vals[2]51 return animation_frame52def hr_pos_handler(vals, animation_frame):53 animation_frame.legs.hr.foot_pos.x.value = vals[0]54 animation_frame.legs.hr.foot_pos.y.value = vals[1]55 animation_frame.legs.hr.foot_pos.z.value = vals[2]56 return animation_frame57def gripper_handler(val, animation_frame):58 animation_frame.gripper.gripper_angle.value = val59 return animation_frame60def fl_contact_handler(val, animation_frame):61 animation_frame.legs.fl.stance.value = val62 return animation_frame63def fr_contact_handler(val, animation_frame):64 animation_frame.legs.fr.stance.value = val65 return animation_frame66def hl_contact_handler(val, animation_frame):67 animation_frame.legs.hl.stance.value = val68 return animation_frame69def hr_contact_handler(val, animation_frame):70 animation_frame.legs.hr.stance.value = val71 return animation_frame72def sh0_handler(val, animation_frame):73 animation_frame.arm.joint_angles.shoulder_0.value = val74 return animation_frame75def sh1_handler(val, animation_frame):76 animation_frame.arm.joint_angles.shoulder_1.value = val77 return animation_frame78def el0_handler(val, animation_frame):79 animation_frame.arm.joint_angles.elbow_0.value = val80 return animation_frame81def el1_handler(val, animation_frame):82 animation_frame.arm.joint_angles.elbow_1.value = val83 return animation_frame84def wr0_handler(val, animation_frame):85 animation_frame.arm.joint_angles.wrist_0.value = val86 return animation_frame87def wr1_handler(val, animation_frame):88 animation_frame.arm.joint_angles.wrist_1.value = val89 return animation_frame90def fl_hx_handler(val, animation_frame):91 animation_frame.legs.fl.joint_angles.hip_x = val92 return animation_frame93def fl_hy_handler(val, animation_frame):94 animation_frame.legs.fl.joint_angles.hip_y = val95 return animation_frame96def fl_kn_handler(val, animation_frame):97 animation_frame.legs.fl.joint_angles.knee = val98 return animation_frame99def fr_hx_handler(val, animation_frame):100 animation_frame.legs.fr.joint_angles.hip_x = val101 return animation_frame102def fr_hy_handler(val, animation_frame):103 animation_frame.legs.fr.joint_angles.hip_y = val104 return animation_frame105def fr_kn_handler(val, animation_frame):106 animation_frame.legs.fr.joint_angles.knee = val107 return animation_frame108def hl_hx_handler(val, animation_frame):109 animation_frame.legs.hl.joint_angles.hip_x = val110 return animation_frame111def hl_hy_handler(val, animation_frame):112 animation_frame.legs.hl.joint_angles.hip_y = val113 return animation_frame114def hl_kn_handler(val, animation_frame):115 animation_frame.legs.hl.joint_angles.knee = val116 return animation_frame117def hr_hx_handler(val, animation_frame):118 animation_frame.legs.hr.joint_angles.hip_x = val119 return animation_frame120def hr_hy_handler(val, animation_frame):121 animation_frame.legs.hr.joint_angles.hip_y = val122 return animation_frame123def hr_kn_handler(val, animation_frame):124 animation_frame.legs.hr.joint_angles.knee = val125 return animation_frame126def fl_x_handler(val, animation_frame):127 animation_frame.legs.fl.foot_pos.x.value = val128 return animation_frame129def fl_y_handler(val, animation_frame):130 animation_frame.legs.fl.foot_pos.y.value = val131 return animation_frame132def fl_z_handler(val, animation_frame):133 animation_frame.legs.fl.foot_pos.z.value = val134 return animation_frame135def fr_x_handler(val, animation_frame):136 animation_frame.legs.fr.foot_pos.x.value = val137 return animation_frame138def fr_y_handler(val, animation_frame):139 animation_frame.legs.fr.foot_pos.y.value = val140 return animation_frame141def fr_z_handler(val, animation_frame):142 animation_frame.legs.fr.foot_pos.z.value = val143 return animation_frame144def hl_x_handler(val, animation_frame):145 animation_frame.legs.hl.foot_pos.x.value = val146 return animation_frame147def hl_y_handler(val, animation_frame):148 animation_frame.legs.hl.foot_pos.y.value = val149 return animation_frame150def hl_z_handler(val, animation_frame):151 animation_frame.legs.hl.foot_pos.z.value = val152 return animation_frame153def hr_x_handler(val, animation_frame):154 animation_frame.legs.hr.foot_pos.x.value = val155 return animation_frame156def hr_y_handler(val, animation_frame):157 animation_frame.legs.hr.foot_pos.y.value = val158 return animation_frame159def hr_z_handler(val, animation_frame):160 animation_frame.legs.hr.foot_pos.z.value = val161 return animation_frame162def body_x_handler(val, animation_frame):163 animation_frame.body.body_pos.x.value = val164 return animation_frame165def body_y_handler(val, animation_frame):166 animation_frame.body.body_pos.y.value = val167 return animation_frame168def body_z_handler(val, animation_frame):169 animation_frame.body.body_pos.z.value = val170 return animation_frame171def com_x_handler(val, animation_frame):172 animation_frame.body.com_pos.x.value = val173 return animation_frame174def com_y_handler(val, animation_frame):175 animation_frame.body.com_pos.y.value = val176 return animation_frame177def com_z_handler(val, animation_frame):178 animation_frame.body.com_pos.z.value = val179 return animation_frame180def body_quat_x_handler(val, animation_frame):181 animation_frame.body.quaternion.x = val182 return animation_frame183def body_quat_y_handler(val, animation_frame):184 animation_frame.body.quaternion.y = val185 return animation_frame186def body_quat_z_handler(val, animation_frame):187 animation_frame.body.quaternion.z = val188 return animation_frame189def body_quat_w_handler(val, animation_frame):190 animation_frame.body.quaternion.w = val191 return animation_frame192def body_roll_handler(val, animation_frame):193 animation_frame.body.euler_angles.roll.value = val194 return animation_frame195def body_pitch_handler(val, animation_frame):196 animation_frame.body.euler_angles.pitch.value = val197 return animation_frame198def body_yaw_handler(val, animation_frame):199 animation_frame.body.euler_angles.yaw.value = val200 return animation_frame201def body_pos_handler(vals, animation_frame):202 animation_frame.body.body_pos.x.value = vals[0]203 animation_frame.body.body_pos.y.value = vals[1]204 animation_frame.body.body_pos.z.value = vals[2]205 return animation_frame206def com_pos_handler(vals, animation_frame):207 animation_frame.body.com_pos.x.value = vals[0]208 animation_frame.body.com_pos.y.value = vals[1]209 animation_frame.body.com_pos.z.value = vals[2]210 return animation_frame211def body_euler_rpy_angles_handler(vals, animation_frame):212 animation_frame.body.euler_angles.roll.value = vals[0]213 animation_frame.body.euler_angles.pitch.value = vals[1]214 animation_frame.body.euler_angles.yaw.value = vals[2]215 return animation_frame216def body_quaternion_xyzw_handler(vals, animation_frame):217 animation_frame.body.quaternion.x = vals[0]218 animation_frame.body.quaternion.y = vals[1]219 animation_frame.body.quaternion.z = vals[2]220 animation_frame.body.quaternion.w = vals[3]221 return animation_frame222def body_quaternion_wxyz_handler(vals, animation_frame):223 animation_frame.body.quaternion.x = vals[1]224 animation_frame.body.quaternion.y = vals[2]225 animation_frame.body.quaternion.z = vals[3]226 animation_frame.body.quaternion.w = vals[0]227 return animation_frame228def leg_angles_handler(vals, animation_frame):229 animation_frame.legs.fl.joint_angles.hip_x = vals[0]230 animation_frame.legs.fl.joint_angles.hip_y = vals[1]231 animation_frame.legs.fl.joint_angles.knee = vals[2]232 animation_frame.legs.fr.joint_angles.hip_x = vals[3]233 animation_frame.legs.fr.joint_angles.hip_y = vals[4]234 animation_frame.legs.fr.joint_angles.knee = vals[5]235 animation_frame.legs.hl.joint_angles.hip_x = vals[6]236 animation_frame.legs.hl.joint_angles.hip_y = vals[7]237 animation_frame.legs.hl.joint_angles.knee = vals[8]238 animation_frame.legs.hr.joint_angles.hip_x = vals[9]239 animation_frame.legs.hr.joint_angles.hip_y = vals[10]240 animation_frame.legs.hr.joint_angles.knee = vals[11]241 return animation_frame242def foot_pos_handler(vals, animation_frame):243 animation_frame.legs.fl.foot_pos.x.value = vals[0]244 animation_frame.legs.fl.foot_pos.y.value = vals[1]245 animation_frame.legs.fl.foot_pos.z.value = vals[2]246 animation_frame.legs.fr.foot_pos.x.value = vals[3]247 animation_frame.legs.fr.foot_pos.y.value = vals[4]248 animation_frame.legs.fr.foot_pos.z.value = vals[5]249 animation_frame.legs.hl.foot_pos.x.value = vals[6]250 animation_frame.legs.hl.foot_pos.y.value = vals[7]251 animation_frame.legs.hl.foot_pos.z.value = vals[8]252 animation_frame.legs.hr.foot_pos.x.value = vals[9]253 animation_frame.legs.hr.foot_pos.y.value = vals[10]254 animation_frame.legs.hr.foot_pos.z.value = vals[11]255 return animation_frame256def contact_handler(vals, animation_frame):257 animation_frame.legs.fl.stance.value = vals[0]258 animation_frame.legs.fr.stance.value = vals[1]259 animation_frame.legs.hl.stance.value = vals[2]260 animation_frame.legs.hr.stance.value = vals[3]261 return animation_frame262def arm_joints_handler(vals, animation_frame):263 animation_frame.arm.joint_angles.shoulder_0.value = vals[0]264 animation_frame.arm.joint_angles.shoulder_1.value = vals[1]265 animation_frame.arm.joint_angles.elbow_0.value = vals[2]266 animation_frame.arm.joint_angles.elbow_1.value = vals[3]267 animation_frame.arm.joint_angles.wrist_0.value = vals[4]268 animation_frame.arm.joint_angles.wrist_1.value = vals[5]269 return animation_frame270def hand_x_handler(vals, animation_frame):271 animation_frame.arm.hand_pose.position.x = vals[0]272 return animation_frame273def hand_y_handler(vals, animation_frame):274 animation_frame.arm.hand_pose.position.y = vals[0]275 return animation_frame276def hand_z_handler(vals, animation_frame):277 animation_frame.arm.hand_pose.position.z = vals[0]278 return animation_frame279def hand_quat_x_handler(val, animation_frame):280 animation_frame.arm.hand_pose.quaternion.x = val281 return animation_frame282def hand_quat_y_handler(val, animation_frame):283 animation_frame.arm.hand_pose.quaternion.y = val284 return animation_frame285def hand_quat_z_handler(val, animation_frame):286 animation_frame.arm.hand_pose.quaternion.z = val287 return animation_frame288def hand_quat_w_handler(val, animation_frame):289 animation_frame.arm.hand_pose.quaternion.w = val290 return animation_frame291def hand_roll_handler(val, animation_frame):292 animation_frame.arm.hand_pose.euler_angles.roll.value = val293 return animation_frame294def hand_pitch_handler(val, animation_frame):295 animation_frame.arm.hand_pose.euler_angles.pitch.value = val296 return animation_frame297def hand_yaw_handler(val, animation_frame):298 animation_frame.arm.hand_pose.euler_angles.yaw.value = val299 return animation_frame300def hand_pos_handler(vals, animation_frame):301 animation_frame.arm.hand_pose.position.x.value = vals[0]302 animation_frame.arm.hand_pose.position.y.value = vals[1]303 animation_frame.arm.hand_pose.position.z.value = vals[2]304 return animation_frame305def hand_euler_rpy_angles_handler(vals, animation_frame):306 animation_frame.arm.hand_pose.euler_angles.roll.value = vals[0]307 animation_frame.arm.hand_pose.euler_angles.pitch.value = vals[1]308 animation_frame.arm.hand_pose.euler_angles.yaw.value = vals[2]309 return animation_frame310def hand_quaternion_xyzw_handler(vals, animation_frame):311 animation_frame.arm.hand_pose.quaternion.x = vals[0]312 animation_frame.arm.hand_pose.quaternion.y = vals[1]313 animation_frame.arm.hand_pose.quaternion.z = vals[2]314 animation_frame.arm.hand_pose.quaternion.w = vals[3]315 return animation_frame316def hand_quaternion_wxyz_handler(vals, animation_frame):317 animation_frame.arm.hand_pose.quaternion.x = vals[1]318 animation_frame.arm.hand_pose.quaternion.y = vals[2]319 animation_frame.arm.hand_pose.quaternion.z = vals[3]320 animation_frame.arm.hand_pose.quaternion.w = vals[0]321 return animation_frame322def controls_option(file_line_split, animation):323 for track in file_line_split:324 if track == "legs":325 animation.proto.controls_legs = True326 elif track == "arm":327 animation.proto.controls_arm = True328 elif track == "body":329 animation.proto.controls_body = True330 elif track == "gripper":331 animation.proto.controls_gripper = True332 elif track == "controls":333 continue334 else:335 print("Unknown track name %s" % track)336 return animation337def bpm_option(file_line_split, animation):338 bpm = file_line_split[1]339 animation.bpm = int(bpm)340 return animation341def extendable_option(file_line_split, animation):342 animation.proto.extendable = True343 return animation344def truncatable_option(file_line_split, animation):345 animation.proto.truncatable = True346 return animation347def neutral_start_option(file_line_split, animation):348 animation.proto.neutral_start = True349 return animation350def precise_steps_option(file_line_split, animation):351 animation.proto.precise_steps = True352def precise_timing_option(file_line_split, animation):353 animation.proto.precise_timing = True354def no_looping_option(file_line_split, animation):355 animation.proto.no_looping = True356def arm_required_option(file_line_split, animation):357 animation.proto.arm_required = True358def arm_prohibited_option(file_line_split, animation):359 animation.proto.arm_prohibited = True360def track_swing_trajectories_option(file_line_split, animation):361 animation.proto.track_swing_trajectories = True362 return animation363def assume_zero_roll_and_pitch_option(file_line_split, animation):364 animation.proto.assume_zero_roll_and_pitch = True365 return animation366def track_hand_rt_body_option(file_line_split, animation):367 animation.proto.track_hand_rt_body = True368 return animation369def track_hand_rt_feet_option(file_line_split, animation):370 animation.proto.track_hand_rt_feet = True371 return animation372def arm_playback_option(file_line_split, animation):373 playback = file_line_split[1]374 if playback == "jointspace":375 animation.proto.arm_playback = choreography_sequence_pb2.Animation.ARM_PLAYBACK_JOINTSPACE376 elif playback == "workspace":377 animation.proto.arm_playback = choreography_sequence_pb2.Animation.ARM_PLAYBACK_WORKSPACE378 elif playback == "workspace_dance_frame":379 animation.proto.arm_playback = choreography_sequence_pb2.Animation.ARM_PLAYBACK_WORKSPACE_DANCE_FRAME380 else:381 animation.proto.arm_playback = choreography_sequence_pb2.Animation.ARM_PLAYBACK_DEFAULT382 print("Unknown arm playback option %s" % playback)383 return animation384def display_rgb_option(file_line_split, animation):385 for i in range(1, 3):386 animation.rgb[i - 1] = int(file_line_split[i])387 return animation388def frequency_option(file_line_split, animation):389 freq = file_line_split[1]390 animation.frequency = float(freq)391 return animation392def retime_to_integer_slices_option(file_line_split, animation):393 animation.proto.retime_to_integer_slices = True394 return animation395def description_option(file_line_split, animation):396 description = " ".join(file_line_split[1:])397 description = description.replace('"', '') # remove any quotation marks398 animation.description = description...

Full Screen

Full Screen

frame_helpers.py

Source:frame_helpers.py Github

copy

Full Screen

1# Copyright (c) 2022 Boston Dynamics, Inc. All rights reserved.2#3# Downloading, reproducing, distributing or otherwise using the SDK Software4# is subject to the terms and conditions of the Boston Dynamics Software5# Development Kit License (20191101-BDSDK-SL).6from . import math_helpers7from bosdyn.api import geometry_pb28VISION_FRAME_NAME = "vision"9BODY_FRAME_NAME = "body"10# Note that the frame name for a gravity aligned body frame is "flat_body" to create a shorter11# string identifier.12GRAV_ALIGNED_BODY_FRAME_NAME = "flat_body"13ODOM_FRAME_NAME = "odom"14GROUND_PLANE_FRAME_NAME = "gpe"15HAND_FRAME_NAME = "hand"16UNKNOWN_FRAME_NAME = "unknown"17RAYCAST_FRAME_NAME = "walkto_raycast_intersection"18class Error(Exception):19 pass20class ValidateFrameTreeError(Error):21 pass22class ValidateFrameTreeUnknownFrameError(ValidateFrameTreeError):23 pass24class ValidateFrameTreeCycleError(ValidateFrameTreeError):25 pass26class ValidateFrameTreeDisjointError(ValidateFrameTreeError):27 pass28def validate_frame_tree_snapshot(frame_tree_snapshot):29 """Validates that a FrameTreeSnapshot is well-formed.30 A FrameTreeSnapshot is expected to be a single tree, but poorly written31 services can misuse the syntax to construct other data structures. The32 syntax prevents DAGs from forming, but the data structure could33 Valid FrameTrees must be a single-rooted tree. However, the general format of34 repeated edges may not actually be valid - there could be cycles, disjoint35 trees, or missing edges in the actual data structure.36 Inputs:37 frame_tree_snapshot: A snapshot of the data.38 Returns:39 True if valid40 Raises:41 ValidateFrameTreeError in a number of cases: Empty tree, invalid frame names in the tree, missing transforms42 relating the two nodes, cycles in the tree, the tree is actually a DAG, and disconnected trees.43 """44 if not frame_tree_snapshot:45 raise ValueError('No frame_tree_snapshot')46 # For every entry in the map, see if we can walk to the root without47 # cycles. The root should also be identical for each node48 def _walk_up_tree(frame_name):49 cur_frame_name = frame_name50 visited_frames = set()51 visited_frames.add(cur_frame_name)52 while True:53 edge = frame_tree_snapshot.child_to_parent_edge_map.get(cur_frame_name)54 if not edge:55 raise ValidateFrameTreeUnknownFrameError()56 if not edge.parent_frame_name:57 # At the root of the tree58 break59 if edge.parent_frame_name in visited_frames:60 raise ValidateFrameTreeCycleError()61 visited_frames.add(edge.parent_frame_name)62 cur_frame_name = edge.parent_frame_name63 return cur_frame_name64 root = None65 if not frame_tree_snapshot.child_to_parent_edge_map:66 raise ValidateFrameTreeError("Empty edges in FrameTreeSnapshot")67 for frame_name in frame_tree_snapshot.child_to_parent_edge_map:68 if not frame_name:69 raise ValidateFrameTreeError("Empty child frame name")70 cur_root = _walk_up_tree(frame_name)71 if not root:72 root = cur_root73 else:74 if not cur_root == root:75 raise ValidateFrameTreeDisjointError()76 return True77def get_a_tform_b(frame_tree_snapshot, frame_a, frame_b, validate=True):78 """Get the SE(3) pose representing the transform between frame_a and frame_b.79 Using frame_tree_snapshot, find the math_helpers.SE3Pose to transform geometry from80 frame_a's representation to frame_b's.81 Args:82 frame_tree_snapshot (dict) dictionary representing the child_to_parent_edge_map83 frame_a (string)84 frame_b (string)85 validate (bool) if the FrameTreeSnapshot should be checked for a valid tree structure86 Returns:87 math_helpers.SE3Pose between frame_a and frame_b if they exist in the tree. None otherwise.88 """89 if validate:90 validate_frame_tree_snapshot(frame_tree_snapshot)91 if frame_a not in frame_tree_snapshot.child_to_parent_edge_map:92 return None93 if frame_b not in frame_tree_snapshot.child_to_parent_edge_map:94 return None95 def _list_parent_edges(leaf_frame):96 parent_edges = []97 cur_frame = leaf_frame98 while True:99 parent_edge = frame_tree_snapshot.child_to_parent_edge_map.get(cur_frame)100 if not parent_edge.parent_frame_name:101 break102 parent_edges.append(parent_edge)103 cur_frame = parent_edge.parent_frame_name104 return parent_edges105 inverse_edges = _list_parent_edges(frame_a)106 forward_edges = _list_parent_edges(frame_b)107 # Possible optimization: Nearest common ancestor pruning.108 def _accumulate_transforms(parent_edges):109 ret = math_helpers.SE3Pose.from_identity()110 for parent_edge in parent_edges:111 ret = math_helpers.SE3Pose.from_proto(parent_edge.parent_tform_child) * ret112 return ret113 frame_a_tform_root_frame = _accumulate_transforms(inverse_edges).inverse()114 root_frame_tform_frame_b = _accumulate_transforms(forward_edges)115 return frame_a_tform_root_frame * root_frame_tform_frame_b116def get_se2_a_tform_b(frame_tree_snapshot, frame_a, frame_b, validate=True):117 """Get the SE(2) pose representing the transform between frame_a and frame_b.118 Using frame_tree_snapshot, find the math_helpers.SE2Pose to transform geometry from119 frame_a's representation to frame_b's.120 Args:121 frame_tree_snapshot (dict) dictionary representing the child_to_parent_edge_map122 frame_a (string)123 frame_b (string)124 validate (bool) if the FrameTreeSnapshot should be checked for a valid tree structure125 Returns:126 math_helpers.SE2Pose between frame_a and frame_b if they exist in the tree and127 frame a is a gravity aligned frame. None otherwise.128 """129 # Validate that the transform is in a gravity aligned frame based on the string name.130 if not is_gravity_aligned_frame_name(frame_a):131 # Frame A is not gravity aligned, and therefore a_tform_b cannot be converted into132 # an SE(2) pose because it will lose height information.133 return None134 # Get the SE(3) pose from the frame tree snapshot representing the desired transform a_tform_b135 se3_a_tform_b = get_a_tform_b(frame_tree_snapshot, frame_a, frame_b, validate)136 if se3_a_tform_b is None:137 # Failed to find the transformation between frames a and b in the frame tree snapshot.138 return None139 return se3_a_tform_b.get_closest_se2_transform()140def express_se2_velocity_in_new_frame(frame_tree_snapshot, frame_b, frame_c, vel_of_a_in_b,141 validate=True):142 """Convert the SE2 Velocity in frame b to a SE2 Velocity in frame c using143 the frame tree snapshot.144 Args:145 frame_tree_snapshot (dict) dictionary representing the child_to_parent_edge_map146 frame_b (string)147 frame_c (string)148 vel_of_a_in_b (SE2Velocity proto) SE2 Velocity in frame_b149 validate (bool) if the FrameTreeSnapshot should be checked for a valid tree structure150 Returns:151 math_helpers.SE2Velocity velocity_of_a_in_c in frame_c if the frames exist in the tree. None otherwise.152 """153 # Find the SE(3) pose in the frame tree snapshot that represents c_tform_b.154 se3_c_tform_b = get_a_tform_b(frame_tree_snapshot, frame_c, frame_b, validate)155 if se3_c_tform_b is None:156 # If the SE3Pose for c_tform_b does not exist in the frame tree snapshot,157 # then we cannot transform the velocity.158 return None159 # Check that the frame name of frame_c is considered to be a gravity aligned frame.160 if not is_gravity_aligned_frame_name(frame_c):161 # Frame C is not gravity aligned, and therefore c_tform_b cannot be converted into162 # an SE(2) pose because it will lose height information.163 return None164 # Find the closest SE(2) pose for the c_tform_b SE(3) pose found from the snapshot.165 se2_c_tform_b = se3_c_tform_b.get_closest_se2_transform()166 # Transform the velocity into the new frame to get vel_of_a_in_c.167 c_adjoint_b = se2_c_tform_b.to_adjoint_matrix()168 vel_of_a_in_c = math_helpers.transform_se2velocity(c_adjoint_b, vel_of_a_in_b)169 return vel_of_a_in_c170def express_se3_velocity_in_new_frame(frame_tree_snapshot, frame_b, frame_c, vel_of_a_in_b,171 validate=True):172 """Convert the SE(3) Velocity in frame b to an SE(3) Velocity in frame c using173 the frame tree snapshot.174 Args:175 frame_tree_snapshot (dict) dictionary representing the child_to_parent_edge_map176 frame_b (string)177 frame_c (string)178 vel_of_a_in_b (SE3Velocity proto) SE(3) Velocity in frame_b179 validate (bool) if the FrameTreeSnapshot should be checked for a valid tree structure180 Returns:181 math_helpers.SE3Velocity velocity_of_a_in_c in frame_c if the frames exist in the tree. None otherwise.182 """183 # Find the SE(3) pose in the frame tree snapshot that represents c_tform_b.184 se3_c_tform_b = get_a_tform_b(frame_tree_snapshot, frame_c, frame_b, validate)185 if se3_c_tform_b is None:186 # If the SE3Pose for c_tform_b does not exist in the frame tree snapshot,187 # then we cannot transform the velocity.188 return None189 # Transform the velocity into the new frame to get vel_of_a_in_c.190 c_adjoint_b = se3_c_tform_b.to_adjoint_matrix()191 vel_of_a_in_c = math_helpers.transform_se3velocity(c_adjoint_b, vel_of_a_in_b)192 return vel_of_a_in_c193def get_odom_tform_body(frame_tree_snapshot):194 """Get the transformation between "odom" frame and "body" frame from the FrameTreeSnapshot."""195 return get_a_tform_b(frame_tree_snapshot, ODOM_FRAME_NAME, BODY_FRAME_NAME)196def get_vision_tform_body(frame_tree_snapshot):197 """Get the transformation between "vision" frame and "body" frame from the FrameTreeSnapshot."""198 return get_a_tform_b(frame_tree_snapshot, VISION_FRAME_NAME, BODY_FRAME_NAME)199class GenerateTreeError(Error):200 pass201class ChildFrameInTree(GenerateTreeError):202 pass203def add_edge_to_tree(frame_tree_snapshot, parent_tform_child, parent_frame_name, child_frame_name):204 """Appends a child/parent and the transform to the FrameTreeSnapshot.205 Args:206 frame_tree_snapshot (dict) dictionary representing the child_to_parent_edge_map207 parent_tform_child (SE3Pose proto)208 parent_frame_name (string)209 child_frame_name (string)210 """211 if child_frame_name in frame_tree_snapshot:212 raise ChildFrameInTree213 # Can add additional validation checks, such as if the parent frame will make a cycle,214 # or if this will be completely disconnected215 frame_tree_snapshot[child_frame_name] = geometry_pb2.FrameTreeSnapshot.ParentEdge(216 parent_frame_name=parent_frame_name, parent_tform_child=parent_tform_child)217 return frame_tree_snapshot218def get_frame_names(frame_tree_snapshot):219 """Returns a list of all known child or parent frames in the FrameTreeSnapshot."""220 frame_names = []221 for child_frame in frame_tree_snapshot.child_to_parent_edge_map:222 if child_frame not in frame_names:223 frame_names.append(child_frame)224 parent_frame = frame_tree_snapshot.child_to_parent_edge_map[child_frame].parent_frame_name225 if parent_frame not in frame_names:226 frame_names.append(parent_frame)227 return [frame_name for frame_name in frame_names if frame_name != ""]228def is_gravity_aligned_frame_name(frame_name):229 """Checks if the string frame name is a known gravity aligned frame."""230 if frame_name == VISION_FRAME_NAME or frame_name == GRAV_ALIGNED_BODY_FRAME_NAME or frame_name == ODOM_FRAME_NAME:231 return True...

Full Screen

Full Screen

sigproc.py

Source:sigproc.py Github

copy

Full Screen

1# This file includes routines for basic signal processing including framing and computing power spectra.2# Author: James Lyons 20123import numpy4import math5def framesig(sig,frame_len,frame_step,winfunc=lambda x:numpy.ones((x,))):6 """Frame a signal into overlapping frames.7 :param sig: the audio signal to frame.8 :param frame_len: length of each frame measured in samples.9 :param frame_step: number of samples after the start of the previous frame that the next frame should begin.10 :param winfunc: the analysis window to apply to each frame. By default no window is applied. 11 :returns: an array of frames. Size is NUMFRAMES by frame_len.12 """13 slen = len(sig)14 frame_len = int(round(frame_len))15 frame_step = int(round(frame_step))16 if slen <= frame_len: 17 numframes = 118 else:19 numframes = 1 + int(math.ceil((1.0*slen - frame_len)/frame_step))20 21 padlen = int((numframes-1)*frame_step + frame_len)22 23 zeros = numpy.zeros((padlen - slen,))24 padsignal = numpy.concatenate((sig,zeros))25 26 indices = numpy.tile(numpy.arange(0,frame_len),(numframes,1)) + numpy.tile(numpy.arange(0,numframes*frame_step,frame_step),(frame_len,1)).T27 indices = numpy.array(indices,dtype=numpy.int32)28 frames = padsignal[indices]29 win = numpy.tile(winfunc(frame_len),(numframes,1))30 return frames*win31 32 33def deframesig(frames,siglen,frame_len,frame_step,winfunc=lambda x:numpy.ones((x,))):34 """Does overlap-add procedure to undo the action of framesig. 35 :param frames: the array of frames.36 :param siglen: the length of the desired signal, use 0 if unknown. Output will be truncated to siglen samples. 37 :param frame_len: length of each frame measured in samples.38 :param frame_step: number of samples after the start of the previous frame that the next frame should begin.39 :param winfunc: the analysis window to apply to each frame. By default no window is applied. 40 :returns: a 1-D signal.41 """42 frame_len = round(frame_len)43 frame_step = round(frame_step)44 numframes = numpy.shape(frames)[0]45 assert numpy.shape(frames)[1] == frame_len, '"frames" matrix is wrong size, 2nd dim is not equal to frame_len'46 47 indices = numpy.tile(numpy.arange(0,frame_len),(numframes,1)) + numpy.tile(numpy.arange(0,numframes*frame_step,frame_step),(frame_len,1)).T48 indices = numpy.array(indices,dtype=numpy.int32)49 padlen = (numframes-1)*frame_step + frame_len 50 51 if siglen <= 0: siglen = padlen52 53 rec_signal = numpy.zeros((padlen,))54 window_correction = numpy.zeros((padlen,))55 win = winfunc(frame_len)56 57 for i in range(0,numframes):58 window_correction[indices[i,:]] = window_correction[indices[i,:]] + win + 1e-15 #add a little bit so it is never zero59 rec_signal[indices[i,:]] = rec_signal[indices[i,:]] + frames[i,:]60 61 rec_signal = rec_signal/window_correction62 return rec_signal[0:siglen]63 64def magspec(frames,NFFT):65 """Compute the magnitude spectrum of each frame in frames. If frames is an NxD matrix, output will be NxNFFT. 66 :param frames: the array of frames. Each row is a frame.67 :param NFFT: the FFT length to use. If NFFT > frame_len, the frames are zero-padded. 68 :returns: If frames is an NxD matrix, output will be NxNFFT. Each row will be the magnitude spectrum of the corresponding frame.69 """ 70 complex_spec = numpy.fft.rfft(frames,NFFT)71 return numpy.absolute(complex_spec)72 73def powspec(frames,NFFT):74 """Compute the power spectrum of each frame in frames. If frames is an NxD matrix, output will be NxNFFT. 75 :param frames: the array of frames. Each row is a frame.76 :param NFFT: the FFT length to use. If NFFT > frame_len, the frames are zero-padded. 77 :returns: If frames is an NxD matrix, output will be NxNFFT. Each row will be the power spectrum of the corresponding frame.78 """ 79 return 1.0/NFFT * numpy.square(magspec(frames,NFFT))80 81def logpowspec(frames,NFFT,norm=1):82 """Compute the log power spectrum of each frame in frames. If frames is an NxD matrix, output will be NxNFFT. 83 :param frames: the array of frames. Each row is a frame.84 :param NFFT: the FFT length to use. If NFFT > frame_len, the frames are zero-padded. 85 :param norm: If norm=1, the log power spectrum is normalised so that the max value (across all frames) is 1.86 :returns: If frames is an NxD matrix, output will be NxNFFT. Each row will be the log power spectrum of the corresponding frame.87 """ 88 ps = powspec(frames,NFFT);89 ps[ps<=1e-30] = 1e-3090 lps = 10*numpy.log10(ps)91 if norm:92 return lps - numpy.max(lps)93 else:94 return lps95 96def preemphasis(signal,coeff=0.95):97 """perform preemphasis on the input signal.98 99 :param signal: The signal to filter.100 :param coeff: The preemphasis coefficient. 0 is no filter, default is 0.95.101 :returns: the filtered signal.102 """ ...

Full Screen

Full Screen

picklebag.py

Source:picklebag.py Github

copy

Full Screen

1import os2import pickle3import traindata4class FramePickle:5 def __init__(self, pickle_filename):6 self.pickle_filename = pickle_filename7 def generate(self):8 with open(self.pickle_filename, 'rb') as f:9 frames = pickle.load(f)10 for frame in frames:11 yield frame12 def dump(self, frames):13 print('DEBUG: Dumping frames to pickle. ', self.pickle_filename)14 with open(self.pickle_filename, 'wb') as f:15 pickle.dump(frames, f)16def get_pickle_folder(bag_file):17 return bag_file + '_pickle/'18def get_pickle_filename(bag_file, pickle_id):19 return os.path.join(get_pickle_folder(bag_file), str(pickle_id) + '.p')20HEADER_ID = 'header'21FRAME_COUNT = 'frame_count'22FRAME_FILENAMES = 'frame_filenames'23class PickleAdapter:24 def __init__(self, frames_per_pickle = 50):25 self.frames_per_pickle = frames_per_pickle26 self.frame_count = None27 self.generator = None28 self.next_frame = None29 # tracklet_file is allowed to be None30 def start_read(self, bag_file, tracklet_file):31 header_file = get_pickle_filename(bag_file, HEADER_ID)32 if os.path.exists(header_file):33 print('DEBUG: header found')34 else:35 print('DEBUG: header not found. Dicing pickles.')36 split_into_pickles(bag_file, tracklet_file, self.frames_per_pickle)37 with open(header_file, 'rb') as f:38 header = pickle.load(f)39 self.frame_count = header[FRAME_COUNT]40 self.generator = self.generate(header)41 try:42 self.next_frame = next(self.generator)43 except StopIteration:44 self.next_frame = None45 self.generator = None46 def count(self):47 return self.frame_count48 def empty(self):49 return self.next_frame is None50 def next(self):51 if self.next_frame is None:52 return None53 else:54 current_frame = self.next_frame55 try:56 self.next_frame = next(self.generator)57 except StopIteration:58 self.next_frame = None59 self.generator = None60 return current_frame61 def generate(self, header):62 frame_filenames = header[FRAME_FILENAMES]63 frame_pickles = []64 for frame_filename in frame_filenames:65 assert(os.path.exists(frame_filename))66 frame_pickles.append(FramePickle(frame_filename))67 for frame_pickle in frame_pickles:68 generator = frame_pickle.generate()69 empty = False70 while not empty:71 try:72 yield next(generator)73 except StopIteration:74 empty = True75def make_pickle_folder(bag_file):76 folder = get_pickle_folder(bag_file)77 if not os.path.exists(folder):78 os.makedirs(folder)79def split_into_pickles(bag_file, tracklet_file, frames_per_pickle):80 make_pickle_folder(bag_file)81 frame_count = 082 frames = []83 pickles = []84 datastream = traindata.TrainDataStream()85 datastream.start_read(bag_file, tracklet_file)86 while not datastream.empty():87 train_data_frame = datastream.next()88 frames.append(train_data_frame)89 frame_count += 190 if (frame_count % frames_per_pickle) == 0:91 # Dump pickle.92 frame_pickle = FramePickle(get_pickle_filename(bag_file, len(pickles)))93 frame_pickle.dump(frames)94 frames = []95 pickles.append(frame_pickle)96 # Dump rest of frames to pickle.97 frame_pickle = FramePickle(get_pickle_filename(bag_file, len(pickles)))98 frame_pickle.dump(frames)99 frames = []100 pickles.append(frame_pickle)101 # Pickle header102 frame_filenames = []103 for frame_pickle in pickles:104 frame_filenames.append(frame_pickle.pickle_filename)105 header = dict()106 header[FRAME_COUNT] = frame_count107 header[FRAME_FILENAMES] = frame_filenames108 header_file = get_pickle_filename(bag_file, HEADER_ID)109 with open(header_file, 'wb') as f:110 pickle.dump(header, f)111def pre_pickle(bag_tracklets, frames_per_pickle):112 import picklebag113 for bt in bag_tracklets:114 header_file = get_pickle_filename(bt.bag, HEADER_ID)115 if os.path.exists(header_file):116 print('DEBUG: header found', header_file)117 else:118 print('DEBUG: header not found.', header_file, 'Dicing pickles.')119 split_into_pickles(bt.bag, bt.tracklet, frames_per_pickle = frames_per_pickle)120if __name__ == '__main__':121 print('Warning: This will write as much as 20G of data to disk.')122 count = 0123 pickle_adapter = PickleAdapter()124 for i in range(2):125 pickle_adapter.start_read('/data/Didi-Release-2/Data/1/14_f.bag', '/data/output/tracklet/1/14_f/tracklet_labels.xml')126 while not pickle_adapter.empty():127 td = pickle_adapter.next()128 count += 1129 print(count)...

Full Screen

Full Screen

Slam.py

Source:Slam.py Github

copy

Full Screen

1__author__ = 'tom1231'2from PyQt4.QtGui import *3from BAL.Interface.DeviceFrame import DeviceFrame, EX_DEV, SLAM4from lxml.etree import Element, SubElement, XML5class Slam(DeviceFrame):6 def __init__(self, frame, data):7 DeviceFrame.__init__(self, EX_DEV, frame, data)8 self._tf_map_scanmatch_transform_frame_name = 'scanmatcher_frame'9 self._base_frame = 'base_link'10 self._odom_frame = 'odom_link'11 self._map_frame = 'map'12 self._scan_topic = 'scan'13 def toDict(self):14 data = dict()15 data['type'] = SLAM16 data['tf'] = self._tf_map_scanmatch_transform_frame_name17 data['base'] = self._base_frame18 data['odom'] = self._odom_frame19 data['map'] = self._map_frame20 data['scan'] = self._scan_topic21 return data22 def showDetails(self, items=None):23 self.tf_map_scanmatch_transform_frame_name = QLineEdit(self._tf_map_scanmatch_transform_frame_name)24 self.base_frame = QLineEdit(self._base_frame)25 self.odom_frame = QLineEdit(self._odom_frame)26 self.map_frame = QLineEdit(self._map_frame)27 self.scan_topic = QLineEdit(self._scan_topic)28 self._frame.layout().addRow(QLabel('Tf map scan match: '), self.tf_map_scanmatch_transform_frame_name)29 self._frame.layout().addRow(QLabel('Base frame: '), self.base_frame)30 self._frame.layout().addRow(QLabel('Odometry frame: '), self.odom_frame)31 self._frame.layout().addRow(QLabel('Map frame: '), self.map_frame)32 self._frame.layout().addRow(QLabel('Scan topic: '), self.scan_topic)33 def printDetails(self):34 self._frame.layout().addRow(QLabel('Tf map scan match: '), QLabel(self._tf_map_scanmatch_transform_frame_name))35 self._frame.layout().addRow(QLabel('Base frame: '), QLabel(self._base_frame))36 self._frame.layout().addRow(QLabel('Odometry frame: '), QLabel(self._odom_frame))37 self._frame.layout().addRow(QLabel('Map frame: '), QLabel(self._map_frame))38 self._frame.layout().addRow(QLabel('Scan topic: '), QLabel(self._scan_topic))39 def getName(self):40 return "SLAM"41 def saveToFile(self, parent):42 element = SubElement(parent, 'include', {43 'file': '$(find ric_board)/launch/hector_slam.launch'44 })45 SubElement(element, 'arg', {46 'name': 'tf_map_scanmatch_transform_frame_name',47 'value': self._tf_map_scanmatch_transform_frame_name48 })49 SubElement(element, 'arg', {50 'name': 'base_frame',51 'value': self._base_frame52 })53 SubElement(element, 'arg', {54 'name': 'odom_frame',55 'value': self._odom_frame56 })57 SubElement(element, 'arg', {58 'name': 'map_frame',59 'value': self._map_frame60 })61 SubElement(element, 'arg', {62 'name': 'pub_map_odom_transform',63 'default': 'true'64 })65 SubElement(element, 'arg', {66 'name': 'scan_subscriber_queue_size',67 'default': '5'68 })69 SubElement(element, 'arg', {70 'name': 'scan_topic',71 'value': self._scan_topic72 })73 SubElement(element, 'arg', {74 'name': 'map_size',75 'default': '2048'76 })77 def add(self):78 if not self.nameIsValid():79 QMessageBox.critical(self._frame, "Error", "Name already taken.")80 self._isValid = False81 return82 self._isValid = True83 self._tf_map_scanmatch_transform_frame_name = str(self.tf_map_scanmatch_transform_frame_name.text())84 self._base_frame = str(self.base_frame.text())85 self._odom_frame = str(self.odom_frame.text())86 self._map_frame = str(self.map_frame.text())87 self._scan_topic = str(self.scan_topic.text())88 def fromDict(self, data):89 self._tf_map_scanmatch_transform_frame_name = data['tf']90 self._base_frame = data['base']91 self._odom_frame = data['odom']92 self._map_frame = data['map']...

Full Screen

Full Screen

frame_diff.py

Source:frame_diff.py Github

copy

Full Screen

1#!/usr/bin/python2import cv23# Compute the frame differences4def frame_diff(prev_frame, cur_frame, next_frame):5 # Difference between the current frame and the next frame6 diff_frames_1 = cv2.absdiff(next_frame, cur_frame)7 # Difference between the current frame and the previous frame8 diff_frames_2 = cv2.absdiff(cur_frame, prev_frame)9 return cv2.bitwise_and(diff_frames_1, diff_frames_2)10# Define a function to get the current frame from the webcam11def get_frame(cap, scaling_factor):12 # Read the current frame from the video capture object13 _, frame = cap.read()14 # Resize the image15 frame = cv2.resize(frame, None, fx=scaling_factor, 16 fy=scaling_factor, interpolation=cv2.INTER_AREA)17 # Convert to grayscale18 gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)19 return gray 20if __name__=='__main__':21 # Define the video capture object22 cap = cv2.VideoCapture(0)23 # Define the scaling factor for the images24 scaling_factor = 0.525 26 # Grab the current frame27 prev_frame = get_frame(cap, scaling_factor) 28 # Grab the next frame29 cur_frame = get_frame(cap, scaling_factor) 30 # Grab the frame after that31 next_frame = get_frame(cap, scaling_factor) 32 # Keep reading the frames from the webcam 33 # until the user hits the 'Esc' key34 while True:35 # Display the frame difference36 cv2.imshow('Object Movement', frame_diff(prev_frame, 37 cur_frame, next_frame))38 # Update the variables39 prev_frame = cur_frame40 cur_frame = next_frame 41 # Grab the next frame42 next_frame = get_frame(cap, scaling_factor)43 # Check if the user hit the 'Esc' key44 key = cv2.waitKey(10)45 if key == 27:46 break47 # Close all the windows...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var rootFrame = Frame.topmost();2rootFrame.navigate("view1");3var pageFrame = page.frame;4pageFrame.navigate("view2");5var pageFrame = page.frame;6pageFrame.navigate("view3");7var pageFrame = page.frame;8pageFrame.navigate("view1");9var pageFrame = page.frame;10pageFrame.navigate("view2");11var pageFrame = page.frame;12pageFrame.navigate("view3");13var pageFrame = page.frame;14pageFrame.navigate("view1");15var pageFrame = page.frame;16pageFrame.navigate("view2");17var pageFrame = page.frame;18pageFrame.navigate("view3");19var pageFrame = page.frame;20pageFrame.navigate("view1");21var pageFrame = page.frame;22pageFrame.navigate("view2");23var pageFrame = page.frame;24pageFrame.navigate("view3");25var pageFrame = page.frame;26pageFrame.navigate("view1");27var pageFrame = page.frame;28pageFrame.navigate("view2");29var pageFrame = page.frame;30pageFrame.navigate("view3");31var pageFrame = page.frame;32pageFrame.navigate("view1");33var pageFrame = page.frame;34pageFrame.navigate("view2");

Full Screen

Using AI Code Generation

copy

Full Screen

1var frame = root.Frame;2frame.Show();3var frame = root.Frame.Frame;4frame.Show();5var frame = root.Frame.Frame.Frame;6frame.Show();7var frame = root.Frame.Frame.Frame.Frame;8frame.Show();9var frame = root.Frame.Frame.Frame.Frame.Frame;10frame.Show();11var frame = root.Frame.Frame.Frame.Frame.Frame.Frame;12frame.Show();13var frame = root.Frame.Frame.Frame.Frame.Frame.Frame.Frame;14frame.Show();15var frame = root.Frame.Frame.Frame.Frame.Frame.Frame.Frame.Frame;16frame.Show();17var frame = root.Frame.Frame.Frame.Frame.Frame.Frame.Frame.Frame.Frame;18frame.Show();

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = this;2root.Frame("test");3root.parent.Frame("test");4root.parent.parent.Frame("test");5root.parent.parent.parent.Frame("test");6root.parent.parent.parent.parent.Frame("test");7root.parent.parent.parent.parent.parent.Frame("test");8root.parent.parent.parent.parent.parent.parent.Frame("test");9root.parent.parent.parent.parent.parent.parent.parent.Frame("test");10root.parent.parent.parent.parent.parent.parent.parent.parent.Frame("test");11root.parent.parent.parent.parent.parent.parent.parent.parent.parent.Frame("test");

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = Frame.getRoot();2root.setTitle("Hello World");3this.setTitle("Hello World");4var root = Frame.getRoot();5root.setTitle("Hello World");6this.setTitle("Hello World");7var root = Frame.getRoot();8root.setTitle("Hello World");9this.setTitle("Hello World");10var root = Frame.getRoot();11root.setTitle("Hello World");12this.setTitle("Hello World");13var root = Frame.getRoot();14root.setTitle("Hello World");15this.setTitle("Hello World");16var root = Frame.getRoot();17root.setTitle("Hello World");18this.setTitle("Hello World");19var root = Frame.getRoot();20root.setTitle("Hello World");21this.setTitle("Hello World");22var root = Frame.getRoot();23root.setTitle("Hello World");24this.setTitle("Hello World");25var root = Frame.getRoot();26root.setTitle("Hello World");27this.setTitle("Hello World");28var root = Frame.getRoot();29root.setTitle("Hello World");30this.setTitle("Hello World");31var root = Frame.getRoot();32root.setTitle("Hello World");33this.setTitle("Hello World");34var root = Frame.getRoot();35root.setTitle("Hello World");36this.setTitle("Hello World");

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('ui').root;2root.frame = {x:0, y:0, width:320, height:480};3var Button = require('ui/button');4var button = new Button({frame: {x:0, y:0, width:320, height:480}});5button.frame = {x:0, y:0, width:320, height:480};6var Window = require('ui/window');7var window = new Window({frame: {x:0, y:0, width:320, height:480}});8window.frame = {x:0, y:0, width:320, height:480};9var Card = require('ui/card');10var card = new Card({frame: {x:0, y:0, width:320, height:480}});11card.frame = {x:0, y:0, width:320, height:480};12var Menu = require('ui/menu');13var menu = new Menu({frame: {x:0, y:0, width:320, height:480}});14menu.frame = {x:0, y:0, width:320, height:480};15var SplashWindow = require('ui/splash-window');16var splashWindow = new SplashWindow({frame: {x:0, y:0, width:320, height:480}});17splashWindow.frame = {x:0, y:0, width:320, height:480};18var VectorImage = require('ui/vector-image');19var vectorImage = new VectorImage({frame: {x:0, y:0, width:320, height:480}});20vectorImage.frame = {x:0, y:0, width:320, height:480};21var Image = require('ui/image');22var image = new Image({frame: {x:0, y:0, width:320, height:480}});23image.frame = {x:0, y:0, width:320, height:480};

Full Screen

Using AI Code Generation

copy

Full Screen

1var frame = root.Frame();2frame.SetTitle("Hello World!");3frame.SetSize(500, 500);4frame.Show();5frame.Center();6frame.SetResizable(false);7var frame = root.Frame();8frame.SetTitle("Hello World!");9frame.SetSize(500, 500);10frame.Show();11frame.Center();12frame.SetResizable(false);13var frame = root.Frame();14frame.SetTitle("Hello World!");15frame.SetSize(500, 500);16frame.Show();17frame.Center();18frame.SetResizable(false);19var frame = root.Frame();20frame.SetTitle("Hello World!");21frame.SetSize(500, 500);22frame.Show();23frame.Center();24frame.SetResizable(false);25var frame = root.Frame();26frame.SetTitle("Hello World!");27frame.SetSize(500, 500);28frame.Show();29frame.Center();30frame.SetResizable(false);31var frame = root.Frame();32frame.SetTitle("Hello World!");33frame.SetSize(500, 500);34frame.Show();35frame.Center();36frame.SetResizable(false);37var frame = root.Frame();38frame.SetTitle("Hello World!");39frame.SetSize(500, 500);40frame.Show();41frame.Center();42frame.SetResizable(false);43var frame = root.Frame();44frame.SetTitle("Hello World!");45frame.SetSize(500, 500);46frame.Show();47frame.Center();48frame.SetResizable(false);49var frame = root.Frame();50frame.SetTitle("Hello World!");51frame.SetSize(500, 500);52frame.Show();53frame.Center();54frame.SetResizable(false);55var frame = root.Frame();56frame.SetTitle("Hello World!");57frame.SetSize(500, 500);58frame.Show();59frame.Center();60frame.SetResizable(false);61var frame = root.Frame();62frame.SetTitle("Hello World!");63frame.SetSize(500, 500);64frame.Show();65frame.Center();66frame.SetResizable(false);67var frame = root.Frame();68frame.SetTitle("Hello World!");69frame.SetSize(500, 500);70frame.Show();71frame.Center();72frame.SetResizable(false);

Full Screen

Using AI Code Generation

copy

Full Screen

1var frame = root.Frame();2var frame = this.Frame();3var frame = this.Frame();4var frameCount = this.FrameCount();5var frameIndex = this.FrameIndex();6var frameName = this.FrameName();7var frameType = this.FrameType();8var animation = this.GetAnimation('animationName');

Full Screen

Using AI Code Generation

copy

Full Screen

1window.rootFrame = function() {2 return window.root.rootFrame();3}4window.rootFrame = function() {5 return window.root.rootFrame();6}7window.rootFrame = function() {8 return window.root.rootFrame();9}10window.rootFrame = function() {11 return window.root.rootFrame();12}13window.rootFrame = function() {14 return window.root.rootFrame();15}16window.rootFrame = function() {17 return window.root.rootFrame();18}19window.rootFrame = function() {20 return window.root.rootFrame();21}22window.rootFrame = function() {23 return window.root.rootFrame();24}25window.rootFrame = function() {26 return window.root.rootFrame();27}28window.rootFrame = function() {29 return window.root.rootFrame();30}31window.rootFrame = function() {32 return window.root.rootFrame();33}34window.rootFrame = function() {35 return window.root.rootFrame();36}37window.rootFrame = function() {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful