Search code examples
nao-robotpepperchoregraphe

How to initiate Aldebaran ServiceManager?


I would like to stop and start ALTactileGesture service through ServiceManager during my app. I'm using Choregraphe and python boxes. I have tried different options to initiate ServiceManager but none of them works. Is there any way of doing this?

Edit:

I have already tried self.sm = session.service('ServiceManager') but did not work. The idea is to stop ALTactileGesture as soon as the app has started:
(1) ServiceManager.stopService('ALTactileGesture') (see this)

and start/restart ALTactileGesture before the application ends:
(2) ServiceManager.startService('ALTactileGesture')

My question is how to reach ServiceManager so I can then use (1) and (2)?


Solution

  • You have to understand that the word "service" actually means two different things in NAOqi. See an explanation here:

    NAOqi services (also called "modules"), that expose an API and are registered to the ServiceDirectory. You can call them with qicli, subscribe to their signals, etc.

    systemd services, that are standalone executables packaged in an Application Package, declared in it's manifest with a tag. These are managed by ALServiceManager, who can start and stop them (they will have their own process). For clarity's sake, these are called "Executables" in this doc.

    The confusion between the two is increased by the fact that a common pattern is to write an executable whose sole purpose is to run a NAOqi service, and sometimes to identify both with the same name (e.g. both are called “ALFuchsiaBallTracker”).

    Your problem here is that the NAOqi service ALTactileGesture is run by the executable registered under the ID ALTactileGesture-serv. So you need to do

    ALServiceManager.stop("ALTactileGesture-serv")
    

    (I just tested it, it works fine)

    (edit) by the way, I'm not sure that actually stopping and starting ALTactileGesture is the best way of doing what you're trying to do (it seems a bit hacky to me), but if you want to do it that way, this is how :)