Esempio n. 1
0
 def __collisionThread(self):
     while not self.stopCollisionThread:
         self.collisionDetected = self.telemetreDetectCollision()
         #Display telemeters and robot
         if webInterface and webInterface.instance:
             self.forme = Ligne("robot", self.x, self.y,
                                self.x + self.largeur, self.y, "violet")
             self.forme.rotate(self.angle)
             webInterface.instance.addDynamicElement(self)
             for telemetre in self.listTelemetre:
                 line = Ligne("", self.x, self.y, self.x - telemetre.x,
                              self.y + telemetre.y, "green")
                 line.rotate(line.getAngle() + self.angle - 90)
                 lineTarget = Ligne("", line.x2, line.y2, line.x2 * 2,
                                    line.y2 * 2, "green")
                 lineTarget.resize(
                     telemetre.value * 1.25
                 )  # extending the line by 1.25, see telemetreDetectCollision()
                 lineTarget.rotate(self.angle + telemetre.angle)
                 lineTarget.couleur = telemetre.color
                 telemetre.forme = lineTarget
                 webInterface.instance.addDynamicElement(telemetre)
         if webInterface and webInterface.instance:
             line = Ligne("direction", self.x, self.y,
                          self.x + self.largeur * 2, self.y, "green")
             line.rotate(self.getMovmentAngle())
             self.movementDirectionObj.forme = line
             webInterface.instance.addDynamicElement(
                 self.movementDirectionObj)
         time.sleep(0.1)
Esempio n. 2
0
 def setPosition(self, x, y, angle):
     self.x = x
     self.y = y
     self.angle = angle
     if webInterface.instance:
         self.forme = Ligne("robot", self.x, self.y, self.x + self.largeur,
                            self.y, "violet")
         self.forme.rotate(self.angle)
         webInterface.instance.addDynamicElement(self)
         for telemetre in self.listTelemetre:
             line = Ligne("", self.x, self.y, self.x - telemetre.x,
                          self.y + telemetre.y, "green")
             line.rotate(line.getAngle() + self.angle - 90)
             lineTarget = Ligne("", line.x2, line.y2, line.x2 * 2,
                                line.y2 * 2, "green")
             lineTarget.resize(
                 telemetre.value * 1.25
             )  # extending the line by 1.25, see telemetreDetectCollision()
             lineTarget.rotate(self.angle + telemetre.angle)
             lineTarget.couleur = telemetre.color
             telemetre.forme = lineTarget
             webInterface.instance.addDynamicElement(telemetre)