예제 #1
0
    def calibrate(self):

        # if(self.lleg.angle <= abs(self.angle)):
        #     self.lleg.lock = False
        # if(self.rleg.angle <= abs(self.angle)):
        #     self.rleg.lock = False
        while ((abs(self.angle) > self.lleg.angle and self.lleg.angle > 0)
               or (abs(self.angle) > self.rleg.angle and self.rleg.angle > 0)):
            if (self.angle != 0):
                self.angle = self.angle + (0 - self.angle) / abs(self.angle)
                move_angle(self.point_zero, self.angle, self.stop_addr)
                time.sleep(.005)
                # if(self.lleg.angle + self.rleg.angle == 0):
                #     self.rleg.lock = True
                #     self.lleg.lock = True

        while (self.angle != 0 or self.lleg.angle != 0
               or self.rleg.angle != 0):
            #while((self.angle > self.lleg.angle and self.lleg.angle > 0) or (self.angle > self.rleg.angle and self.rleg.angle > 0)):
            if (self.angle != 0):
                self.angle = self.angle + (0 - self.angle) / abs(self.angle)
            if (self.lleg.angle + self.rleg.angle == 0):
                self.rleg.lock = True
                self.lleg.lock = True
            if (self.lleg.angle != 0 and self.lleg.lock):
                self.lleg.calibrate()
            if (self.rleg.angle != 0 and self.rleg.lock):
                self.rleg.calibrate()
            time.sleep(.005)
            #move_angle(self.addr)
            #print('p: {}, l: {}, r: {}'.format(self.angle, self.lleg.angle, self.rleg.angle))
            self.last = 0
예제 #2
0
    def move(self, mode, way):

        if (self.lleg.lock):
            self.lleg.move(self.last, mode)

        if (self.rleg.lock):
            self.rleg.move(self.last, mode)

        self.angle = self.angle + 2 * self.modes[self.last]

        move_angle(self.point_zero, way * self.angle, self.stop_addr)

        if (self.angle >= self.max):
            self.last = 1
        elif (self.angle <= self.min):
            self.last = 3
        elif (self.angle == 0 and self.last == 1):
            self.last = 2
        elif (self.angle == 0 and self.last == 3):
            self.last = 4
        elif (abs(self.angle) == int(self.max / 2) and self.last == 0):
            self.last = 5

        if (self.last == 2 or self.last == 4 or self.last == 5):

            if (self.lleg.angle + self.rleg.angle == 0):
                self.rleg.lock = True
                self.lleg.lock = True
예제 #3
0
    def move(self, last, mode):
        if (last != 0 and last != 5 and last != 6):
            self.angle = self.angle + 9 * (self.modes[last] * self.mode)
        elif (last == 0):
            self.angle = self.angle + 9 * (mode * self.mode)
        elif (last == 5):
            self.angle = self.angle - 9 * (mode * self.mode)

        if (self.angle <= self.min):
            self.lock = False
        move_angle(self.point_zero, self.angle, self.stop_addr)
예제 #4
0
    def move_up(self, mode):

        self.lleg.move(self.last, self.lleg.mode)
        move_angle(self.lleg.point_zero, self.lleg.angle, self.lleg.stop_addr)
        self.rleg.move(self.last, self.rleg.mode)
        move_angle(self.rleg.point_zero, self.rleg.angle, self.rleg.stop_addr)
        self.angle = self.angle + self.modes[self.last]
        move_angle(self.point_zero, self.angle, self.stop_addr)
        time.sleep(.3)
        if (abs(self.angle) == 22 and self.last == 0):
            self.last = 5
예제 #5
0
 def calibrate(self):
     self.angle = self.angle + (0 - self.angle) / abs(self.angle)
     move_angle(self.point_zero, self.angle, self.stop_addr)