diff --git a/README.md b/README.md index ac28e76..30e56fb 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,24 @@ brew install libusb ``` ``` -pip install odrive +pip install -r dev_requirements.txt +pip install -r requirements.txt ``` ## The Odrive interface -https://docs.odriverobotics.com/odrivetool.html \ No newline at end of file +https://docs.odriverobotics.com/odrivetool.html + +## The examples + +The motors used in the example are from Alibaba and listed as +[24V 36V 48V 6.5 inch wheel hub motor RBE-102036-002 with encoder for robot]. + + + + + + + + +[24V 36V 48V 6.5 inch wheel hub motor RBE-102036-002 with encoder for robot]: https://www.alibaba.com/product-detail/24V-36V-48V-6-5-inch_60843979831.html?spm=a2700.galleryofferlist.normal_offer.d_title.646a42f9aowWtJ \ No newline at end of file diff --git a/dev_requirments.txt b/dev_requirments.txt index 59b51b4..14bea54 100644 --- a/dev_requirments.txt +++ b/dev_requirments.txt @@ -1,30 +1,56 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.8 # To update, run: # # pip-compile dev_requirments.in # -appdirs==1.4.3 # via black -attrs==19.3.0 # via black, pytest -black==19.10b0 # via -r dev_requirments.in -click==7.1.1 # via black, pip-tools -entrypoints==0.3 # via flake8 -flake8==3.7.9 # via -r dev_requirments.in -importlib-metadata==1.5.0 # via pluggy, pytest -mccabe==0.6.1 # via flake8 -more-itertools==8.2.0 # via pytest -packaging==20.3 # via pytest -pathspec==0.7.0 # via black -pip-tools==4.5.1 # via -r dev_requirments.in -pluggy==0.13.1 # via pytest -py==1.8.1 # via pytest -pycodestyle==2.5.0 # via flake8 -pyflakes==2.1.1 # via flake8 -pyparsing==2.4.6 # via packaging -pytest==5.4.1 # via -r dev_requirments.in -regex==2020.2.20 # via black -six==1.14.0 # via packaging, pip-tools -toml==0.10.0 # via black -typed-ast==1.4.1 # via black -wcwidth==0.1.8 # via pytest -zipp==3.1.0 # via importlib-metadata +appdirs==1.4.3 + # via black +attrs==19.3.0 + # via + # black + # pytest +black==19.10b0 + # via -r dev_requirments.in +click==7.1.1 + # via + # black + # pip-tools +entrypoints==0.3 + # via flake8 +flake8==3.7.9 + # via -r dev_requirments.in +mccabe==0.6.1 + # via flake8 +more-itertools==8.2.0 + # via pytest +packaging==20.3 + # via pytest +pathspec==0.7.0 + # via black +pip-tools==4.5.1 + # via -r dev_requirments.in +pluggy==0.13.1 + # via pytest +py==1.8.1 + # via pytest +pycodestyle==2.5.0 + # via flake8 +pyflakes==2.1.1 + # via flake8 +pyparsing==2.4.6 + # via packaging +pytest==5.4.1 + # via -r dev_requirments.in +regex==2020.2.20 + # via black +six==1.14.0 + # via + # packaging + # pip-tools +toml==0.10.0 + # via black +typed-ast==1.4.1 + # via black +wcwidth==0.1.8 + # via pytest diff --git a/example/odrive-ctl.py b/example/odrive-ctl.py new file mode 100644 index 0000000..0425cc9 --- /dev/null +++ b/example/odrive-ctl.py @@ -0,0 +1,62 @@ +from pathlib import Path, PurePath + +import click +import yaml + +# OPTIONS + +config_option = click.option( + '-c', + '--config', + default=PurePath(Path(__file__).parent, Path('odrive.yaml')), + type=Path, + help='A config file for the odrive. Defaults to odrive.yaml.' +) + + +@click.group() +def cli(): + pass + + +@cli.command('configure') +@config_option +def configure(**options): + """Configures an Odrive with a provided .yaml file of config values.""" + config_file = options['config'] + if not config_file.is_file(): + raise FileNotFoundError(f'No config file {config_file} found.') + print(options['config']) + + +class RoboWheelConfig: + """ + Class for configuring an Odrive axis. + """ + + # Motor KV + KV_RATING = 10.0 + + # min/max phase inductance of motor + MIN_PHASE_INDUCTANCE = 0.0 # ? + MAX_PHASE_INDUCTANCE = 0.001 # ? + + # Min/Max phase resistance of motor + MIN_PHASE_RESISTANCE = 0.0 # ? + MAX_PHASE_RESISTANCE = 2.5 # ? I think my motor is 1.7 ohm... + + ENCODER_PULSE_PER_REV = 3200.0 + ENCODER_COUNT_PER_REV = ENCODER_PULSE_PER_REV * 4 + + # Number of magnets in the motor divided by 2 + POLE_PAIR_COUNT = 27.0 + + # See https://docs.odriverobotics.com/hoverboard + RESISTANCE_CALIB_MAX_VOLTAGE = 4.0 # HB motors are larger with more resistance so he doubled the 2.0 default + REQUESTED_CURRENT_RANGE = 25.0 # lower values are more sensitive default was 60 + CURRENT_CONTROL_BANDWIDTH = 100.0 # Motors are also high inductance so the bandwidth to 100 from the default 1000 + TORQUE_CONSTANT = 8.27 / KV_RATING + + +if __name__ == "__main__": + cli() diff --git a/example/odrive.yaml b/example/odrive.yaml new file mode 100644 index 0000000..e69de29 diff --git a/requirements.in b/requirements.in index 5e2968d..15d4254 100644 --- a/requirements.in +++ b/requirements.in @@ -1 +1,3 @@ -odrive==0.4.11 \ No newline at end of file +click==7.1.1 +odrive +pyyaml \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 194717c..ee6000e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,40 +1,80 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.8 # To update, run: # # pip-compile requirements.in # -appnope==0.1.0 # via ipython -backcall==0.1.0 # via ipython -certifi==2019.11.28 # via requests -chardet==3.0.4 # via requests -cycler==0.10.0 # via matplotlib -decorator==4.4.2 # via ipython, traitlets -idna==2.9 # via requests -intelhex==2.2.1 # via odrive -ipython-genutils==0.2.0 # via traitlets -ipython==7.13.0 # via odrive -jedi==0.16.0 # via ipython -kiwisolver==1.1.0 # via matplotlib -matplotlib==3.2.0 # via odrive -monotonic==1.5 # via odrive -numpy==1.18.1 # via matplotlib -odrive==0.4.11 # via -r requirements.in -parso==0.6.2 # via jedi -pexpect==4.8.0 # via ipython -pickleshare==0.7.5 # via ipython -prompt-toolkit==3.0.4 # via ipython -ptyprocess==0.6.0 # via pexpect -pygments==2.6.1 # via ipython -pyparsing==2.4.6 # via matplotlib -pyserial==3.4 # via odrive -python-dateutil==2.8.1 # via matplotlib -pyusb==1.0.2 # via odrive -requests==2.23.0 # via odrive -six==1.14.0 # via cycler, python-dateutil, traitlets -traitlets==4.3.3 # via ipython -urllib3==1.25.8 # via requests -wcwidth==0.1.8 # via prompt-toolkit +appnope==0.1.0 + # via ipython +backcall==0.1.0 + # via ipython +certifi==2019.11.28 + # via requests +chardet==3.0.4 + # via requests +click==7.1.1 + # via -r requirements.in +cycler==0.10.0 + # via matplotlib +decorator==4.4.2 + # via + # ipython + # traitlets +idna==2.9 + # via requests +intelhex==2.2.1 + # via odrive +ipython==7.13.0 + # via odrive +ipython-genutils==0.2.0 + # via traitlets +jedi==0.16.0 + # via ipython +kiwisolver==1.1.0 + # via matplotlib +matplotlib==3.2.0 + # via odrive +monotonic==1.5 + # via odrive +numpy==1.18.1 + # via matplotlib +odrive==0.4.11 + # via -r requirements.in +parso==0.6.2 + # via jedi +pexpect==4.8.0 + # via ipython +pickleshare==0.7.5 + # via ipython +prompt-toolkit==3.0.4 + # via ipython +ptyprocess==0.6.0 + # via pexpect +pygments==2.6.1 + # via ipython +pyparsing==2.4.6 + # via matplotlib +pyserial==3.4 + # via odrive +python-dateutil==2.8.1 + # via matplotlib +pyusb==1.0.2 + # via odrive +pyyaml==5.4.1 + # via -r requirements.in +requests==2.23.0 + # via odrive +six==1.14.0 + # via + # cycler + # python-dateutil + # traitlets +traitlets==4.3.3 + # via ipython +urllib3==1.25.8 + # via requests +wcwidth==0.1.8 + # via prompt-toolkit # The following packages are considered to be unsafe in a requirements file: # setuptools