From 671c90afceb40faaf98037becfc8325ccb33df7e Mon Sep 17 00:00:00 2001 From: Capo01 <503426+Capo01@users.noreply.github.com> Date: Mon, 27 Nov 2017 22:10:29 +1100 Subject: [PATCH 1/2] Update README.md --- Firmware/README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Firmware/README.md b/Firmware/README.md index af5fac44..443b820c 100644 --- a/Firmware/README.md +++ b/Firmware/README.md @@ -145,14 +145,26 @@ The following options are known to work and supported: * When you are done, you must kill the openocd task before you are able to flash the board again: Tasks -> Terminate task -> openocd. ## Communicating over USB or UART - +Warning: If testing USB or UART communication for the first time it is recommend that your motors are free to spin continuously and are not connected to a drivetrain with limited travel. ### From Linux/Windows/macOS There are two simple python scripts to help you get started with controlling the ODrive using python. -1. [Install Python 3](https://www.python.org/downloads/), then install dependencies: +1. [Install Python 3](https://www.python.org/downloads/), then install dependencies pyusb and pyserial: + * __Linux__ ``` pip install pyusb pyserial ``` + * __Windows__ +From the start menu type 'cmd' and open the command prompt. If you only have python3 installed then enter: +``` +pip install pyusb pyserial +``` +If you have python2 and python3 installed concurrently then you must specifiy the location of pip for python3. For me this was at 'C:\Users\ 'username' \AppData\Local\Programs\Python\Python36-32\Scripts\' and so I instead enter: +``` +C:\Users\'username'\AppData\Local\Programs\Python\Python36-32\Scripts\pip install pyusb pyserial +``` +If you have trouble with this step then refer to [this walkthrough.](https://www.youtube.com/watch?v=jnpC_Ib_lbc) + 3. __Linux__: set up USB permissions ``` echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="0d[0-9][0-9]", MODE="0666"' | sudo tee /etc/udev/rules.d/50-odrive.rules @@ -163,9 +175,11 @@ pip install pyusb pyserial 5. Plug in a USB cable into the microUSB connector on ODrive, and connect it to your PC 6. __Windows__: Use the [Zadig](http://zadig.akeo.ie/) utility to set ODrive (not STLink!) driver to libusb. * If 'Odrive V3.x' is not in the list of devices upon opening Zadig, check 'List All Devices' from the options menu. With the Odrive selected in the device list choose 'libusb-win32' from the target driver list and select the large 'install driver' button. -7. Run `./tools/demo.py` or `./tools/explore_odrive.py`. +7. Run `./tools/demo.py` or `./tools/explore_odrive.py`. - `demo.py` is a very simple script which will make motor 0 turn back and forth. Use this as an example if you want to control the ODrive yourself programatically. - `explore_odrive.py` drops you into an interactive python shell where you can explore and edit the parameters that are available on your device. For instance `my_odrive.motor0.pos_setpoint = 10000` makes motor0 move to position 10000. To connect over serial instead of USB run `./tools/explore_odrive.py --discover serial`. + * __Windows Users:__ +If you run either of the python scripts and only see a prompt window appear for a split second before it closes then it is likely that you have not installed pyusb and pyserial for python3 correctly. ### From Arduino [See ODrive Arduino Library](https://github.com/madcowswe/ODriveArduino) From d898caede7933b7c67429196698b730be95a7caf Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Tue, 16 Jan 2018 23:01:14 -0800 Subject: [PATCH 2/2] improve python on windows instructions --- Firmware/README.md | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/Firmware/README.md b/Firmware/README.md index 679656bb..f2dd9873 100644 --- a/Firmware/README.md +++ b/Firmware/README.md @@ -148,39 +148,35 @@ The following options are known to work and supported: ## Communicating over USB or UART Warning: If testing USB or UART communication for the first time it is recommend that your motors are free to spin continuously and are not connected to a drivetrain with limited travel. ### From Linux/Windows/macOS -There are two simple python scripts to help you get started with controlling the ODrive using python. +There are two example python scripts to help you get started with controlling the ODrive using python. One will drop you into an interactive shell to query settings, parameters, and variables, and let you send setpoints manually ([tools/explore_odrive.py](tools/explore_odrive.py)). The other is a demo application to show you how to control the ODrive programmatically ([tools/demo.py](tools/demo.py)). Below follows a step-by-step guide on how to run these. + + +* __Windows__: It is recommended to use a Unix style command prompt, such as Git Bash that comes with [Git for windows](https://git-scm.com/download/win). 1. [Install Python 3](https://www.python.org/downloads/), then install dependencies pyusb and pyserial: - * __Linux__ ``` pip install pyusb pyserial ``` - * __Windows__ -From the start menu type 'cmd' and open the command prompt. If you only have python3 installed then enter: -``` -pip install pyusb pyserial -``` -If you have python2 and python3 installed concurrently then you must specifiy the location of pip for python3. For me this was at 'C:\Users\ 'username' \AppData\Local\Programs\Python\Python36-32\Scripts\' and so I instead enter: -``` -C:\Users\'username'\AppData\Local\Programs\Python\Python36-32\Scripts\pip install pyusb pyserial -``` -If you have trouble with this step then refer to [this walkthrough.](https://www.youtube.com/watch?v=jnpC_Ib_lbc) +* Note: If you have python2 and python3 installed concurrently then you must specifiy that we wish to target python3. This is done as follows: + * __Linux__: Use `pip3` instead of `pip` in the above command. + * __Windows__: Use the full path of the Python3 pip, yeilding something like: + `C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36-32\Scripts\pip install pyusb pyserial` +* If you have trouble with this step then refer to [this walkthrough.](https://www.youtube.com/watch?v=jnpC_Ib_lbc) -3. __Linux__: set up USB permissions +2. __Linux__: set up USB permissions ``` echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="0d[0-9][0-9]", MODE="0666"' | sudo tee /etc/udev/rules.d/50-odrive.rules sudo udevadm control --reload-rules sudo udevadm trigger # until you reboot you may need to do this everytime you reset the ODrive ``` -4. Power the ODrive board (as per the [Flashing the firmware](#flashing-the-firmware) step) -5. Plug in a USB cable into the microUSB connector on ODrive, and connect it to your PC -6. __Windows__: Use the [Zadig](http://zadig.akeo.ie/) utility to set ODrive (not STLink!) driver to libusb. +3. Power the ODrive board (as per the [Flashing the firmware](#flashing-the-firmware) step). +4. Plug in a USB cable into the microUSB connector on ODrive, and connect it to your PC. +5. __Windows__: Use the [Zadig](http://zadig.akeo.ie/) utility to set ODrive (not STLink!) driver to libusb-win32. * If 'Odrive V3.x' is not in the list of devices upon opening Zadig, check 'List All Devices' from the options menu. With the Odrive selected in the device list choose 'libusb-win32' from the target driver list and select the large 'install driver' button. -7. Run `./tools/demo.py` or `./tools/explore_odrive.py`. - - `demo.py` is a very simple script which will make motor 0 turn back and forth. Use this as an example if you want to control the ODrive yourself programatically. - - `explore_odrive.py` drops you into an interactive python shell where you can explore and edit the parameters that are available on your device. For instance `my_odrive.motor0.pos_setpoint = 10000` makes motor0 move to position 10000. To connect over serial instead of USB run `./tools/explore_odrive.py --discover serial`. - * __Windows Users:__ -If you run either of the python scripts and only see a prompt window appear for a split second before it closes then it is likely that you have not installed pyusb and pyserial for python3 correctly. +6. Open the bash prompt in the `ODrive/tools/` folder. +7. Run `python3 demo.py` or `python3 explore_odrive.py`. +- `demo.py` is a very simple script which will make motor 0 turn back and forth. Use this as an example if you want to control the ODrive yourself programatically. +- `explore_odrive.py` drops you into an interactive python shell where you can explore and edit the parameters that are available on your device. For instance `my_odrive.motor0.pos_setpoint = 10000` makes motor0 move to position 10000. To connect over serial instead of USB run `./tools/explore_odrive.py --discover serial`. ### From Arduino [See ODrive Arduino Library](https://github.com/madcowswe/ODriveArduino)