Create a new Service in Python (no Java)

Is it possible to create a new service (not an instance of an existing/pre-defined service) in Python?

 

I am more comfortable in Python than Java and would like to create a new service using only Python code.  I have been experimenting with instantiating the _TemplateService.java in pure Python, but I am not having much success.  I had thought about maybe creating a Java wrapper  service to allow creating Services in Python, but wanted to check with the experts first to see if it is even viable to create a new service in python only, or if there is some underlying functionality I am overlooking that make MyRobotLab services a Java requirement.

 

Any help is much appreciated.

calamity's picture

Hi bcarroll I really don't

Hi bcarroll

I really don't know if that is doable, maybe Grog can anwer your direct question more precisely

What service do you want to create? Maybe we can help you to start. 

There is plenty of services that you can use as example to create your thing, so you just had to spend some time to understand how everything is working. That may seem a bit overwhelming at first, but you can quickly get in it. 

I'm not qualifying myself as a good java programmer, before I start playing with myrobotlab (about 1 year ago) I have never code anything in java, but with trial and errors, I can manage to get the things I want works

So. I'm curious about what you want to do

bcarroll's picture

Example service

One example is a configuration service based on the configparser python module. I am trying to make my code as modular as possible (separating components into their own modules).  One thing i have done is used the config parser to initialize variables from an INI file. Things like servo min/max, pin mappings, etc...  

i have all this working currently by importing the configparser module and reading the external INI file in every module that needs config parameters from the INI. I am thinking it would be better to create a service that manages the config file (reading, writing, etc). This would simplify the code overall and reduce I/O since the config file would be loaded into memory when the service starts and the config file wouldnt need to be read again. 

 

This is just the latest example i am thinking about, but im sure i will think up more reasons to create a custom service in the future. 

GroG's picture

Ahoy and Welcome

Ahoy and Welcome Bcarroll,

Yes is would be possible ...  its software, it can do anything ... given enough time and work 

I have thought about the same thing, except instead of Python, I have thought of Node.js.

MRL has a pretty well defined structure and api for messaging.  So if you used that api and followed the messaging rules, your "code" could exist in any language.  So you could build your own service in "pure" Python and still interface with an MRL instance with that messaging.  Is this what you want to do ?

But if you want tight integration, nothing would be tighter than using the Jython/Python service in MRL . If you write "pure" Python, you can import other pure Python modules as well, so I'm not sure I see the benefit.

Maybe you can explain further.

Cheers,

GroG

moz4r's picture

Hi Bcarroll ! I use config

Hi Bcarroll ! I use config parser python side, but only read only at this time.
Maybe this can help you

https://github.com/MyRobotLab/inmoov/blob/master/InmoovScript/inmoovSkel...

 

GroG's picture

Thanks moz4r!

Thanks moz4r!