예제 #1
0
def main(machine):
    # Load calibration file
    calibration = Calibration()
    table = calibration.load_calibration_file(calibration_file)

    # Preparation:
    machine.connect()
    machine.home()

    # Movements:
    # --------------------------------------------------------------------------------------
    # Setup initial configuration
    setup_movements = [('A1', 'B4'), ('A8', 'B7'), ('H8', 'E6'), ('D1', 'D2')]
    for origin, destination in setup_movements:
        pick_and_place(machine, chess_to_coord(origin, table), chess_to_coord(destination, table))
        t.sleep(5)
    machine.home()

    # Capture attacking piece
    out_point = chess_to_coord('B0', table) #[0], calibration.real_points['out_white'][1])
    pick_and_place(machine, chess_to_coord('B4', table), out_point)
    t.sleep(1)

    # Simple movements
    movement_list = [('B7', 'B4'),
                     ('E6', 'D5'),
                     ('H1', 'H5'),
                     ('D5', 'D6'),
                     ('B4','B6'),
                     ('D6','C7'),
                     ('B6','F6'),
                     ('C7','D7'),
                     ('H5','H7'),
                     ('D7','D8'),
                     ('F6','F8')]

    for origin, destination in movement_list:
        pick_and_place(machine, chess_to_coord(origin, table), chess_to_coord(destination, table))
        t.sleep(5)
    machine.home()

    # Restore initial position
    cleanup_movements = [('H7', 'H1'), ('D2', 'D1'), ('B0', 'A1'), ('F8', 'F4'), ('D8', 'H8'), ('F4', 'A8')]
    for origin, destination in cleanup_movements:
        pick_and_place(machine, chess_to_coord(origin, table), chess_to_coord(destination, table))
        t.sleep(5)
    machine.home()

    # End
    machine.home()

    try:
        cxy.save_to_file('chess.gcode')
    except AttributeError:
        pass
    machine.disconnect()
예제 #2
0
def main(machine):
    # Load calibration file
    calibration = Calibration()
    table = calibration.load_calibration_file(calibration_file)

    # Preparation:
    machine.connect()
    machine.home()

    # Movements:
    # --------------------------------------------------------------------------------------
    # Setup initial configuration
    setup_movements = [('A1', 'B4'), ('A8', 'B7'), ('H8', 'E6'), ('D1', 'D2')]
    for origin, destination in setup_movements:
        pick_and_place(machine, chess_to_coord(origin, table),
                       chess_to_coord(destination, table))
        t.sleep(5)
    machine.home()

    # Capture attacking piece
    out_point = chess_to_coord(
        'B0', table)  #[0], calibration.real_points['out_white'][1])
    pick_and_place(machine, chess_to_coord('B4', table), out_point)
    t.sleep(1)

    # Simple movements
    movement_list = [('B7', 'B4'), ('E6', 'D5'), ('H1', 'H5'), ('D5', 'D6'),
                     ('B4', 'B6'), ('D6', 'C7'), ('B6', 'F6'), ('C7', 'D7'),
                     ('H5', 'H7'), ('D7', 'D8'), ('F6', 'F8')]

    for origin, destination in movement_list:
        pick_and_place(machine, chess_to_coord(origin, table),
                       chess_to_coord(destination, table))
        t.sleep(5)
    machine.home()

    # Restore initial position
    cleanup_movements = [('H7', 'H1'), ('D2', 'D1'), ('B0', 'A1'),
                         ('F8', 'F4'), ('D8', 'H8'), ('F4', 'A8')]
    for origin, destination in cleanup_movements:
        pick_and_place(machine, chess_to_coord(origin, table),
                       chess_to_coord(destination, table))
        t.sleep(5)
    machine.home()

    # End
    machine.home()

    try:
        cxy.save_to_file('chess.gcode')
    except AttributeError:
        pass
    machine.disconnect()
예제 #3
0
    def onLoadButtonClicked(self):
        calibration_filename = self.calibrationFileLineEdit.text()
        points_filename = self.pointsFileLineEdit.text()

        if calibration_filename and points_filename:
            # Ask the user for a file
            filename, ext = QtGui.QFileDialog.getOpenFileName(
                None, "Select SVG file", filter='*.svg')

            if filename:
                try:
                    # Load image data from calibration file
                    calibration = Calibration()
                    calibration.load_zipfile(calibration_filename)
                    self.loadImage(calibration)
                except Calibration.LoadException, e:
                    QtGui.QMessageBox().critical(
                        self, 'Error', 'Calibration file not compatible!')
                    return False

                try:
                    # Load points data from points file
                    self.limits = Calibration.load_calibration_file(
                        points_filename)
                except Calibration.LoadException, e:
                    QtGui.QMessageBox().critical(
                        self, 'Error', 'Points file not compatible!')
                    return False

                try:
                    # Load data from files
                    self.trajectory.load_paths_from_svg(filename)

                    # Set trajectories on controls
                    trajectory_choices = [
                        "Trajectory #%d" % i
                        for i, path in enumerate(self.trajectory.paths)
                    ]
                    self.trajectoryComboBox.clear()
                    self.trajectoryComboBox.addItems(trajectory_choices)
                    self.setTrajectoryControlsEnabled(True)

                    self.update()
                except TrajectoryController.TrajectoryException, e:
                    pass
예제 #4
0
    def onLoadButtonClicked(self):
        calibration_filename = self.calibrationFileLineEdit.text()
        points_filename = self.pointsFileLineEdit.text()

        if calibration_filename and points_filename:
            # Ask the user for a file
            filename, ext = QtGui.QFileDialog.getOpenFileName(None, "Select SVG file", filter='*.svg' )

            if filename:
                try:
                    # Load image data from calibration file
                    calibration = Calibration()
                    calibration.load_zipfile(calibration_filename)
                    self.loadImage(calibration)
                except Calibration.LoadException, e:
                    QtGui.QMessageBox().critical(self, 'Error', 'Calibration file not compatible!')
                    return False

                try:
                    # Load points data from points file
                    self.limits = Calibration.load_calibration_file(points_filename)
                except Calibration.LoadException, e:
                    QtGui.QMessageBox().critical(self, 'Error', 'Points file not compatible!')
                    return False

                try:
                    # Load data from files
                    self.trajectory.load_paths_from_svg(filename)

                    # Set trajectories on controls
                    trajectory_choices = [ "Trajectory #%d" % i for i, path in enumerate(self.trajectory.paths)]
                    self.trajectoryComboBox.clear()
                    self.trajectoryComboBox.addItems(trajectory_choices)
                    self.setTrajectoryControlsEnabled(True)

                    self.update()
                except TrajectoryController.TrajectoryException, e:
                    pass
 def load_calibration_from_file(self, filepath):
     self.points = Calibration.load_calibration_file(filepath)
예제 #6
0
 def load_calibration_from_file(self, filepath):
     self.points = Calibration.load_calibration_file(filepath)