FlexSEA Wiki

A WEARABLE ROBOTICS TOOLKIT

User Tools

Site Tools


pythonscripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
pythonscripts [2020/02/07 21:06]
rqurashi created
pythonscripts [2020/08/20 18:57] (current)
jfduval [Required Python packages]
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, RaspberryPi ​and Linux (Ubuntu).+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).
  
-These scripts are written in Python 3 and have been tested on Python version 3.7.3 and 3.6 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. They do not seem to work with Python 3.8.1 on Windows.+These scripts are written in Python 3 and have been tested on Python version 3.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.**
  
-The code is available 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 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]].
  
-=====Converting from Python ​interface 2.0===== +===== Required ​Python ​packages ​=====
-The new python interface addresses some short comings of the [[pythonscripts2|previous version]]. As the Python interface 2.0 is no longer supported, here is how to [[interface_conversion_3_to_4|port your existing code]].+
  
-=====Quick Start=====+Use pip to install numpy, matplotlib, tornado and scipy. 
 + 
 +Ex.: ''​python -m pip install numpy''​ 
 + 
 +===== Converting from Python interface 2.0 ===== 
 + 
 +The new Python interface addresses some shortcomings of the [[pythonscripts2|previous version]]. As the Python interface 2.0 is no longer supported, here is how to [[interface_conversion_3_to_4|port your legacy code]]. 
 + 
 +===== Quick Start =====
  
 If you have not already setup up your Actuator Package, please read the [[dephyactpack#​Quick Start Guide|ActPack'​s quick start guide]]. ​ If you have not already setup up your Actuator Package, please read the [[dephyactpack#​Quick Start Guide|ActPack'​s quick start guide]]. ​
Line 19: Line 26:
     - At a minimum it has to be newer than August 2018     - At a minimum it has to be newer than August 2018
     - We recommend using the latest from the Release page     - We recommend using the latest from the Release page
-  - Clone the repo :<​code>​ git clone --recursive ​https://​github.com/​DephyInc/​Actuator-Package.git </​code>​+  - Clone the repo :<​code>​git clone https://​github.com/​DephyInc/​Actuator-Package.git</​code>​ 
 +     * The command above will clone the master branch. To clone a specific branch use ''​git clone -b branchName https://​github.com/​DephyInc/​Actuator-Package.git''​
   - Copy ''​Actuator-Package/​Python/​flexseapython/​com_template.txt''​ to a file named ''​Actuator-Package/​Python/​flexseapython/​com.txt''​   - Copy ''​Actuator-Package/​Python/​flexseapython/​com_template.txt''​ to a file named ''​Actuator-Package/​Python/​flexseapython/​com.txt''​
-    ​The first line is the baud rate. If connecting over USB or Bluetooth you can ignore the baud rate, otherwise please enter your desired rate. +    ​The first line is the baud rate. If connecting over USB or Bluetooth you can ignore the baud rate, otherwise please enter your desired rate. 
-    ​The second line is the port name (ex.: COM5 or /​dev/​ttyACM0) +    ​The second line is the port name (ex.: COM5 or /​dev/​ttyACM0) 
-    ​If connecting to more than one device you can add additional port names each on a new line+    ​If connecting to more than one device you can add additional port names each on a new line 
 +    * See below for a file example 
 +    * 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 in and turn on the device. 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>​
Line 29: Line 39:
  
 {{ :​pythonscripts.png |}} {{ :​pythonscripts.png |}}
 +
 +==== Command line arguments ====
 +
 +Since April 2020 the Python scripts accept command line arguments. The first argument is the experiment number and the second (optional) is the number of devices.
 +To see a list of experiments do not include an argument:
 +<​code>​python fxMain.py</​code>​
 +Calling Read Only directly (default = 1 device):
 +<​code>​python fxMain.py 0</​code>​
 +Two Devices Leader Follower is #10 and it uses 2 devices. To launch it with one command:
 +<​code>​python fxMain.py 10 2</​code>​
 +
 =====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).
 +
 +=====com_template.txt and com.txt=====
 +
 +__com_template.txt:​__
 +<​code>​
 +# ***************** com.txt *****************
 +#
 +# Typical values shown in this file. May or may not work on your device.
 +# Bare minimum: two lines. Rest is optional.
 +# 1) First line without comments is baud rate (ex.: 230400)
 +# 2) Second line is the first port
 +# 3) List additional ports as needed.
 +#
 +# ******** Windows Example: ********
 +#
 +# 230400
 +# COM3
 +# COM4
 +#
 +# ******** Ubuntu ********
 +#
 +# 230400
 +# /dev/ttyS3 #(could also be /​dev/​ttyACM0)
 +# /dev/ttyS4
 +#
 +# ******** Raspberry Pi4 ********
 +#
 +# 230400
 +# /​dev/​ttyACM0
 +# /​dev/​ttyACM1
 +</​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).
 +
 +__com.txt:​__
 +<​code>​
 +# ***************** com.txt *****************
 +#
 +# Typical values shown in this file. May or may not work on your device.
 +# Bare minimum: two lines. Rest is optional.
 +# 1) First line without comments is baud rate (ex.: 230400)
 +# 2) Second line is the first port
 +# 3) List additional ports as needed.
 +#
 +# ******** Windows Example: ********
 +#
 +230400
 +COM5
 +# COM4
 +#
 +# ******** Ubuntu ********
 +#
 +# 230400
 +# /dev/ttyS3 #(could also be /​dev/​ttyACM0)
 +# /dev/ttyS4
 +#
 +# ******** Raspberry Pi4 ********
 +#
 +# 230400
 +# /​dev/​ttyACM0
 +# /​dev/​ttyACM1
 +</​code>​
 +
  
 =====Notes===== =====Notes=====
pythonscripts.1581109591.txt.gz · Last modified: 2020/02/07 21:06 by rqurashi