This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
pythonscripts [2020/08/20 18:57] jfduval [Required Python packages] |
pythonscripts [2020/12/04 01:38] casmat |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Python Interface ====== | ====== Python Interface ====== | ||
- | This document describes the Python scripts that demonstrate how to control the Actuator Package. These scripts are accompanied by and are dependent upon C based libraries for both Windows (.dll) and Unix (.so). Pre-compiled libraries are provided for Windows 32 and 64 bits, Raspberry Pi and Linux (Ubuntu). | + | This document describes the Python scripts that demonstrate how to control the Actuator Package. These scripts are accompanied by required binary libraries precompiled for both Windows 32 and 64 bits (.dll), and Linux (.so) including Rapspbian and Ubuntu. |
- | These scripts are written in Python 3 and have been tested on Python version 3.8 32 bit and 64 bit (using Windows 10 Pro), as well as 32 bit Rasbian on a Raspberry Pi 4 and Ubuntu 18 64 bits. Python versions lower than 3.7 are no longer supported. **We recommend using 3.7+ 32-bit for a new install.** | + | These scripts are written in Python 3.7.x and have been tested to work on the following platforms: |
+ | * 32-bit and 64-bit Windows 10 Pro (timing and control speed is highly dependent on the hardware and system load). | ||
+ | * armv7l Rasbian on a Raspberry Pi 4 | ||
+ | * x86_64 Ubuntu 18.04 and 20.04 64 bits. | ||
+ | |||
+ | Python versions lower than 3.7 are no longer supported. **We recommend using 3.7+ 32-bit for a new install.** | ||
- | The code is available on GitHub at [[https://github.com/DephyInc/Actuator-Package/tree/develop|Actuator Package]]. This git repository contains the API, DLLs, and example scripts. The functions are documented in pyFlexsea.py. Additional documentation on the fx_plan_stack API can be found [[fx_plan_stack_api|here]]. | + | The code is available on GitHub at [[https://github.com/DephyInc/Actuator-Package/tree/develop|Actuator Package]]. This git repository contains the API, DLLs, and sample scripts. The functions are documented in pyFlexsea.py. Additional documentation on the fx_plan_stack API can be found [[fx_plan_stack_api|here]]. |
===== Required Python packages ===== | ===== Required Python packages ===== | ||
- | + | Follow the instructions on [[https://github.com/DephyInc/Actuator-Package/blob/master/README.md|the readme]] to install the Python dependencies according to your OS. | |
- | Use pip to install numpy, matplotlib, tornado and scipy. | + | |
- | + | ||
- | Ex.: ''python -m pip install numpy'' | + | |
===== Converting from Python interface 2.0 ===== | ===== Converting from Python interface 2.0 ===== | ||
Line 34: | Line 36: | ||
* See below for a file example | * See below for a file example | ||
* Do not commit com.txt! We use com_template.txt to avoid pushing and pulling local changes. | * Do not commit com.txt! We use com_template.txt to avoid pushing and pulling local changes. | ||
- | - Plug in and turn on the device. If you are using Windows make sure that you have the [[stm32driver|STM32 Virtual Com Port Driver]] installed. | + | - Plug the device in and turn it ON. If you are using Windows make sure that you have the [[stm32driver|STM32 Virtual Com Port Driver]] installed. |
- From a cmd window or terminal, run the Actuator-Package/Python/fxMain.py script in Python <code>python fxMain.py</code> | - From a cmd window or terminal, run the Actuator-Package/Python/fxMain.py script in Python <code>python fxMain.py</code> | ||
- Enter the experiment number. Be careful, most of them will make the motor move! | - Enter the experiment number. Be careful, most of them will make the motor move! | ||
Line 52: | Line 54: | ||
=====Matplotlib===== | =====Matplotlib===== | ||
- | Some of the scripts (High-speed test, Impedance, etc.) include plotting. By default we use the WebAgg engine to show the plots in a browser. | + | Some of the scripts (High-speed test, Impedance, etc.) include plotting. By default, we use the WebAgg engine to show the plots in a browser. |
The first time you use the scripts you will need to install matplotlib and tornado (via pip). | The first time you use the scripts you will need to install matplotlib and tornado (via pip). | ||
The plots will stop the Python program. A prompt will tell you how to get out of it. Typically, it's CTRL+C (Unix) or CTRL+BREAK (Windows). | The plots will stop the Python program. A prompt will tell you how to get out of it. Typically, it's CTRL+C (Unix) or CTRL+BREAK (Windows). | ||
Line 87: | Line 89: | ||
</code> | </code> | ||
- | To use it, un-comment and/or modify the lines you need. Below is an example of that file used on Windows, with one port (COM5). | + | To use it, uncomment and/or modify the lines you need. Below is an example of that file used on Windows, with one port (COM5). |
__com.txt:__ | __com.txt:__ | ||
Line 119: | Line 121: | ||
- | =====Notes===== | + | ===== Toubleshooting ===== |
* If you encounter problems with the DLLs, here are some [[generalhints|useful tips]]. | * If you encounter problems with the DLLs, here are some [[generalhints|useful tips]]. | ||
- | * If your device has never had poles configured, you should run "find poles" from the demo script before trying other demos | + | * If your device has never had poles configured, you should run "find poles" from the demo script before trying other demos. This is not typical! |
+ | * The leading cause of segmentation faults is a Device Spec mismatch between the embedded system and the scripts. This happens when you use old firmware with new scripts. | ||