Script demo_simpleGaitCyclePlan_py
[hide private]
[frames] | no frames]

Source Code for Script script-demo_simpleGaitCyclePlan_py

 1  from joy import * 
 2   
3 -class GaitCyclePlanApp( JoyApp ):
4 SHEET = loadCSV("demos/M4ModLab.csv") 5
6 - def __init__(self,*arg,**kw):
7 JoyApp.__init__(self,scr={},*arg,**kw)
8
9 - def onStart( self ):
10 self.plan = GaitCyclePlan( self, 11 self.SHEET, x='>catX',y=('>catY',lambda v : -v)) 12 self.plan.setPeriod(10)
13
14 - def onEvent(self, evt):
15 if evt.type==KEYDOWN: 16 if evt.key in [ord('q'),27]: # 'q' and [esc] stop program 17 self.stop() 18 # 19 elif evt.key==ord(' '): # [space] toggles motion 20 if self.plan.isRunning(): 21 self.plan.stop() 22 progress('Stopped motion') 23 else: 24 self.plan.start() 25 progress('Started motion')
26 27 if __name__=="__main__": 28 print """ 29 Demo of SheetPlan class 30 ----------------------- 31 32 Use this demo with the demo-plans.sb Scratch project: 33 $ scratch demos/demo-plans.sb & 34 35 When any key is pressed, starts a SheetPlan making the 36 cat move around a shape defined in the CSV file. 37 38 The application can be terminated with 'q' or [esc] 39 """ 40 import joy 41 app=GaitCyclePlanApp() 42 app.run() 43