1
0
forked from MDL29/JacoBot

Compare commits

...

23 Commits
main ... main

Author SHA1 Message Date
3ee3598dc2 37: Create motor encoder Fritzing component: fix SVG files. 2024-06-08 13:17:07 +00:00
408a74e199 37: Create motor encoder Fritzing component: add SVG files and README. 2024-06-08 13:17:07 +00:00
8a1dca2190 Revome test method 2024-06-05 20:14:48 +00:00
9e43fb4334 Remove useless import 2024-06-05 20:14:48 +00:00
ec329a60cf Fix crash 2024-06-05 20:14:48 +00:00
fa1acdbc0a Fix token reset on R key press 2024-06-05 20:14:48 +00:00
450c44ade3 Rename some constants 2024-06-05 20:14:48 +00:00
65e6b11b37 Delete useless docstrings 2024-06-05 20:14:48 +00:00
962f65a8d0 Change names : case to tile and up to forward 2024-06-05 20:14:48 +00:00
d19fc05b28 Add a fonction to get instructions 2024-06-05 20:14:48 +00:00
87b2432543 Add the pad 2024-06-05 20:14:48 +00:00
7af33cf3a3 🍱 Add space level from Cubetto carpet 2024-06-05 11:41:30 +02:00
6e3aeca232 Create a full screen option for the virtual pad #77
MDL29/JacoBot#77
2024-05-18 13:04:47 +00:00
59943dc54d Imrpove robot move
close MDL29/JacoBot#80
2024-05-13 16:51:40 +02:00
792fec50d6 🤖 Add & move robot on the grid 2024-05-12 19:11:36 +02:00
ec40c35fda 💄 Draw grid from a level
MDL29/JacoBot#40
MDL29/JacoBot#72
2024-05-12 19:11:33 +02:00
ce7df429b9 💄 Create a level from Cubetto wodden carpet
MDL29/JacoBot#40
MDL29/JacoBot#72
2024-05-12 19:11:05 +02:00
557dc54acc 🍱 Add wodden tile from Cubetto carpet
MDL29/JacoBot#40
2024-05-12 19:07:50 +02:00
bb0b2caa80 Add pdbr as developement dependancy
Improve debugger with rich library : https://pypi.org/project/pdbr/
2024-05-12 18:37:30 +02:00
0d530b9ad6 Fix the garbage zone for the virtual pad #34 2024-04-27 23:57:01 +02:00
041307a28c Add flake8 linter 2024-04-25 14:46:29 +00:00
21d334ddb9 Improve README 2024-04-25 16:07:38 +02:00
5008db05e1 Creates a garbage zone for the virtual pad #34
close MDL29/JacoBot#34
2024-04-25 15:47:50 +02:00
59 changed files with 1107 additions and 42 deletions

Binary file not shown.

66
doc/fritzing/README.md Normal file
View File

