Skip to content

Commit

Permalink
Merge pull request #54 from Hacking3DPrinters/testing
Browse files Browse the repository at this point in the history
Release 0.2.4
  • Loading branch information
HippoProgrammer authored Jun 18, 2024
2 parents 89da324 + 129ddf0 commit a0f5f74
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 59 deletions.
Binary file added dist/robotic_chess-0.2.4-py3-none-any.whl
Binary file not shown.
Binary file added dist/robotic_chess-0.2.4.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "robotic_chess"
version = "0.2.1"
version = "0.2.4"
authors = [
{ name="Benjamin Porter", email="bcgcustomerservices@gmail.com" },
]
Expand Down
32 changes: 29 additions & 3 deletions src/robotic_chess.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: robotic_chess
Version: 0.2.1
Version: 0.2.4
Summary: A 3D printer-based chess playing robot.
Author-email: Benjamin Porter <bcgcustomerservices@gmail.com>
Project-URL: Homepage, https://github.com/hippoprogrammer/robotic-chess
Expand All @@ -12,5 +12,31 @@ Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE

# robotic-chess
An AI-powered chess playing robot, powered by Raspberry Pi.
# Robotic Chess

An chess playing robot, powered by Stockfish.
For documentation, see [our wiki](https://github.com/Hacking3DPrinters/robotic-chess/wiki).

---

## Installation

### Installation from wheel

First, visit [our releases page](https://github.com/Hacking3DPrinters/robotic-chess/releases) and download the `.whl` and `requirements.txt` files from the desired version.

Then, run
```pip install robotic_chess-0.2.1-py3.whl```
(replace 0.2.1 with the version number of your downloaded wheel).

Finally, run
```pip install -r requirements.txt```
to install dependencies.

THIS DOES NOT INSTALL STOCKFISH OR OCTOPRINT (will be included in the future).

### Installation from source

First, clone our repo using `git clone https://github.com/Hacking3DPrinters/robotic-chess.git`, and enter the new directory. Then do `pip install dist/robotic_chess-0.2.1-py3-none-any.whl` (replace 0.2.1 with the desired version number), followed by `pip install -r requirements.txt`.

THIS DOES NOT INSTALL STOCKFISH OR OCTOPRINT (will be included in the future).
2 changes: 2 additions & 0 deletions src/robotic_chess.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
LICENSE
README.md
pyproject.toml
src/robotic_chess/__init__.py
src/robotic_chess/chess.py
src/robotic_chess/gcode.py
src/robotic_chess/octoprint.py
src/robotic_chess.egg-info/PKG-INFO
src/robotic_chess.egg-info/SOURCES.txt
src/robotic_chess.egg-info/dependency_links.txt
Expand Down
7 changes: 4 additions & 3 deletions src/robotic_chess/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import chess
import gcode
import __main__
import robotic_chess.chess
import robotic_chess.gcode
import robotic_chess.octoprint
# main code goes here
1 change: 0 additions & 1 deletion src/robotic_chess/__main__.py

This file was deleted.

83 changes: 32 additions & 51 deletions src/robotic_chess/gcode.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# a simple module for parsing Python to .gcode
class Parser:
def __init__(self):
self.cmd_list=[]
def add_manual(self,cmd):
# Warning: command may break Parser
self.cmd_list.add(str(cmd))
def setup(self,rel_pos=True,mm=True,home=[0,20,0]):
self.cmd_list.append('%')
pass
def setup(self,rel_pos=True,mm=True,home=(0,20,0)):
cmd_list=[]
self.home=home

if rel_pos:
self.cmd_list.append('G91 ; set relative position')
else:
self.cmd_list.append('G90 ; set absolute position')
self.pos=rel_pos
if mm:
self.cmd_list.append('G21 ; mm')
cmd_list.append('G21 ; mm')
else:
cmd_list.append('G20 ; inches')
cmd_list.append('G90 ; set absolute position for homing')
cmd_list.append('G00 X{x} Y{y} Z{z} ; go to set home'.format(x=str(home[0]), y=str(home[1]), z=str(home[2])))
if self.pos:
cmd_list.append('G91 ; set relative position')
else:
self.cmd_list.append('G20 ; inches')
self.cmd_list.append('G00 X{x} Y{y} Z{z} ; go to set home'.format(x=str(home[0]), y=str(home[1]), z=str(home[2])))
cmd_list.append('G90 ; set absolute position')
return tuple(cmd_list)
def add_movement(self,x=0,y=0,z=0,speed=200):
if (x!=0 or y!=0 or z!=0):
cmd='G01 '
Expand All @@ -28,54 +27,36 @@ def add_movement(self,x=0,y=0,z=0,speed=200):
if z!=0:
cmd+='Z{coordz} '.format(coordz=str(z))
cmd+='F{f}'.format(f=str(speed))
self.cmd_list.append(cmd)
return tuple([cmd])
else:
pass
def add_home(self):
self.cmd_list.append('G00 X{x} Y{y} Z{z} ; go to set home'.format(x=str(self.home[0]), y=str(self.home[1]), z=str(self.home[2])))
cmd_list=[]
old_pos=self.pos
cmd_list.append(self.change_pos(rel_pos=False))
cmd_list.append('G00 X{x} Y{y} Z{z} ; go to set home'.format(x=str(self.home[0]), y=str(self.home[1]), z=str(self.home[2])))
cmd_list.append(self.change_pos(old_pos))
return tuple(cmd_list)
def add_fan(self,speed=255):
if speed=255:
self.cmd_list.append('M106 ; use fan'.format(s=str(speed)))
if speed==255:
return tuple(['M106 ; use fan'])
elif speed==0:
return tuple(['M107 ; use fan'])
else:
self.cmd_list.append('M106 S{s} ; use fan'.format(s=str(speed)))
return tuple(['M106 S{s} ; use fan'.format(s=str(speed))])
def change_pos(self,rel_pos=True):
if rel_pos:
self.cmd_list.append('G91 ; set relative position')
self.pos=rel_pos
if self.pos:
return tuple(['G91 ; set relative position'])
else:
self.cmd_list.append('G90 ; set absolute position')
return tuple(['G90 ; set absolute position'])
def change_mm(self,mm=True):
if mm:
self.cmd_list.append('G21 ; mm')
return tuple(['G21 ; mm'])
else:
self.cmd_list.append('G20 ; inches')
def change_home(self,home=[0,20,0]):
return tuple(['G20 ; inches'])
def change_home(self,home=(0,20,0)):
self.home=home
def parse(self, target=''):
if self.cmd_list[len(self.cmd_list)-1]!='%':
self.cmd_list.append('%')
if len(target)>0:
if target=='stdout':
output=''
for cmd in self.cmd_list:
print('Parsing '+cmd+'...')
output+=cmd+'\n'
return output
else:
f=open(target,'w')
for cmd in self.cmd_list:
print('Parsing '+cmd+'...')
f.write(cmd+'\n')
f.close()

else:
f=open('output.gcode','w')
for cmd in self.cmd_list:
print('Parsing '+cmd+'...')
f.write(cmd+'\n')
f.close()
def clear(self):
self.cmd_list=[]




Expand Down
31 changes: 31 additions & 0 deletions src/robotic_chess/octoprint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from os import system as cmd
from os.path import exists
class PrinterError(Exception):
pass
class Printer:
def __init__(self):
self.loaded_file=False
cmd('octoprint-cli connection connect')
def load_file(self, file='./output.gcode'):
if exists(file):
self.loaded_file=True
cmd('octoprint-cli print select {path}'.format(path=str(file)))
else:
raise PrinterError('File selected was invalid')
def start_file(self):
if self.loaded_file:
cmd('octoprint-cli print start')
self.loaded_file=False
else:
raise PrinterError('No file selected using Printer.load_file()')
def run_gcode(self,gcode=()):
if str(type(gcode))=='<class \'tuple\'>':
for gcmd in gcode:
cmd('octoprint-cli gcode {command}'.format(command=str(gcmd)))
else:
raise PrinterError('gcode was not in tuple form')
def connect(self):
# should never be called
cmd('octoprint-cli connection connect')
def disconnect(self):
cmd('octoprint-cli connection disconnect')

0 comments on commit a0f5f74

Please sign in to comment.