03-14-2015 12:42 PM
I am trying to connect a Thalmic Myo gesture control armband ( https://www.thalmic.com/en/myo/ ) directly to MyRIO, without a Windows host computer to implement the interface, and use this armband to control an i-Robot (i.e. use a Labview VI running in MyRio to receive data from the armband, interpret the gesture information and send the corresponding command to the i-Robot through serial communication).
From Thalmic Labs tools and bindings developer forums:
https://developer.thalmic.com/forums/topic/778/
I found next Gighub containing python scripts - project that can be used in Linux as an interface to communicate with the Thalmic Myo:
https://github.com/dzhu/myo-raw
After installing Python2.7 and some of the required python modules, (pyserial, enum34), I was able to run the myo_raw.py script in MyRio, from the SSH command prompt, and I am able to capture EMG raw data and gestures information from the Myo Armband into the command prompt terminal.
Notice that it has been very painful / time consuming to install Python2.7 and Python modules into MyRio, using opkg, or copying the module's source code into MyRio and compiling it by running the corresponding setup.py file provided for each module, as each new module to be installed requires many other modules (i.e. modules inter-dependencies)
I found some of the required python modules at:
http://download.ni.com/ni-linux-rt/feeds/2014/arm/armv7a-vfp-neon/Packages
and installed them using next command for each module:
#opkg install http://download.ni.com/ni-linux-rt/feeds/2014/arm/armv7a-vfp-neon/<filename>
where <filename> is the corresponding .ipk module filename listed at:
http://download.ni.com/ni-linux-rt/feeds/2014/arm/armv7a-vfp-neon/Packages
I have found some other modules as source code only (i.e. they are not part of the opkg packages list), using google search. I have installed them by copying their source code into MyRio and running their corresponding "setup.py" script:
# python setup.py install
I have found some other python modules to be available as single python scirpt files. For such modules, I have just save them as a .py files, copied them into /usr/lib/python2.7/ and cpompiled them using:
# python -o py_compile.py <filename.py>
This creates the corresponding <filename.pyo> file
So far so good...
Now, here are the issues and challenges I am facing:
1.- I have not been able to install the python module that is used to graph and visualize the EMG data coming from Myo harmband: pygame-1.9.1release. I get next errors when I try to run the setup.py file for this module in MyRIO:
#python setup.py install
building 'pygame._numericsurfarray' extension
arm-nilrt-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -D_REENTRANT -I/usr/X11R6/include -I/usr/include/SDL -I/usr/include/python2.7 -c src/_numericsurfarray.c -o build/temp.linux-armv7l-2.7/src/_numericsurfarray.o
arm-nilrt-linux-gnueabi-gcc: error trying to exec 'as': execvp: No such file or directory
/usr/lib/gcc/gcc/arm-nilrt-linux-gnueabi/4.7.2/cc1: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
error: command 'arm-nilrt-linux-gnueabi-gcc' failed with exit status 1
It seems this module's compilation is failing due to missing files.
Can anybody help me with this error?
2.- I can't find missing Python modules required to install numpy and sklearn modules:
a) numpy: installation is reporting many no existing paths, missing libraries, and python commands missing module when run from MyRio, as shown below. Is there any other option to install this python package in NI Linux RT?
admin@NI-myRIO-exp:/natinst/numpy-1.9.2# python setup.py install
Running from numpy source directory. /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'test_suite'
warnings.warn(msg)
non-existing path in 'numpy/distutils': 'site.cfg'
non-existing path in 'numpy/f2py': 'docs'
non-existing path in 'numpy/f2py': 'f2py.1'
/bin/sh: svnversion: command not found
F2PY Version 2
blas_opt_info: blas_mkl_info: libraries mkl,vml,guide not found in ['/usr/local/lib', '/usr/lib']
NOT AVAILABLE
openblas_info: libraries openblas not found in ['/usr/local/lib', '/usr/lib']
NOT AVAILABLE
atlas_3_10_blas_threads_info: Setting PTATLAS=ATLAS
libraries tatlas not found in ['/usr/local/lib', '/usr/lib']
NOT AVAILABLE
atlas_3_10_blas_info:
libraries satlas not found in ['/usr/local/lib', '/usr/lib']
NOT AVAILABLE
atlas_blas_threads_info:
Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in ['/usr/local/lib', '/usr/lib']
NOT AVAILABLE
atlas_blas_info:
libraries f77blas,cblas,atlas not found in ['/usr/local/lib', '/usr/lib']
NOT AVAILABLE
/natinst/numpy-1.9.2/numpy/distutils/system_info.py:1603: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__) blas_info:
libraries blas not found in ['/usr/local/lib', '/usr/lib']
NOT AVAILABLE
/natinst/numpy-1.9.2/numpy/distutils/system_info.py:1612:
UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
warnings.warn(BlasNotFoundError.__doc__) blas_src_info:
NOT AVAILABLE
/natinst/numpy-1.9.2/numpy/distutils/system_info.py:1615: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
warnings.warn(BlasSrcNotFoundError.__doc__)
NOT AVAILABLE
/bin/sh: svnversion: command not found non-existing path in 'numpy/lib':
'benchmarks' lapack_opt_info: openblas_lapack_info:
libraries openblas not found in ['/usr/local/lib', '/usr/lib']
NOT AVAILABLE
lapack_mkl_info: mkl_info:
libraries mkl,vml,guide not found in ['/usr/local/lib', '/usr/lib']
NOT AVAILABLE
NOT AVAILABLE atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
libraries tatlas,tatlas not found in /usr/local/lib
libraries lapack_atlas not found in /usr/local/lib
libraries tatlas,tatlas not found in /usr/lib
libraries lapack_atlas not found in /usr/lib
numpy.distutils.system_info.atlas_3_10_threads_info
NOT AVAILABLE
atlas_3_10_info:
libraries satlas,satlas not found in /usr/local/lib
libraries lapack_atlas not found in /usr/local/lib
libraries satlas,satlas not found in /usr/lib
libraries lapack_atlas not found in /usr/lib numpy.distutils.system_info.atlas_3_10_info
NOT AVAILABLE
atlas_threads_info: Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
libraries lapack_atlas not found in /usr/local/lib
libraries ptf77blas,ptcblas,atlas not found in /usr/lib
libraries lapack_atlas not found in /usr/lib numpy.distutils.system_info.atlas_
threads_info
NOT AVAILABLE
atlas_info: libraries f77blas,cblas,atlas not found in /usr/local/lib
libraries lapack_atlas not found in /usr/local/lib libraries f77blas,cblas,atlas not found in /usr/lib
libraries lapack_atlas not found in /usr/lib numpy.distutils.system_info.atlas_info
NOT AVAILABLE
/natinst/numpy-1.9.2/numpy/distutils/system_info.py:1505: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)
lapack_info:
libraries lapack not found in ['/usr/local/lib', '/usr/lib']
NOT AVAILABLE
/natinst/numpy-1.9.2/numpy/distutils/system_info.py:1516: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
warnings.warn(LapackNotFoundError.__doc__) lapack_src_info:
NOT AVAILABLE
/natinst/numpy-1.9.2/numpy/distutils/system_info.py:1519: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
warnings.warn(LapackSrcNotFoundError.__doc__)
NOT AVAILABLE
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'define_macros'
warnings.warn(msg) running install running build running config_cc unifing config_cc, config, build_clib, build_ext, build commands --compiler options running config_fc unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options running build_src build_src building py_modules sources building library "npymath" sources Traceback (most recent call last):
File "setup.py", line 251, in setup_package()
File "setup.py", line 243, in setup_package setup(**metadata)
File "/natinst/numpy-1.9.2/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command cmd_obj.run()
File "/natinst/numpy-1.9.2/numpy/distutils/command/install.py", line 60, in run r = old_install.run(self)
File "/usr/lib/python2.7/distutils/command/install.py", line 565, in run self.run_command('build')
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command cmd_obj.run()
File "/natinst/numpy-1.9.2/numpy/distutils/command/build.py", line 39, in run old_build.run(self)
File "/usr/lib/python2.7/distutils/command/build.py", line 127, in run self.run_command(cmd_name)
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command self.distribution.run_command(command) File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command cmd_obj.run()
File "/natinst/numpy-1.9.2/numpy/distutils/command/build_src.py", line 153, in run self.build_sources()
File "/natinst/numpy-1.9.2/numpy/distutils/command/build_src.py", line 164, in build_sources self.build_library_sources(*libname_info) File "/natinst/numpy-1.9.2/numpy/distutils/command/build_src.py", line 299, in build_library_sources sources = self.generate_sources(sources, (lib_name, build_info))
File "/natinst/numpy-1.9.2/numpy/distutils/command/build_src.py", line 386, in generate_sources source = func(extension, build_dir)
File "numpy/core/setup.py", line 684, in get_mathlib_info st = config_cmd.try_link('int main(void) { return 0;}')
File "/usr/lib/python2.7/distutils/command/config.py", line 248, in try_link self._check_compiler()
File "/natinst/numpy-1.9.2/numpy/distutils/command/config.py", line 87, in _check_compiler c_compiler=self.compiler)
File "/natinst/numpy-1.9.2/numpy/distutils/fcompiler/__init__.py", line 837, in new_fcompiler load_all_fcompiler_classes()
File "/natinst/numpy-1.9.2/numpy/distutils/fcompiler/__init__.py", line 740, in load_all_fcompiler_classes __import__ (module_name)
File "/natinst/numpy-1.9.2/numpy/distutils/fcompiler/gnu.py", line 11, in from numpy.distutils.cpuinfo import cpu
File "/natinst/numpy-1.9.2/numpy/distutils/cpuinfo.py", line 25, in
from commands import getstatusoutput ImportError: No module named commands
b) Sklearnt. Work in process... it requires many libraries to be installed into MyRIO:
build-essential , python-dev python-setuptools, python-nump,y python-scipy, libatlas-dev, libatlas3gf-base
3.-Next step is to be able to call these python scripts from a Labview VI running in MyRio to capture gestures / posses data and translate them to the corresponding i-Robot's serial port commands.
Can Python scripts be called from Labview VIs running in a RT target?
If yes, what is the proper vi, module or interface to do this?
Is such thing as a python.h file, equivalent to a c .h file that can be used to define python module's interface with Labview?
03-14-2015 09:10 PM
Update for issue no. 1 mentioned on my post above:
1.- I have not been able to install the python module that is used to graph and visualize the EMG data coming from Myo harmband: pygame-1.9.1release. I get next errors when I try to run the setup.py file for this module in MyRIO:
#python setup.py install
After installing additiona packages: linux-libc-headers-dev, libmpc-dev and libmpc2, I was able to go over the original compilation error:
/usr/lib/gcc/gcc/arm-nilrt-linux-gnueabi/4.7.2/cc1: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
It seems libmpc.so.2 shared library is included as part of the libmpc2 package
But now I am gettin a new compilation error:
building 'pygame._numericsurfarray'
extension arm-nilrt-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -D_REENTRANT -I/usr/X11R6/include -I/usr/include/SDL -I/usr/include/python2.7 -c src/_numericsurfarray.c -o build/temp.linux-armv7l-2.7/src/_numericsurfarray.o
arm-nilrt-linux-gnueabi-gcc: error trying to exec 'as': execvp: No such file or directory src/_numericsurfarray.c:1163:1: fatal error: error writing to -: Broken pipe
compilation terminated. error: command 'arm-nilrt-linux-gnueabi-gcc' failed with exit status 1
How can I fix the Broken pipe identified for src/_numericsurfarray.c:1163:1?
03-16-2015 09:44 AM
liejf wrote:
...
But now I am gettin a new compilation error:
building 'pygame._numericsurfarray'
extension arm-nilrt-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -D_REENTRANT -I/usr/X11R6/include -I/usr/include/SDL -I/usr/include/python2.7 -c src/_numericsurfarray.c -o build/temp.linux-armv7l-2.7/src/_numericsurfarray.o
arm-nilrt-linux-gnueabi-gcc: error trying to exec 'as': execvp: No such file or directory src/_numericsurfarray.c:1163:1: fatal error: error writing to -: Broken pipe
compilation terminated. error: command 'arm-nilrt-linux-gnueabi-gcc' failed with exit status 1
How can I fix the Broken pipe identified for src/_numericsurfarray.c:1163:1?
You missed the other error that led to the broken pipe.
How did you install the tools that you're using for the compilation, or are you using some of the tools that are meant for kernel module building?
03-16-2015 07:17 PM
I installed the compilation tools using "opkg install" command.
I have downloaded the ipk files from next locations:
http://download.ni.com/ni-linux-rt/feeds/2014/arm/armv7a-vfp-neon/
http://feeds.angstrom-distribution.org/feeds/next/ipk/eglibc/armv7a/base/Packages
(2nd location is not working for me anymore)
It seems I can run the main python script (myo_raw.py) to get raw data and pose information from the Myo armbad into MyRio, without having to install pygame-1.9.1release, numpy and sklearn python modules.
Still I need to figure it out how to interface between Python and Labview (last section on my original post):
3.-Next step is to be able to call these python scripts from a Labview VI running in MyRio to capture gestures / posses data and translate them to the corresponding i-Robot's serial port commands.
Can Python scripts be called from Labview VIs running in a RT target?
If yes, what is the proper vi, module or interface to do this? Is such thing as a python.h file, equivalent to a c .h file that can be used to define python module's interface with Labview?
Is there any reference you can provide for this?
We found some packages / modules containing VIs to inteface between Labview and python, or to run Python code in Labview, but it seems they only work in the host VI (Windows) and not on the RT VI (NI Linux RT).
03-16-2015 08:49 PM
You of course could try to run the python code from a System Exec vi (http://zone.ni.com/reference/en-XX/help/371361K-01/glang/system_exec/)
If this doesn't do what you need (e.g. the code requires interactive,dynamic input) you can write a wrapper library in C/C++ and call the interface through a CLFN (http://zone.ni.com/reference/en-XX/help/371361H-01/glang/call_library_function/)
03-22-2015 11:46 PM
I am trying to use a "socket" to send a data stream produced by a python script that reads Myo armbad data, to a labview vi, both running in NI Linux RT
How can I create a socket in labview to connect to a socket created in python?
I tried to use labview "datasocket" but it seems python "socket" is not compatible with labview "datasocket": I was not able to connect the python socke to the labview datasocket:
URL: dstp://10.32.0.55/actbutton is not recognized as a valid socket host name by Python bind command.
Also labview "datasocket" requires a datasocket server, which can only run in Windows, and I am trying to avoid the need o a Windows host machine to implement the interface between Myo Armband and MyRio.
I am creating the socket in Python using next lines of code:
a) Server socket script:
serversocket1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket1.bind(('localhost', 1025))
serversocket1.listen(5)
(clientsocket1, address1) = serversocket1.accept()
clientsocket1.recv(1024)
b) Client socket script:
s = socket.socket()
host = 'localhost'
port = 1025
s.send(mydata)
When I run both clien socket and server socket python scripts at MyRio, I am able to transfer data between scripts / processes, but I have not being able to figure it out how to do it beween the server socket python script and a labview VI.
Question:
How can I create a socket in Labview that can be connected to the socket created in Python, for a labview VI and a Python script running in NI Linux RT target (MyRio)? (AF_INET socket family).
Any help / reference you can provide would be appreciated.