@ -0,0 +1,66 @@
# Create Component part for Fritzing
## Installation
Install:
* Fritzing
* Inkscape
Fritzing installation (Debian 12):
`
$ sudo apt install fritzing
`
Inkscape installation (Debian 12):
`
$ sudo apt install inkscape`
## Fonts installation
Install fonts for Fritzing components definition:
* download file from [](https://fritzing.org/learning/tutorials/creating-custom-parts/download-fonts-and-templates)
`
$ wget https://fritzing.org/media/uploads/learning/graphic_standards/fontsandtemplates.zip
`
Install fonts from the zip file:
* DroidSans
* OCR A
## Inkscape
Use Inkscape to define:
* the Fritzing breadboard svg file
* the Fritzing schematic svg file and
* the Fritzing PCB svg file
You can start using the templates provided in the fontsandtemplates.zip file.
## Frizting
Steps to create a new component:
* new project
* drag and drop in the breadboard and existing component
* click Component menu / Edit (new componnent)
* load svg file for each tabs (breadboard, schematic, PCB)
* change the metadata in Metadata tab
* change the number and definition of pins in Connectors tab
* for each view, select pin and link it to a graphical part of the svg drawings
Finally, save the Fritzing new component in **My Parts** tab.
## This directory content
This directory contains svg files for:
* breadboard and icon: lph_gear_motor_encoder_icon.svg
* schematic: lph_gear_motor_encoder_schematic.svg
* PCB: lph_gear_motor_encoder_pcb.svg
# References
* https://wiki.dfrobot.com/Micro_DC_Motor_with_Encoder-SJ01_SKU__FIT0450
* https://github.com/Arduinolibrary/DFRobot_Micro_DC_Geared_Motor_with_Encoder/

View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
height="124.32"
width="257.952"
viewBox="0 0 2687.011 1294.646"
version="1.1"
id="svg580"
sodipodi:docname="lph_gear_motor_encoder_icon.svg"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs584" />
<sodipodi:namedview
id="namedview582"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="5.9041993"
inkscape:cx="91.96844"
inkscape:cy="62.159148"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg580" />
<path
fill="#e6e6e6"
d="M2080.526 0h152.528v1294.646h-152.528z"
id="path544" />
<g
fill="#ffd42a"
id="g550">
<path
d="M1136.29 265.875h1399.36v762.885H1136.29z"
id="path546" />
<path
d="M2471.29 589.442h215.708v115.75H2471.29z"
id="path548" />
</g>
<g
fill="#4d4d4d"
id="g556">
<path
d="M28.028 436.43h127.14c15.486 0 28.042 12.542 28.042 28.028V831.65c0 15.472-12.542 28.028-28.042 28.028H28.028C12.542 859.678 0 847.108 0 831.636V464.443c0-15.472 12.542-28.014 28.028-28.014z"
id="path552" />
<path
d="M102.805 343.694h102.597c22.264 0 40.306 18.042 40.306 40.305v528.08c0 22.264-18.056 40.305-40.306 40.305H102.805c-22.264 0-40.306-18.055-40.306-40.305V384c0-22.264 18.056-40.305 40.306-40.305z"
id="path554" />
</g>
<path
d="M822.166 293.305l27.903-26.86h22.306m-50.21 734.885l27.903 26.86h22.306"
stroke-miterlimit="1"
fill="none"
stroke="#fc0"
stroke-width="7.847"
stroke-linecap="round"
id="path558" />
<path
fill="#ffd42a"
d="M712.194 289.027h427.82v717.996h-427.82z"
id="path560" />
<path
fill="#d4aa00"
stroke="#d4aa00"
stroke-width="2.378"
d="M1101.193 292.403h31.736v711.26h-31.736z"
id="path562" />
<path
fill="#ccc"
d="M183.208 323.444h528.986V972.62H183.208z"
id="path564" />
<path
d="M2687.01 647.318H712.194"
opacity=".45"
fill="#fc0"
stroke="#d4aa00"
stroke-width="3.475"
id="path566" />
<path
d="M119.687 293.47a9.83 9.83 0 0 1 9.833 9.847v30.528a9.83 9.83 0 0 1-9.833 9.847 9.84 9.84 0 0 1-9.847-9.847v-30.528a9.85 9.85 0 0 1 9.847-9.847z"
fill="#fff"
id="path570" />
<path
d="M114 284.187h9.764v10.458H114zm0 699.986h9.764v10.472H114z"
fill="#e6e6e6"
id="path576" />
<path
d="M402.6 867.705V849.69c.028-2.347.792-4.64 2.278-6.86s3.278-3.847 5.375-4.917l18.236-9c3.292-1.694 6.722-2.556 10.306-2.556 3.333 0 6.75.903 10.25 2.708l18.014 9.056a13.86 13.86 0 0 1 5.556 4.986c1.39 2.166 2.083 4.597 2.083 7.264v17.417a4.31 4.31 0 0 1-1.361 3.222c-.903.9-1.972 1.333-3.194 1.333-1.264 0-2.36-.43-3.278-1.333-.917-.875-1.4-1.958-1.4-3.222v-4.778h-53.653v4.667a4.23 4.23 0 0 1-1.39 3.222 4.55 4.55 0 0 1-3.278 1.333 4.33 4.33 0 0 1-3.194-1.333c-.903-.847-1.36-1.917-1.36-3.194zm9.222-13.778h53.764l-.014-3.18c0-2.028-.986-3.528-2.986-4.542l-17.903-9c-2.347-1.125-4.32-1.694-5.917-1.708a12.28 12.28 0 0 0-5.639 1.361l-18.556 9.333c-1.847.972-2.764 2.57-2.764 4.778v2.958zm53.765-73.874V763.6a4.56 4.56 0 0 1 1.333-3.292c.9-.917 1.958-1.4 3.222-1.4s2.333.458 3.222 1.4 1.333 2.028 1.333 3.278v17.042c0 2.167-.68 4.417-2.056 6.722-1.375 2.32-2.903 3.93-4.6 4.833l-20.347 10.528c-2.93 1.417-5.93 2.1-9 2.1-3.403 0-6.347-.667-8.847-2.014l-20.125-10.625c-1.875-1-3.528-2.583-4.958-4.722-1.43-2.125-2.14-4.194-2.14-6.18v-18.014c0-1.264.458-2.333 1.36-3.222.903-.875 1.972-1.333 3.194-1.333a4.55 4.55 0 0 1 3.278 1.333c.917.9 1.4 1.972 1.4 3.222v17.347c0 1.444.86 2.625 2.556 3.542l18.86 10.1c1.486.806 3.236 1.194 5.264 1.18 2.14.014 4.028-.417 5.653-1.292l18.556-9.653c1.917-.903 2.875-2.403 2.86-4.458zM411.722 624.93h17.083c3.986 0 7.194 1.222 9.653 3.694 2.82-2.528 5.9-3.792 9.222-3.792h17.792c2.5 0 4.64.903 6.43 2.708a8.92 8.92 0 0 1 2.681 6.514v32.222c0 1.278-.444 2.347-1.333 3.222a4.38 4.38 0 0 1-3.222 1.333c-1.264 0-2.333-.43-3.222-1.333-.9-.875-1.333-1.958-1.333-3.222V634.15H447.68a4.55 4.55 0 0 0-3.278 1.333c-.917.9-1.4 1.958-1.4 3.222v18.333c0 1.278-.43 2.347-1.306 3.222-.875.9-1.958 1.333-3.25 1.333-1.264 0-2.333-.43-3.222-1.333-.9-.875-1.333-1.958-1.333-3.222v-18.444c0-1.222-.444-2.306-1.333-3.194s-1.958-1.36-3.222-1.36h-17.64v32.555c0 1.278-.444 2.347-1.333 3.222a4.38 4.38 0 0 1-3.222 1.333c-1.264 0-2.333-.43-3.222-1.333-.9-.875-1.333-1.958-1.333-3.222V634.04c0-2.528.9-4.68 2.68-6.458s3.958-2.653 6.444-2.653zm26.638-67.112h4.014a4.55 4.55 0 0 1 3.278 1.333c.917.9 1.4 1.958 1.4 3.222v36.778c0 1.264-.458 2.333-1.4 3.222s-2.014 1.333-3.278 1.333h-4.014a4.38 4.38 0 0 1-4.556-4.556v-36.778c0-1.153.43-2.208 1.278-3.153s1.944-1.403 3.278-1.403zm-35.75-25.875v-4.556c0-1.264.458-2.333 1.36-3.222s1.972-1.333 3.194-1.333a4.38 4.38 0 0 1 4.556 4.556h30.1v-32.125c0-1.222.458-2.306 1.4-3.194s2.014-1.36 3.278-1.36h23.542c1.264 0 2.333.458 3.222 1.4s1.333 2.014 1.333 3.278v36.57c0 1.264-.458 2.36-1.36 3.278s-1.972 1.4-3.194 1.4h-62.875c-1.264 0-2.333-.458-3.222-1.36s-1.333-2.014-1.333-3.306zm48.444-4.458h14.43V499.93h-14.43zm-43.777-104.11h16.764l47.25 18.57c2.292.93 3.43 2.417 3.43 4.43 0 2.125-1.14 3.653-3.417 4.556l-47.25 18.444H407.3c-1.306 0-2.403-.444-3.306-1.333a4.38 4.38 0 0 1-1.36-3.236c0-1.264.458-2.347 1.36-3.236s2.014-1.333 3.306-1.333h14.86l35.375-13.875-35.278-13.875h-14.972c-1.306 0-2.403-.444-3.306-1.333a4.38 4.38 0 0 1-1.36-3.236c0-1.264.458-2.347 1.36-3.236s2-1.306 3.306-1.306z"
id="path578" />
<rect
style="fill:#000000;stroke-width:13.9513"
id="rect735"
width="46.684719"
height="295.86975"
x="424.99976"
y="32.252914" />
<rect
style="fill:#999999;stroke-width:13.308"
id="rect789"
width="82.355682"
height="217.49408"
x="342.64404"
y="32.252914" />
<rect
style="fill:#999999;stroke-width:13.308"
id="rect791"
width="82.355682"
height="217.49408"
x="470.58252"
y="32.252914" />
<rect
style="fill:#000000;stroke-width:10.4167"
id="rect793"
width="61.088448"
height="32.584198"
x="281.55557"
y="70.205444" />
<rect
style="fill:#ff0000;stroke-width:10.4167"
id="rect899"
width="61.088448"
height="32.584198"
x="281.55557"
y="153.53911" />
<path
style="fill:#ff0000;stroke-width:10.4167"
d="m 552.39078,187.21392 v 32.57257 h 61.09644 v -32.57257 z"
id="path930" />
<path
style="fill:#000000;stroke-width:10.4167"
d="m 552.39078,145.54709 v 32.57256 h 61.09644 v -32.57256 z"
id="path928" />
<path
style="fill:#0000ff;stroke-width:10.4167"
d="m 552.39078,103.88025 v 32.57256 h 61.09644 v -32.57256 z"
id="path926" />
<path
style="fill:#008000;stroke-width:10.4167"
d="m 552.39078,62.213415 v 32.572562 h 61.09644 V 62.213415 Z"
id="rect901" />
</svg>

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="30.24px"
height="30.24px"
viewBox="0 0 30.24 30.24"
enable-background="new 0 0 30.24 30.24"
xml:space="preserve"
sodipodi:docname="lph_gear_motor_encoder_pcb.svg"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs2096">
</defs><sodipodi:namedview
id="namedview2094"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="25.859789"
inkscape:cx="15.12"
inkscape:cy="15.12"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" />
<g
id="silkscreen">
<line
fill="none"
stroke="#FFFFFF"
stroke-width="0.75"
x1="0.72"
y1="0.72"
x2="0.72"
y2="29.52"
id="line2069" />
<line
fill="none"
stroke="#FFFFFF"
stroke-width="0.75"
x1="0.72"
y1="29.52"
x2="29.521"
y2="29.52"
id="line2071" />
<line
fill="none"
stroke="#FFFFFF"
stroke-width="0.75"
x1="29.521"
y1="29.52"
x2="29.521"
y2="0.72"
id="line2073" />
<line
fill="none"
stroke="#FFFFFF"
stroke-width="0.75"
x1="0.72"
y1="0.72"
x2="11.52"
y2="0.72"
id="line2075" />
<line
fill="none"
stroke="#FFFFFF"
stroke-width="0.75"
x1="18.72"
y1="0.72"
x2="29.521"
y2="0.72"
id="line2077" />
</g>
<circle
id="connector5pin"
fill="none"
stroke="#ffbf00"
stroke-width="1.152"
cx="25.92"
cy="18.719999"
r="1.584" /><circle
id="connector0pin"
fill="none"
stroke="#ffbf00"
stroke-width="1.152"
cx="4.3200002"
cy="4.3200002"
r="1.584" /><circle
id="connector1pin"
fill="none"
stroke="#ffbf00"
stroke-width="1.152"
cx="4.3200002"
cy="11.52"
r="1.584" /><circle
id="connector4pin"
fill="none"
stroke="#ffbf00"
stroke-width="1.152"
cx="25.92"
cy="25.92"
r="1.584" /><circle
id="connector6pin"
fill="none"
stroke="#ffbf00"
stroke-width="1.152"
cx="25.92"
cy="11.52"
r="1.584" /><circle
id="connector7pin"
fill="none"
stroke="#ffbf00"
stroke-width="1.152"
cx="25.92"
cy="4.3200002"
r="1.584" />
<g
id="keepout">
</g>
<g
id="soldermask">
</g>
<g
id="outline">
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -0,0 +1,303 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 15.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
version="1.2"
id="Layer_1"
x="0px"
y="0px"
width="57.643px"
height="71.833px"
viewBox="0 0 57.643 71.833"
xml:space="preserve"
sodipodi:docname="lph_gear_motor_encoder_schematic.svg"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs1455">
</defs><sodipodi:namedview
id="namedview1453"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="10.886361"
inkscape:cx="28.935289"
inkscape:cy="31.323598"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" />
<rect
id="part_symbol"
x="7.1999998"
y="7.1999998"
fill="#ffffff"
stroke="#000000"
stroke-width="0.9002"
stroke-linecap="round"
width="43.199001"
height="57.598999" /><text
fill="#555555"
font-family="DroidSans"
font-size="4.5px"
id="text1426-2"
x="14.601288"
y="62.0037">V</text><text
fill="#555555"
font-family="DroidSans"
font-size="4.5px"
id="text1428-3"
x="17.022188"
y="62.0037">c</text><text
fill="#555555"
font-family="DroidSans"
font-size="4.5px"
id="text1430-7"
x="19.106089"
y="62.0037">c</text><line
fill="none"
stroke="#555555"
stroke-width="0.7"
stroke-linecap="round"
stroke-linejoin="round"
x1="41.336124"
y1="-0.1808724"
x2="41.336124"
y2="7.020124"
id="line1370-2" /><g
id="g1372">
<line
fill="none"
stroke="#555555"
stroke-width="0.7"
stroke-linecap="round"
stroke-linejoin="round"
x1="28.799999"
y1="64.799004"
x2="28.799999"
y2="72"
id="line1370" />
</g><g
id="g1372-5"
transform="translate(-10.687967)">
<line
fill="none"
stroke="#555555"
stroke-width="0.7"
stroke-linecap="round"
stroke-linejoin="round"
x1="28.799999"
y1="64.799004"
x2="28.799999"
y2="72"
id="line1370-9" />
</g><g
id="g1384">
<line
fill="none"
stroke="#555555"
stroke-width="0.7"
stroke-linecap="round"
stroke-linejoin="round"
x1="28.799999"
y1="7.2010002"
x2="28.799999"
y2="0"
id="line1382" />
</g><g
id="g1388"
transform="translate(0,10)">
<line
fill="none"
stroke="#555555"
stroke-width="0.7"
stroke-linecap="round"
stroke-linejoin="round"
x1="50.401001"
y1="28.799999"
x2="57.599998"
y2="28.799999"
id="line1386" />
</g><g
id="g1392"
transform="translate(0,2)">
<line
fill="none"
stroke="#555555"
stroke-width="0.7"
stroke-linecap="round"
stroke-linejoin="round"
x1="50.401001"
y1="21.6"
x2="57.599998"
y2="21.604"
id="line1390" />
</g><text
fill="#555555"
font-family="DroidSans"
font-size="3px"
id="text1395"
x="53.310799"
y="22.154301">5</text><text
fill="#555555"
font-family="DroidSans"
font-size="3px"
id="text1397"
x="53.1409"
y="37.4492">6</text><text
fill="#555555"
font-family="DroidSans"
font-size="3px"
id="text1401"
x="30.162399"
y="3.8729999">1</text><text
fill="#555555"
font-family="DroidSans"
font-size="3px"
id="text1403"
x="30.162399"
y="69.109901">4</text><text
fill="#555555"
font-family="DroidSans"
font-size="3px"
id="text1403-22"
x="19.382944"
y="69.476166">3</text><text
fill="#555555"
font-family="DroidSans"
font-size="3px"
id="text1403-2"
x="43.751019"
y="3.8634784">2</text><text
fill="#555555"
font-family="DroidSans"
font-size="4.5px"
id="text1424"
x="24.6106"
y="62.484901">Gnd</text><text
fill="#555555"
font-family="DroidSans"
font-size="4.5px"
id="text1424-9"
x="37.544281"
y="12.616499">Gnd</text><text
fill="#555555"
font-family="DroidSans"
font-size="4.5px"
id="text1426"
x="25.511999"
y="12.5352">V</text><text
fill="#555555"
font-family="DroidSans"
font-size="4.5px"
id="text1428"
x="27.932899"
y="12.5352">c</text><text
fill="#555555"
font-family="DroidSans"
font-size="4.5px"
id="text1430"
x="30.0168"
y="12.5352">c</text><text
fill="#555555"
font-family="DroidSans"
font-size="4.5px"
id="text1440"
x="27.99662"
y="25.018021"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Droid Sans Mono';-inkscape-font-specification:'Droid Sans Mono'"><tspan
sodipodi:role="line"
id="tspan1981"
x="27.99662"
y="25.018021">Out Blue </tspan><tspan
sodipodi:role="line"
id="tspan1983"
x="27.99662"
y="30.643021" /></text><text
fill="#555555"
font-family="DroidSans"
font-size="4.5px"
id="text1442"
x="27.906532"
y="39.373055">Out Green</text><text
font-family="DroidSans"
font-size="6px"
id="text1447"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.33333px;font-family:'Droid Sans Mono';-inkscape-font-specification:'Droid Sans Mono'"
x="9.6147776"
y="17.202038">DC Motor </text><text
font-family="DroidSans"
font-size="6px"
id="text1447-0"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.33333px;font-family:'Droid Sans Mono';-inkscape-font-specification:'Droid Sans Mono'"
x="13.811852"
y="55.412983">DC Coder </text>
</svg>

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -17,9 +17,9 @@ poetry install
~~~
Run the virtual pad with :
~~~
poetry run jacovirt-pad
poetry run jacovirt pad
~~~
Run the virtual bot with :
~~~
poetry run jacovirt-bot
~~~
poetry run jacovirt bot
~~~

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -0,0 +1,51 @@
import arcade
import logging
class Bot(arcade.Sprite):
"""
Bot sprite
"""
def __init__(self, start, grid, scale=0.75):
self.sprite = ":resources:images/space_shooter/playerShip1_green.png"
self.grid = grid
self.pos = list(start)
super().__init__(self.sprite, scale, hit_box_algorithm="None")
self.set_pos()
self.angle = 270
def set_pos(self):
for tile in self.grid.tiles:
if tile.pos == tuple(self.pos):
self.position = tile.position
logging.debug(f"Move bot to {self.pos} - {self.position}")
break
def left(self):
self.angle += 90
if self.angle >= 360:
self.angle -=360
def right(self):
self.angle -= 90
if self.angle < 0:
self.angle += 360
def forward(self):
match self.angle:
case 0:
if self.pos[1] < self.grid.column - 1:
self.pos[1] += 1
case 90:
if self.pos[0] > 0:
self.pos[0] -= 1
case 180:
if self.pos[1] > 0:
self.pos[1] -= 1
case 270:
if self.pos[0] < self.grid.row - 1:
self.pos[0] += 1
self.set_pos()

View File

@ -0,0 +1,61 @@
import arcade
from importlib import resources
from jacovirt.bot.level import space as level
class Tile(arcade.Sprite):
"""
Tile sprite
"""
def __init__(self, x, y, start_x, start_y, size=100, spacing=10, scale=0.5):
self.pos = (x, y)
self.theme = level.get("theme")
self.sprite = level.get(self.pos)
with resources.path("jacovirt", 'Img') as img_folder :
self.image_file_name = f"{img_folder}/bot/{self.theme}/{self.sprite}.png"
self.size = size
self.spacing = spacing
super().__init__(self.image_file_name, scale, hit_box_algorithm="None")
self.position = (
start_x + x * (self.size + self.spacing) + self.size / 2,
start_y + y * (self.size + self.spacing) + self.size / 2
)
def debug(self, size=10):
arcade.draw_text(
self.pos,
self.left + self.spacing,
self.bottom + self.spacing,
arcade.color.RED,
size,
)
class Grid():
"""
Grid object
"""
def __init__(self, x, y, row=6, column=6, size=100, spacing=10):
self.row = row
self.column = column
self.pos = (x, y)
self.tiles = arcade.SpriteList()
for r in range(row):
for c in range(column):
self.tiles.append(
Tile(
x=r,
y=c,
start_x=x,
start_y=y,
size=size,
spacing=spacing
)
)

View File

@ -0,0 +1,79 @@
wooden = {
"theme": "wooden",
(0,0): "wave",
(0,1): "castle",
(0,2): "wave",
(0,3): "tile_1",
(0,4): "R",
(0,5): "start",
(1,0): "city",
(1,1): "tile_6",
(1,2): "tile_3",
(1,3): "tile_2",
(1,4): "tree",
(1,5): "tile_1",
(2,0): "wave",
(2,1): "wave",
(2,2): "mountain",
(2,3): "tile_4",
(2,4): "wave",
(2,5): "G",
(3,0): "B",
(3,1): "tile_2",
(3,2): "tile_4",
(3,3): "Y",
(3,4): "wave",
(3,5): "tile_2",
(4,0): "wave",
(4,1): "P",
(4,2): "tile_3",
(4,3): "tile_1",
(4,4): "tile_2",
(4,5): "tile_5",
(5,0): "wave",
(5,1): "tile_1",
(5,2): "wave",
(5,3): "boat",
(5,4): "tile_1",
(5,5): "tile_4",
}
space = {
"theme": "space",
(0,0): "tile_1",
(0,1): "planet_5",
(0,2): "tile_10",
(0,3): "tile_9",
(0,4): "planet_2",
(0,5): "start",
(1,0): "system",
(1,1): "tile_8",
(1,2): "tile_1",
(1,3): "tile_11",
(1,4): "crater",
(1,5): "tile_1",
(2,0): "tile_11",
(2,1): "tile_3",
(2,2): "volcano",
(2,3): "meteor",
(2,4): "satellite",
(2,5): "planet_1",
(3,0): "planet_4",
(3,1): "tile_7",
(3,2): "tile_10",
(3,3): "planet_3",
(3,4): "tile_2",
(3,5): "tile_12",
(4,0): "meteor",
(4,1): "mountain",
(4,2): "tile_1",
(4,3): "tile_10",
(4,4): "tile_13",
(4,5): "meteor",
(5,0): "tile_13",
(5,1): "tile_6",
(5,2): "tile_5",
(5,3): "rocket",
(5,4): "tile_4",
(5,5): "tile_13",
}

View File

@ -2,16 +2,26 @@ import arcade
import jacovirt.logger
import logging
from jacovirt.bot.grid import Grid
from jacovirt.bot.bot import Bot
# Screen title and size
SCREEN_TITLE = "JacoVirt Bot"
SCREEN_MULTILPLIER = 1
SCREEN_WIDTH = int(1000 * SCREEN_MULTILPLIER)
SCREEN_HEIGHT = int(1000 * SCREEN_MULTILPLIER)
SCREEN_WIDTH = int(1000)
SCREEN_HEIGHT = int(1000)
# Window color
BACKGROUND_COLOR = arcade.color.CATALINA_BLUE
class Bot(arcade.Window):
COLUMN = 6
ROW = 6
TILE_SIZE = 100
TILE_SPACING = 10
X_START = (SCREEN_HEIGHT - (TILE_SIZE + TILE_SPACING) * ROW) / 2
Y_START = (SCREEN_WIDTH - (TILE_SIZE + TILE_SPACING) * COLUMN) / 2
class Window(arcade.Window):
"""Main application class"""
def __init__(self):
@ -20,27 +30,50 @@ class Bot(arcade.Window):
# Set background color
arcade.set_background_color(BACKGROUND_COLOR)
self.grid = None
self.bot = None
def setup(self):
"""Set up the pad"""
logging.info("Set up the bot.")
self.grid = Grid(X_START, Y_START, ROW, COLUMN, TILE_SIZE, TILE_SPACING)
self.bot = Bot((0,5), self.grid)
def on_draw(self):
"""Render the screen"""
# Clear the screen
self.clear()
# Draw tiles
self.grid.tiles.draw()
# If debug log level, draw info for tiles
if logging.root.level <= logging.DEBUG:
for tile in self.grid.tiles:
tile.debug()
self.bot.draw()
def on_key_press(self, symbol, modifiers):
"""Called when the user presses key"""
if symbol == arcade.key.R:
logging.info("Restart !")
self.setup()
print("Restart !")
if symbol == arcade.key.Q:
arcade.exit()
if symbol == arcade.key.LEFT:
self.bot.left()
if symbol == arcade.key.RIGHT:
self.bot.right()
if symbol == arcade.key.UP:
self.bot.forward()
def main():
"""Main method"""
window = Bot()
window = Window()
window.setup()
arcade.run()
arcade.run()

View File

@ -0,0 +1,54 @@
import arcade
class Tile(arcade.SpriteSolidColor):
def __init__(self, x, y, start_x, start_y, size=100, spacing=10, scale=0.5, color=arcade.color.AMBER):
super().__init__(size, size, color=color)
self.size = size
self.spacing = spacing
self.position = (
start_x + x*(size + spacing),
start_y - y*(size + spacing)
)
class Pad():
def __init__(self, x, y, row=6, column=6, size=100, spacing=10):
self.row = row
self.column = column
self.pos = (x, y)
self.tiles = arcade.SpriteList()
for r in range(row):
for c in range(column):
self.tiles.append(
Tile(
x=c,
y=r,
start_x=x,
start_y=y,
size=size,
spacing=spacing
)
)
def get_instructions(self, token_list):
instructions = []
if len(token_list) > 0:
for tile in self.tiles:
token, distance = arcade.get_closest_sprite(tile, token_list)
if arcade.check_for_collision(token, tile):
token_type = str(token.token_type)
if token_type == "forward":
instructions.append("forward")
if token_type == "left":
instructions.append("left")
if token_type == "right":
instructions.append("right")
return instructions

View File

@ -5,7 +5,7 @@ from importlib import resources
class Token(arcade.Sprite):
""" Token sprite """
def __init__(self, token_type, scale=1):
def __init__(self, token_type, scale=0.70):
# Attributes for token type
self.token_type = token_type
@ -13,7 +13,7 @@ class Token(arcade.Sprite):
self.image_file_name = f"{img_folder}/pad/token/{self.token_type}.png"
# Call the parent
super().__init__(self.image_file_name, scale, hit_box_algorithm="None")
super().__init__(self.image_file_name, scale=scale, hit_box_algorithm="None")
class Token_generator(arcade.Sprite):
@ -38,4 +38,12 @@ class Token_generator(arcade.Sprite):
return token
def draw_tokens(self):
self.tokens.draw()
self.tokens.draw()
class Token_trash(arcade.SpriteSolidColor):
def __init__(self, height, width, color=arcade.color.AMERICAN_ROSE):
super().__init__(width, height, color)
def remove_token(self, held_token):
held_token.remove_from_sprite_lists()

View File

@ -1,19 +1,27 @@
import arcade
import jacovirt.logger
import logging
from jacovirt.pad.token import Token, Token_generator
from jacovirt.pad.token import Token_generator, Token_trash
from jacovirt.pad.pad import Pad
# Screen title and size
SCREEN_TITLE = "Jaco Pad"
SCREEN_MULTILPLIER = 1
SCREEN_WIDTH = int(1000* SCREEN_MULTILPLIER)
SCREEN_HEIGHT = int(1000* SCREEN_MULTILPLIER)
SCREEN_WIDTH = int(1100)
SCREEN_HEIGHT = int(1000)
# Window color
BACKGROUND_COLOR = (133, 100, 100)
# Pad
PAD_X_START = 600
PAD_Y_START = 780
PAD_ROW = 5
PAD_COLUMN = 4
TILE_SIZE = 125
TILE_SPACING = 10
class Pad(arcade.Window):
class Window(arcade.Window):
"""Main application class"""
def __init__(self):
@ -25,89 +33,188 @@ class Pad(arcade.Window):
# List of token generator
self.tokens_generator = arcade.SpriteList()
# List of trash
self.tokens_trash = arcade.SpriteList()
# The held token
self.held_token = None
# List of tokens
self.tokens = arcade.SpriteList()
self.pad = None
def setup(self):
"""Set up the pad"""
logging.info("Set up the pad.")
logging.debug("Set up the pad.")
# Create a token
token = Token("up", 1*SCREEN_MULTILPLIER)
token.position = 500, 500
self.tokens.append(token)
# Create a camera
self.camera = arcade.Camera()
# Create a token generator
token_generator = Token_generator("up", 1*SCREEN_MULTILPLIER)
token_generator.position = 200, 500
token_generator = Token_generator("forward", 1)
token_generator.position = 100, 780
self.tokens_generator.append(token_generator)
# Create a other token generator
token_generator = Token_generator("right", 1*SCREEN_MULTILPLIER)
token_generator.position = 800, 500
# Create a right token generator
token_generator = Token_generator("right", 1)
token_generator.position = 250, 780
self.tokens_generator.append(token_generator)
# Create a left token generator
token_generator = Token_generator("left", 1)
token_generator.position = 400, 780
self.tokens_generator.append(token_generator)
# Create a trash for token
trash = Token_trash(150, 150)
trash.position = 60, 60
self.tokens_trash.append(trash)
# Setup the pad
self.pad = Pad(PAD_X_START, PAD_Y_START, PAD_ROW, PAD_COLUMN, TILE_SIZE, TILE_SPACING)
def on_draw(self):
"""Render the screen"""
# Clear the screen
self.clear()
# Draw the pad
self.pad.tiles.draw()
# Draw the token generator
self.tokens_generator.draw()
# Draw the trash
self.tokens_trash.draw()
# Draw the tokens
self.tokens.draw()
self.camera.use()
def on_key_press(self, symbol, modifiers):
"""Called when the user presses key"""
logging.debug(f"User press {symbol}, {modifiers}")
if symbol == arcade.key.R:
# Clear existing tokens and generators
self.tokens = arcade.SpriteList()
self.tokens_generator = arcade.SpriteList()
self.setup()
print("Restart !")
logging.info("Restart")
if symbol == arcade.key.Q:
arcade.exit()
if symbol == arcade.key.S:
instruction = self.pad.get_instructions(self.tokens)
logging.debug(f"Instruction : {instruction}")
if symbol == arcade.key.F:
# When the user hits f. Flip between full and not full screen.
if self.fullscreen:
# If in fullscreen, switch to windowed mode
self.set_fullscreen(False)
# Resize the camera to match the window size
width, height = self.get_size()
self.camera.resize(width, height)
# Reset camera position
self.camera.move((0, 0))
else:
# If not in fullscreen, switch to fullscreen mode
# Remember the previous window size
last_width, last_height = self.get_size()
# Switch to fullscreen
self.set_fullscreen(True)
# Adjust camera and window size for fullscreen
width, height = self.get_size()
self.camera.resize(width, height)
# Calculate the difference in center position between last window size and new fullscreen size
self.x_fullscreen_diff = (last_width - width) / 2
self.y_fullscreen_diff = (last_height - height) / 2
# Move camera to keep the same center point in the game
self.camera.move((self.x_fullscreen_diff, self.y_fullscreen_diff))
def on_mouse_press(self, x, y, button, key_modifiers):
"""Called when the user presses a mouse button"""
logging.info(f"Mouse pressed at {x},{y}")
logging.debug(f"Mouse pressed at {x},{y}")
# If the game is in fullscreen mode, adjust mouse coordinates
if self.fullscreen:
x = x + self.x_fullscreen_diff
y = y + self.y_fullscreen_diff
logging.debug(f"Mouse pressed at {x}, {y} in the game window in full screen")
# Get list of tokens we've clicked on
tokens = arcade.get_sprites_at_point((x, y), self.tokens)
# Have we clicked on a token?
if len(tokens) > 0:
# Might be a stack of tokens, get the top one
primary_token = tokens[-1]
# All other cases, grab the token we are clicking on
# All other tiles, grab the token we are clicking on
self.held_token = primary_token
# Save the position
self.held_token_original_position = self.held_token.position
return
# Get the list of generator we've clicked on
generators = arcade.get_sprites_at_point((x, y), self.tokens_generator)
# Have we clicked on a generator ?
if len(generators) > 0:
generator = generators[-1]
logging.info(f"Cliced on the generator of {generator.type}")
logging.debug(f"Cliced on the generator of {generator.type}")
# Create a token and take it
self.held_token = generator.create_token(x, y)
self.held_token = generator.create_token(*generator.position)
self.held_token_original_position = self.held_token.position
self.tokens.append(self.held_token)
def on_mouse_release(self, x, y, button, modifiers):
"""Called when the user presses a mouse button"""
logging.info(f"Mouse relase at {x},{y}")
if self.held_token != None:
logging.debug(f"Mouse relase at {x},{y}")
if self.held_token is not None:
# Find the closest trash
trash, distance = arcade.get_closest_sprite(self.held_token, self.tokens_trash)
# See if we are in contact with the closest trash, if yes delete the held token
if arcade.check_for_collision(self.held_token, trash):
trash.remove_token(self.held_token)
reset_position = True
# Find the closest tile
tile, distance = arcade.get_closest_sprite(self.held_token, self.pad.tiles)
# See if we are in contact with the closest tile
if arcade.check_for_collision(self.held_token, tile):
# Center the token
self.held_token.position = tile.center_x, tile.center_y
# Success, don't reset position of tokens
reset_position = False
if reset_position:
# Where-ever we were dropped, it wasn't valid. Reset the each token's position
# to its original spot.
self.held_token.position = self.held_token_original_position
# Remove the token from the hand
self.held_token = None
def on_mouse_motion(self, x: float, y: float, dx: float, dy: float):
@ -121,6 +228,6 @@ class Pad(arcade.Window):
def main():
"""Main method"""
window = Pad()
window = Window()
window.setup()
arcade.run()

View File

@ -12,6 +12,9 @@ redis = "^5.0.3"
pydantic = "^2.7.1"
rich = "^13.7.1"
[tool.poetry.group.dev.dependencies]
flake8 = "^7.0.0"
pdbr = "^0.8.8"
[build-system]
requires = ["poetry-core"]