fixes
This commit is contained in:
parent
260cd60b91
commit
ca62e8ef89
6
robot.py
6
robot.py
@ -24,7 +24,7 @@ class Robot:
|
||||
# pins reliés au moteurs (bw_l, fw_l, bw_r, fw_r)
|
||||
motors_pins = ((9,10),(12,11))
|
||||
# position du spot lumineux
|
||||
light_pos = (5, 1.5)
|
||||
light_pos = (9, 1.5)
|
||||
# ecart entre les deux photores
|
||||
photores_l = 0.1
|
||||
# longeur du séparateur entre les photorésistances
|
||||
@ -66,8 +66,8 @@ class Robot:
|
||||
self.pr_l = self.PHOTORES_SHADOW
|
||||
self.pr_r = self.PHOTORES_LIGHT
|
||||
|
||||
self.pins[self.pr_l_pin] = 1024 * self.PHOTORES_BRIDGE/(self.pr_l+self.PHOTORES_BRIDGE)
|
||||
self.pins[self.pr_r_pin] = 1024 * self.PHOTORES_BRIDGE/(self.pr_r+self.PHOTORES_BRIDGE)
|
||||
self.pins[self.pr_l_pin] = int(1024-1024 * self.PHOTORES_BRIDGE/(self.pr_l+self.PHOTORES_BRIDGE))
|
||||
self.pins[self.pr_r_pin] = int(1024-1024 * self.PHOTORES_BRIDGE/(self.pr_r+self.PHOTORES_BRIDGE))
|
||||
|
||||
|
||||
def analogWrite(self, pin, dc):
|
||||
|
@ -54,9 +54,14 @@ while True:
|
||||
screen.fill(black)
|
||||
robotShape = pygame.Rect(20,15, 10,20);
|
||||
rsurf = pygame.Surface((50,50)).convert_alpha();
|
||||
# robot
|
||||
pygame.draw.rect(rsurf, (255,255,255), robotShape);
|
||||
# heading
|
||||
pygame.draw.line(rsurf, (255,255,255), (25,25), (25,50))
|
||||
# dir2light
|
||||
pygame.draw.line(rsurf, (255,255,255), (25,25), (25+25*sin(r.angle2spot),25+25*cos(r.angle2spot)))
|
||||
# light
|
||||
pygame.draw.polygon(screen, (255,255,0), ([100*a for a in r.light_pos],[100*(a+b) for a,b in zip(r.light_pos,(-1,1))],[100*(a+b) for a,b in zip(r.light_pos,(-1,-1))]))
|
||||
rsurf_r = pygame.transform.rotate(rsurf, degrees(r.rot));
|
||||
center = rsurf_r.get_rect().center
|
||||
screen.blit(rsurf_r, (r.pos[0]*100-center[0],r.pos[1]*100-center[1]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user