2022-11-21 20:56:47 +01:00

31 lines
797 B
Python

from math import cos, sin, pi
class Robot:
# position
pos=(0,1.5)
# orientation
rot=pi/2
# velocite
v=0
# velocite angulaire
angv=0
# velocite des roues (non angulaire)
wv=(0.1,0.1)
# espace entre les deux roues
l=0.1
# time
t = 0
def __init__(self):
print("yo")
def update(self, dt):
self.t += dt
# https://robotics.stackexchange.com/questions/106/what-is-a-suitable-model-for-two-wheeled-robots
self.v = 1/2*(self.wv[0]+self.wv[1])
self.angv = 1/self.l*(self.wv[1]-self.wv[0])
self.rot += self.angv*dt
self.pos = (self.pos[0]+self.v*sin(self.rot)*dt,self.pos[1]+self.v*cos(self.rot)*dt)
if(self.pos[0]>=10):
print(self.t)
sys.exit()