Compare commits

..

29 Commits
main ... main

Author SHA1 Message Date
b61f8b5648
📝 Update schematics with right colors (effective ones used on the robot). Fixes #4 2024-06-08 15:00:51 +02:00
5f8c0a03ad Update shematic 2024-05-25 16:44:08 +02:00
e2c390e498 fix pins 2024-05-25 15:48:41 +02:00
5d81b67f0c change pins 2024-05-25 15:43:20 +02:00
fec3adfa8a change pins 2024-05-18 17:28:42 +02:00
9cda222780 change pins 2024-05-18 17:24:20 +02:00
7d8ceba7bf fixes and optimisations 2024-05-11 21:38:01 +02:00
20ae6250fd fix 2024-05-11 17:08:11 +02:00
6ab0a55cd0 fix moter encoder 2024-05-11 16:58:17 +02:00
9de37a2caf
🎨 Reorganize code with platformio project 2024-05-11 15:22:18 +02:00
96a192c0e7 fix 2024-05-11 14:46:39 +02:00
288c1dfe44 JacoBot Final 2024-05-06 22:43:58 +02:00
811252599e Minor fixes 2024-04-25 22:11:03 +02:00
92e8329119 Fix and improve radio 2024-04-25 21:45:43 +02:00
715e715356 Fix and improve radio 2024-04-25 21:43:54 +02:00
b92503fa24 New review++ deluxe supra premium 2024-04-25 15:24:45 +02:00
8d145e1cd8 review final 2024-04-25 11:53:34 +02:00
abec51256d review final 2024-04-25 11:51:26 +02:00
ff397f75bc Review 2024-04-25 11:11:06 +02:00
2020fed424 Merge branch 'main' of git.afpy.org:Adrien/JacoBot into experimental 2024-04-23 19:19:45 +02:00
e8eb8f34a3 Revert "[NOT WORKING] I think I found thomething..."
This reverts commit ea3a44c024.

	modified:   jacobot/arduino/Car.cpp
	modified:   jacobot/arduino/MotorEncoder.cpp
	modified:   jacobot/arduino/main.cpp
	deleted:    jacopad/arduino/.gitkeep
2024-04-23 19:10:31 +02:00
2445f801e7 Revert "Token detection"
This reverts commit 97dd28a88a.

	deleted:    jacopad/arduino/README.md
	deleted:    jacopad/arduino/main.cpp
	deleted:    jacopad/arduino/token.cpp
	deleted:    jacopad/arduino/token.h
2024-04-23 19:05:03 +02:00
97dd28a88a Token detection 2024-04-23 15:38:22 +02:00
Adrien de Joux
ea3a44c024 [NOT WORKING] I think I found thomething... 2024-04-19 20:51:05 +02:00
8294b9c0d1 [NOT WORKING] I try things but it doesn't work :( 2024-04-18 23:18:41 +02:00
1b886bab7d I commit the wrong stl, i am stupid 2024-04-13 18:42:32 +02:00
0fdb58b6cc Start integrate NRF24 module
Author:    Linux_Hat <adrien@d4x.fr>
2024-04-13 18:13:20 +02:00
c2213b3991 Add arduino bumper model 2024-04-12 23:26:42 +02:00
97f126835c [JacoBot] Motor encoder basic Arduino implementation with PID 2024-04-06 15:37:39 +02:00
103 changed files with 703 additions and 1632 deletions

232
.gitignore vendored
View File

@ -1,232 +0,0 @@
### C++ ###
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
### PlatformIO ###
.pioenvs
.piolibdeps
.clang_complete
.gcc-flags.json
.pio
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml
# ruff
.ruff_cache/
# LSP config files
pyrightconfig.json
### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

18
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}

24
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/home/adrien/dev/LPH/JacoBot/jacobot/arduino",
"program": "/home/adrien/dev/LPH/JacoBot/jacobot/arduino/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

59
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,59 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}

Binary file not shown.

View File

@ -1,66 +0,0 @@
# 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

