robertalab-ev3dev icon indicating copy to clipboard operation
robertalab-ev3dev copied to clipboard

refactor lab.py to make the server protocol code portable

Open ensonic opened this issue 5 years ago • 8 comments

We'd like to refactor https://github.com/OpenRoberta/robertalab-ev3dev/blob/develop/roberta/lab.py to not import ev3dev and Hal anymore. Instead when initializing the roberta.lab.Service() we'd like to pass a device module.

The device module will have function such as:

def updateDeviceState():   # set firmware name, update battery status
def notifyConnect():       # eg play a beep, or toggle a led
def notifyDisconnect():
def reset():               # resets actors, sensors
...

ensonic avatar Mar 29 '19 13:03 ensonic

Should create a communication library(pull out lab.py and refactoring it) somewhat similar to ev3dev library??

sroopsai avatar Apr 06 '19 16:04 sroopsai

Yes, the idea is to start a new git repository 'openroberta' and extract the code from lab.py. Lab.py contains multiple things (the actual protocol state machine, a dbus service, the code execution sandbox). Ideally those will be split into separate files and will be covered by separate tests. But step by step :)

ensonic avatar Apr 07 '19 10:04 ensonic

should Hal(Hardware Abstraction Library) also be included in new library ('openroberta') as previously Hal is an import into lab.py but now after refactoring no more imports into the library as mentioned above.

sroopsai avatar Apr 07 '19 16:04 sroopsai

No, the hal will stay here (robertalab-ev3dev) and there will be a separate hal.py for eg robertalab-raspberrypi. Whenever the current lab.py calls function from hal.py we need an interface instead.

ensonic avatar Apr 07 '19 17:04 ensonic

OK got it for each separate hardware separate Hal file

sroopsai avatar Apr 07 '19 17:04 sroopsai

FYI: a 2nd use for the new library could be the naoclient: https://github.com/OpenRoberta/robertalab-naoclient/tree/master/oraclient-choreographe-app/app/scripts

ensonic avatar Apr 08 '19 08:04 ensonic

@ensonic what do you mean by an interface through which lab.py calls hal.py functions at some instants.

sroopsai avatar May 02 '19 15:05 sroopsai

See my answer in gitter.

ensonic avatar May 05 '19 10:05 ensonic