Hello MRL'ians :)

Wvantoorn mentioned I should start a post regarding our future Python Community Library.  Right now, our library is checked into github as part of the MyRobotLab repo.  This repo is primarily Java (framework) code - but the library has grown significantly, and there are many scripts floating around which would be nice to share, modify, modularize & improve.

I have just verified that you can create an module import just by saving a file to the mrl installation directory like c:\myrobotlab\fibo.py  (taken from this example - https://docs.python.org/2/tutorial/modules.html

In your script you could just write these 2 lines
@import fibo

fibo(100)

then it would print the Fibonacci numbers. This is much more maintainable than 4K lines of code !!!!

Great news ! But a little planning sometimes saves a lot of future work.

So lets plan where and how these community libraries should exist.
Some things to consider :

  • GitHub has an online editor which will syntax hightlight Python - very nice for quick fixes 
  • Right now the files are in the Java myrobotlab repo .. strangely they are distributed with the myrobotlab.jar too - this is residual from Python having "examples" which could be loaded locally without a network connection.
  • "imports" currently work if the files are in myrobotlab installation directory.. but is this the best place?  I'm pretty sure the locations can be changed - (its configuration within the Python service)
  • Should the Python service be capable of loading a script directly from the GitHub repo ?
  • Should there be a "special" place for Python scripts for Service pages ?  These scripts "should" be the most stable and would not change as often as the "community" scripts .. mebbe just a naming convention?  e.g. Arduino.py ?

What thoughts do you have ?

wvantoorn

10 years 2 months ago

Maybe another point would be (to get a structure) to define what would be put in the config file script, and what should be placed in the depending script files.

maybe it can be made in such a fashion that one only would have to change the config settings to their own, like min/max settings, map settings, com ports and what should be turned on and off.

Then the depending script files would be universal, for all to be used and with the individual settings made, they should make more or less the same movement. And do the same on all inmoovs / platforms.

 

In my vision it would be a good idea if scripts and files could be loaded from github directly, just like the services we have now.

and your last point i dont really understand, you mean every service has their own python scripts, and need their own explaining pages?

Yes - a template (inmoov_configure.py) script which everyone would have different values (or not) depending on specifics of their InMoov build :  Arduino types, ports, pins, camera indexes, min / max & mappings  would all be in that file - You would be able to configure your InMoov to use a single Mega in this script - 

Then import the gestures or activities you want .e.g.

import inmoov.basic
import inmoov.pir
import inmoov.intro
import inmoov.counting

etc. - naming conventions to follow PEP 8 style guide for Python
http://legacy.python.org/dev/peps/pep-0008/#package-and-module-names&nb…;
Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.

Ya .. might gut feeling to to make a new Python repo & loading from that directly into mrl would be pretty easy. People could work online & if they worked directly with the GitHub editor - you know always were the "latest" would be

Last Point is about MyRobotLab and Services being like Legos .. but software Legos are difficult to "see" - documentation is important ..  The Service pages are a page here dedicated to each service.  A way to "see" the block so it can be played with it.  To play with it most people here use Python (although there are other ways) - but if Python is used - there should be at least 1 good working script in the service page .  You can see an example of this for the Speech block - http://myrobotlab.org/service/speech 

The script there is really on GitHub - It's "supposed" to be a working script (I think this one still is) - but If I was a new user, I'd like to be directed to this Speech page (possibly from the cookbook - https://github.com/MyRobotLab/myrobotlab/wiki ) I want to copy paste and see it all worky !...
(Community Scripts in progress are not always worky all the time - that's just part of development)

If it worky I would be happy monkey.

This is a great idea.  It makes a lot of sense.  I think it'd be nice if we could put the python scripts (to be imported) in a subdirectory of mrl...  something like   mrl/python  similar to how the arduino code is in the subdirectory arduino.  (just to help organize the directory structure a bit better.)

 

next, i figure most of the inmoov scripts are large because all of the gestures..  it'd be nice to be able to consolidate those gestures into a gestures class (or something like that..)  

so people can add to the gestures class.  the tricky part is that many of the angles are hard-coded and stuff, people may want to tweak those depending on how their inmoov is calibrated... which brings me to the last point..

having some helper scripts that allow people to calibrate the inmoov movement and rest positions to automatically generate the configuration  (min/max/rest)  settings for their particular build would also be super awesome.. that way the common gestures should all behave the same, so long as the inmoov has been  calibrated...  at that point we can merge together the gestures into a common library that can be reused in anyones script.