@@ -0,0 +1,1836 @@
+from SimpleCV import Image, Display, Color%0Aimport numpy as np%0Aimport scipy as sp%0Aimport time%0Aimport PID%0A%0Adef windForce(X, D):%0A  ''' Computes a factor for the wind force depending on the postion on the window%0A      Inputs :%0A%09  - X: vector position%0A%09  - D: diameter of the window of flight'''%0A  d = sp.sqrt(X%5B1%5D**2 + X%5B2%5D**2)%0A  return sp.cos(d/D*sp.pi/2) # kind of circular shape%0A%0Adef speed(X):%0A  ''' Computes the speed of kite based on its position and orientation'''%0A  F = windForce(X, 350)%0A  return F -0.1*sp.cos(sp.arctan2(X%5B2%5D, X%5B1%5D)-sp.pi/2 -X%5B0%5D)%0A  %0Aorder = 1%0AX = np.array(%5B%5B0, 0, 0%5D%5D).transpose()%0A%0A#Create a black and a white image%0Alogo = Image('logo').resize(800, 600)%0Ablack = logo-logo%0Awhite = black.invert()%0Akite_base = white.crop(0, 0, 30, 10)%0Adisp = Display()%0Ak = -4%0Adt = 0.1%0Akdrift  = 50%0Ai_loop = 0%0Apid = PID.PID(1, 1, 0.1)%0Aoffset = sp.pi/3%0AdX = 0*X%0Awhile disp.isNotDone():%0A  setpoint = sp.pi/1.7*sp.sin(2*sp.pi/7*time.time())+offset%0A  i_loop = i_loop +1%0A  #order = 0+sp.randn(1)/5#2.0*disp.mouseX/white.width-1 %0A  error = X%5B0%5D -setpoint%0A  order = sp.randn(1)/100 +  pid.computeCorrection(error, dX%5B0%5D/dt-0)%0A  pid.incrementTime(error, dt)%0A  angle = X%5B0%5D%0A  V = 150*speed(X)%0A  print setpoint -X%5B0%5D%0A  dX = dt*np.array(%5Bk*(windForce(X, 400) +0.1)*(order-0.3*sp.sin(sp.arctan2(X%5B2%5D, X%5B1%5D)-sp.pi/2)), -V*sp.sin(angle) + kdrift*order*sp.cos(angle) , V*sp.cos(angle) + kdrift*order*sp.sin(angle)%5D)%0A  X = X + dX%0A  kite = kite_base.rotate(sp.rad2deg(angle), fixed=False)%0A  #kite.save(disp)d%0A  #white.blit(kite, (799,0)).save(disp)%0A%0A  toDisplay = black.blit(kite, (max(-kite.width +1, min(white.width-1, int(X%5B1%5D+white.width/2-kite.width/2))), max(-kite.height+1, min(white.height-1, int(white.height-X%5B2%5D-200)))))%0A  toDisplay.drawText(str(i_loop*dt), 0, 0, color = Color.RED, fontsize=60)%0A  toDisplay.save(disp)%0A  time.sleep(dt)%0A  %0A%0A%0A

Add a basic kite simulator