@ -1,150 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -1,150 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,303 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -0,0 +1,47 @@
# JacoBot
Jacobot is a robot that moves on a carpet and is controlled wirelessly by the jacopad.
## Bot
### Shematic
`/jacobot/arduino/shematics/shematic.png`
![picture](https://git.afpy.org/Adrien/JacoBot/raw/branch/main/jacobot/arduino/shematics/shematic.png)
### How it works
Jacobot moves precisely and adapts to the terrain thanks to encoder motors.
### Design
All parts of the JacoPad's tokens tokens are in `/jacobot/parts/tokens/` and `/jacobot/arduino/models/`
## Wireless protocol
The Jacobot and the Jacopad talk via [NRF24L01](https://pecquery.wixsite.com/arduino-passion/le-transmetteur-radio-nrf24l01) following this protocol:
- **Use canal 120**
- **24-character message**
Exemple :
```
"JACOFFRLfLfNNNFFLRLN07"
\__/\________/\____/\/
1 2 3 4
- 1: The first part will always be "JACO",
to differentiate it from other projects using the same canal.
- 2: The second part is the 10 tokens placed on the normal slots.
"F" : Forward
"L" : Left
"R" : Right
"f" : Function
"N" : Nothing
- 3: The third part is the same that the second but for the
function slots and with only 6 tokens.
- 4: The fourth part is the checksum of the 3 others.
```

View File

@ -0,0 +1 @@
# JacoBot Arduino

View File

@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch

View File

@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

View File

@ -0,0 +1,73 @@
{
"C_Cpp_Runner.cCompilerPath": "/home/adrien/.platformio/packages/toolchain-atmelavr/bin/avr-gcc",
"C_Cpp_Runner.cppCompilerPath": "/home/adrien/.platformio/packages/toolchain-atmelavr/bin/avr-g++",
"C_Cpp_Runner.debuggerPath": "/home/adrien/.platformio/packages/toolchain-atmelavr/bin/avr-gdb",
"C_Cpp_Runner.cStandard": "gnu11",
"C_Cpp_Runner.cppStandard": "gnu++11",
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [
"/home/adrien/dev/LPH/JacoBot/jacobot/arduino/jacobot-pio-project/include",
"/home/adrien/dev/LPH/JacoBot/jacobot/arduino/jacobot-pio-project/src",
"/home/adrien/dev/LPH/JacoBot/jacobot/arduino/jacobot-pio-project/.pio/libdeps/uno/PID",
"/home/adrien/dev/LPH/JacoBot/jacobot/arduino/jacobot-pio-project/.pio/libdeps/uno/RF24",
"/home/adrien/dev/LPH/JacoBot/jacobot/arduino/jacobot-pio-project/.pio/libdeps/uno/RF24/utility",
"/home/adrien/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
"/home/adrien/.platformio/packages/framework-arduino-avr/cores/arduino",
"/home/adrien/.platformio/packages/framework-arduino-avr/variants/standard",
"/home/adrien/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
"/home/adrien/.platformio/packages/framework-arduino-avr/libraries/HID/src",
"/home/adrien/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
"/home/adrien/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
""
],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}

View File

@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

View File

@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

View File

@ -0,0 +1,17 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps =
nrf24/RF24@^1.4.8
br3ttb/PID@^1.2.1

View File

@ -0,0 +1 @@
# JacoBot Arduino

View File

@ -0,0 +1,59 @@
// Made by Linux_Hat
#include "car.h"
#include "motorEncoder.h"
#define pi 3.1415
Car::Car(MotorEncoder* left, MotorEncoder* right, float distance_beetween_motors)
: m_left(left), m_right(right), m_distance_beetween_motors(distance_beetween_motors) {
}
void Car::forward(float distance, double setPoint) { //distance : mm
const float m1_mmp = pi*(*m_left).m_radius*2/(*m_left).m_ratio; // mm/pulse for m1
const float m2_mmp = pi*(*m_right).m_radius*2/(*m_right).m_ratio; // mm/pulse for m2
double m1_duration = 0;
double m2_duration = 0;
m_left->setPoint = setPoint;
m_right->setPoint = setPoint/m2_mmp*m1_mmp;
while(m1_duration<distance/m1_mmp && m2_duration<distance/m2_mmp) {
if(m1_duration<distance/m1_mmp) {
m1_duration+=m_left->compute(0);
m_left->advance();
} else {m_left->stop();}
if(m2_duration<distance/m2_mmp) {
m2_duration+m_right->compute(0);
m_right->advance();
} else {m_right->stop();}
}
m_left->stop();
m_right->stop();
}
void Car::turn(float angle, double setPoint) { //angle : degre
float distance = pi*m_distance_beetween_motors/360*angle;
const float m1_mmp = pi*(*m_left).m_radius*2/(*m_left).m_ratio; // mm/pulse for m1
const float m2_mmp = pi*(*m_right).m_radius*2/(*m_right).m_ratio; // mm/pulse for m2
double duration = 0;
m_left->setPoint = setPoint;
m_right->setPoint = setPoint/m2_mmp*m1_mmp;
if(angle>0) {
const double pulse_goal = distance/m1_mmp;
while(duration<pulse_goal) {
duration+=m_left->compute(0);
m_left->advance();
m_right->compute(0);
m_right->back();
}
} else if(angle<0) {
const double pulse_goal = distance/m2_mmp;
while(duration<pulse_goal) {
duration+=m_right->compute(0);
m_right->advance();
m_left->compute(0);
m_left->back();
}
}
m_left->stop();
m_right->stop();
return;
}

View File

@ -0,0 +1,24 @@
// Made by Linux_Hat
#pragma once
#include "motorEncoder.h"
/**
* @brief Create a new instance of car
*
* This constructor initializes the a Car with 2 motors and the distance between 2 wheels.
*
* @param m1 ?
* @param m2
* @param distance_beetween_motors
*/
class Car {
private:
float m_distance_beetween_motors;// mm
MotorEncoder* m_left;
MotorEncoder* m_right;
public:
Car(MotorEncoder* left, MotorEncoder* right, float distance_beetween_motors);
void forward(float distance, double setPoint);
void turn(float angle, double setPoint);
};

View File

@ -0,0 +1,109 @@
// Made by Linux_Hat
#include <Arduino.h>
#include "radio.h"
#include "motorEncoder.h"
#include "car.h"
#define MLEFT_ENC_PIN_A 2
#define MLEFT_ENC_PIN_B A4
#define MLEFT_E_MOTOR 5
#define MLEFT_M_MOTOR 4
#define MLEFT_RATIO 120
#define MLEFT_RADIUS 3.3
#define MRIGHT_ENC_PIN_A 3
#define MRIGHT_ENC_PIN_B A3
#define MRIGHT_E_MOTOR 10
#define MRIGHT_M_MOTOR 8
#define MRIGHT_RATIO 120
#define MRIGHT_RADIUS 3.3
#define LED_ORANGE 12
#define SIZE 500
#define SPEED 50
MotorEncoder m1(MLEFT_ENC_PIN_A, MLEFT_ENC_PIN_B, MLEFT_E_MOTOR, MLEFT_M_MOTOR, MLEFT_RATIO, MLEFT_RADIUS); // Initialise motor
MotorEncoder m2(MRIGHT_ENC_PIN_A, MRIGHT_ENC_PIN_B, MRIGHT_E_MOTOR, MRIGHT_M_MOTOR, MRIGHT_RATIO, MRIGHT_RADIUS); // Initialise motor with pins
Car car(&m1, &m2, 110);
float m1_duration = 0;
float m2_duration = 0;
void encoder_handler_m1() {
m1.wheelSpeed(); // Call wheelSpeed() of the m1 MotorEncoder instance
}
void encoder_handler_m2() {
m2.wheelSpeed(); // Call wheelSpeed() of the m2 MotorEncoder instance
}
Radio* radio;
void setup() {
Serial.begin(9600);
pinMode(LED_ORANGE, OUTPUT);
radio = new Radio(120, 9, 7);
m1.EncoderHandlerInit(encoder_handler_m1);
m2.EncoderHandlerInit(encoder_handler_m2);
Serial.println("Car started");
}
void function(int fn_lenght) {
for (int j=14; j<14+fn_lenght; j++){
if(radio->message[j] == (char)"F") {
car.forward(SIZE, SPEED);
} else if(radio->message[j] == (char)"R") {
car.turn(90, SPEED);
} else if(radio->message[j] == (char)"L") {
car.turn(-90, SPEED);
} else if(radio->message[j] == (char)"f") {
function(fn_lenght);
} else if(radio->message[j] == (char)"N") {
delay(800);
}
}
}
void loop() {
if (radio->read() && strncmp(radio->message, "JACO", 4) == 0){
char checksum_check[2] = {radio->message[22], radio->message[23]};
char checksum[] = "AA";
for(int i=0; i<11; i++) {
checksum[0] ^= radio->message[i*2];
checksum[1] ^= radio->message[i*2+1];
}
if(strncmp(checksum_check, checksum, 2) == 0){
int lenght = 10;
int fn_lenght = 6;
for (int i=13; i>3; i--){
if(radio->message[i] != (char)"N") {
break;
}
lenght--;
}
for (int i=19; i>13; i--){
if(radio->message[i] != (char)"N") {
break;
}
fn_lenght--;
}
for (int i=4; i<4+lenght; i++){
if(radio->message[i] == (char)"F") {
car.forward(SIZE, SPEED);
} else if(radio->message[i] == (char)"R") {
car.turn(90, SPEED);
} else if(radio->message[i] == (char)"L") {
car.turn(-90, SPEED);
} else if(radio->message[i] == (char)"f") {
function(fn_lenght);
} else if(radio->message[i] == (char)"N") {
delay(800);
}
}
}
}
}

View File

@ -0,0 +1,78 @@
#include <PID_v1.h>
#include <Arduino.h>
#include "motorEncoder.h"
MotorEncoder::MotorEncoder(uint8_t encoder0pinA, uint8_t encoder0pinB, int E_left, int M_left, float ratio, float radius) {
m_encoder0pinA = encoder0pinA; // pin 2 or 3
m_encoder0pinB = encoder0pinB;
m_E_left = E_left;// pwm pin !
m_M_left = M_left;
m_ratio = ratio;
m_radius = radius;
setPoint = 0;
direction = true; // Default -> Forward
pinMode(m_encoder0pinB, INPUT);
pinMode(m_M_left, OUTPUT); // L298P Control port settings DC motor driver board for the output mode
pinMode(m_E_left, OUTPUT);
// Initialize PID controller
myPID = new PID(&abs_duration, &val_output, &setPoint, Kp, Ki, Kd, DIRECT);
myPID->SetMode(AUTOMATIC); // PID is set to automatic mode
myPID->SetSampleTime(100); // Set PID sampling frequency to 100ms
}
void MotorEncoder::wheelSpeed() {
int Lstate = digitalRead(m_encoder0pinA);
if((encoder0PinALast == LOW) && Lstate==HIGH){
int val = digitalRead(m_encoder0pinB);
if(val == LOW && direction){
direction = false; //Reverse
}
else if(val == HIGH && !direction){
direction = true; //Forward
}
}
encoder0PinALast = Lstate;
if(!direction) duration++;
else duration--;
}
void MotorEncoder::EncoderHandlerInit(void (*ISR)(void)) {
direction = true; // Default -> Forward
pinMode(m_encoder0pinB, INPUT); // Ensure encoder pin A is set as INPUT
attachInterrupt(m_encoder0pinA-2, ISR, CHANGE);
}
void MotorEncoder::advance() {
digitalWrite(m_M_left, LOW);
analogWrite(m_E_left, abs(val_output));
}
void MotorEncoder::back() {
digitalWrite(m_M_left, HIGH);
analogWrite(m_E_left, abs(val_output));
}
void MotorEncoder::stop() {
analogWrite(m_E_left, 0);
}
double MotorEncoder::compute(int debug) {
abs_duration = abs(duration);
result = myPID->Compute();
if (result) {
if (debug) {
Serial.print("Pluse: ");
Serial.print(duration);
Serial.print(" Power: ");
Serial.println(val_output);
}
double old_duration = duration;
duration = 0;
return old_duration;
}
return duration;
}

View File

@ -0,0 +1,32 @@
#pragma once
#include <PID_v1.h>
#include <Arduino.h>
class MotorEncoder {
private:
uint8_t encoder0PinALast; //the number of the pulses
boolean direction; //the rotation direction
boolean result;
PID* myPID;
double val_output; //Power supplied to the motor PWM value.
double Kp = 0.6, Ki = 5, Kd = 0;
double abs_duration;
uint8_t m_encoder0pinA; //A pin
uint8_t m_encoder0pinB; //B pin
int m_E_left; //The enabling of L298PDC motor driver board connection to the digital interface port 5
int m_M_left;
public:
float m_radius, m_ratio;
double duration;
double setPoint;
MotorEncoder(uint8_t encoder0pinA, uint8_t encoder0pinB, int E_left, int M_left, float ratio, float radius);
void EncoderHandlerInit(void (*ISR)(void));
void wheelSpeed();
void advance();
void back();
void stop();
double compute(int debug);
};

View File

@ -0,0 +1,33 @@
// Made by Linux_Hat
#include <RF24.h>
#include <SPI.h>
#include <Arduino.h>
#include "radio.h"
#define tunnel "PIPE1"
Radio::Radio(int canal, int pinCE, int pinCSN) {
m_canal = canal;
m_pinCE = pinCE;
m_pinCSN = pinCSN;
radio = new RF24(m_pinCE, m_pinCSN);
const byte adress[6] = tunnel;
if (!radio->begin()) {
Serial.println("Error while initialise the NRF module");
while (1);
}
Serial.println("Radio module initialised");
radio->openReadingPipe(0, adress);
radio->setChannel(m_canal);
radio->setPALevel(RF24_PA_MIN);
radio->startListening();
}
boolean Radio::read() {
if (radio->available()) {
radio->read(&message, sizeof(message));
return true;
} else {
return false;
}
}

View File

@ -0,0 +1,17 @@
// Made by Linux_Hat
#pragma once
#include <RF24.h>
#include <SPI.h>
#include <Arduino.h>
class Radio {
public:
char message[32];
Radio(int canal, int pinCE, int pinCSN);
boolean read();
private:
int m_canal;
int m_pinCE;
int m_pinCSN;
RF24* radio;
};

View File

@ -0,0 +1,11 @@
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

View File

@ -1,25 +0,0 @@
# JacoVirt
## How run the project ?
Clone the project :
~~~
git clone https://git.afpy.org/MDL29/JacoBot.git
~~~
Go in the folder of project then in the virtual pad folder
~~~
cd Jacobot/jacovirt
~~~
Downloads dependencies and create a virtual environement
~~~
poetry install
~~~
Run the virtual pad with :
~~~
poetry run jacovirt pad
~~~
Run the virtual bot with :
~~~
poetry run jacovirt bot
~~~

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

View File

@ -1,56 +0,0 @@
import argparse
import logging
import jacovirt.logger
log_level = {
"CRITICAL": logging.CRITICAL,
"ERROR": logging.ERROR,
"WARN": logging.WARNING,
"INFO": logging.INFO,
"DEBUG": logging.DEBUG,
}
def main():
# General parser
parser = argparse.ArgumentParser(description=__doc__)
# Subparser
sub = parser.add_subparsers(dest="sub")
parser.add_argument(
"-l",
"--log",
choices=log_level.keys(),
default="WARN",
help=("Set level log"),
dest="log",
)
# Parser for JacoVirt Pad
pad = sub.add_parser("pad", help="Run JacoVirt Pad")
# Parser for JacoVirt Bot
bot = sub.add_parser("bot", help="Run JacoVirt Bot")
args = parser.parse_args()
if args.sub is None:
parser.print_help()
exit(1)
logging.getLogger().setLevel(args.log)
match args.sub:
case "pad":
logging.info("Lunch JacoVirt Pad")
from jacovirt.pad import window
window.main()
case "bot":
logging.info("Lunch JacoVirt Bot")
from jacovirt.bot import window
window.main()
case _:
SystemExit

View File

@ -1,51 +0,0 @@
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

@ -1,61 +0,0 @@
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

@ -1,79 +0,0 @@
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

@ -1,79 +0,0 @@
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_WIDTH = int(1000)
SCREEN_HEIGHT = int(1000)
# Window color
BACKGROUND_COLOR = arcade.color.CATALINA_BLUE
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):
# Init parent class
super().__init__(int(SCREEN_WIDTH), int(SCREEN_HEIGHT), SCREEN_TITLE)
# 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()
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 = Window()
window.setup()
arcade.run()

View File

@ -1,9 +0,0 @@
from datetime import datetime
from typing import Literal
from pydantic import BaseModel
class Instruction(BaseModel):
move: Literal["FORWARD", "LEFT", "RIGHT"]
timestamp: datetime
source: str

View File

@ -1,8 +0,0 @@
import logging
from rich.logging import RichHandler
# Set level INFO log for Arcade library
logging.getLogger("arcade").setLevel(logging.INFO)
# Logger config
logging.basicConfig(format="%(asctime)s %(levelname)s %(message)s", datefmt="%m/%d/%Y %H:%M:%S", handlers=[RichHandler()])

View File

@ -1,54 +0,0 @@
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

@ -1,49 +0,0 @@
import arcade
from importlib import resources
class Token(arcade.Sprite):
""" Token sprite """
def __init__(self, token_type, scale=0.70):
# Attributes for token type
self.token_type = token_type
with resources.path("jacovirt", 'Img') as img_folder :
self.image_file_name = f"{img_folder}/pad/token/{self.token_type}.png"
# Call the parent
super().__init__(self.image_file_name, scale=scale, hit_box_algorithm="None")
class Token_generator(arcade.Sprite):
""" Token generator sprite """
def __init__(self, token_type, scale=1):
# Attributes for token type
self.type = token_type
self.image_file_name = ":resources:images/tiles/boxCrate_double.png"
self.tokens = arcade.SpriteList()
# Call the parent
super().__init__(self.image_file_name, scale, hit_box_algorithm="None")
def create_token(self, x, y):
# Create a token
token = Token(self.type)
token.position = x, y
self.tokens.append(token)
return token
def draw_tokens(self):
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()

Some files were not shown because too many files have changed in this diff Show More