Exemplo n.º 1
0
    def scan(self):
        log.info("scan()")
        self.colors = {}
        self.k = 0
        self.scan_face(1)

        self.flip()
        self.scan_face(2)

        self.flip()
        self.scan_face(3)

        self.rotate_cube(-1, 1)
        self.flip()
        self.scan_face(4)

        self.rotate_cube(1, 1)
        self.flip()
        self.scan_face(5)

        self.flip()
        self.scan_face(6)

        if self.shutdown:
            return

        log.info("RGB json:\n%s\n" % json.dumps(self.colors))
        self.rgb_solver = RubiksColorSolver()
        self.rgb_solver.enter_scan_data(self.colors)
        self.cube_kociemba = self.rgb_solver.crunch_colors()
        log.info("Final Colors (kociemba): %s" % ''.join(self.cube_kociemba))

        # This is only used if you want to rotate the cube so U is on top, F is
        # in the front, etc. You would do this if you were troubleshooting color
        # detection and you want to pause to compare the color pattern on the
        # cube vs. what we think the color pattern is.
        '''
Exemplo n.º 2
0
    def scan(self):
        self.colors = {}
        #self.bloc_cube()
        self.k = 0
        self.scan_face()

        self.flip()
        self.scan_face()

        self.flip()
        self.scan_face()

        self.rotate_cube(-1, 1)
        self.flip()
        self.scan_face()

        self.rotate_cube(1, 1)
        self.flip()
        self.scan_face()

        self.flip()
        self.scan_face(last_face=True)

        if self.shutdown_flag:
            return

        run_rgb_solver = True

        if self.server_username and self.server_ip and self.server_path:
            output = Popen([
                'ssh',
                '%s@%s' % (self.server_username, self.server_ip),
                '%s/python/pyev3/rubiks_rgb_solver.py' % self.server_path,
                '--rgb',
                "'%s'" % json.dumps(self.colors)
            ],
                           stdout=PIPE).communicate()[0]
            output = output.strip().strip()
            self.cube_kociemba = list(output)

            if self.cube_kociemba:
                run_rgb_solver = False
            else:
                log.warning(
                    "Our connection to %s failed, we will run rubiks_rgb_solver locally"
                    % self.server_ip)
                self.leds.set_all('orange')

        if run_rgb_solver:
            from rubiks_rgb_solver import RubiksColorSolver
            self.rgb_solver = RubiksColorSolver(False)

            if self.shutdown_flag:
                self.rgb_solver.shutdown_flag = True

            self.rgb_solver.enter_scan_data(self.colors)
            (self.cube_kociemba,
             self.cube_cubex) = self.rgb_solver.crunch_colors()

        log.info("Scanned RGBs\n%s" % pformat(self.colors))
        log.info("Final Colors: %s" % self.cube_kociemba)