2

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)?

dim
  • 992
  • 11
  • 26
  • I think the service is started by default, you just need to connect to signal/event produced by this module (in some version, it's the subscribing which start the service). Do you had a look at this kind of page: http://doc.aldebaran.com/2-4/naoqi/sensors/altactilegesture.html – Alexandre Mazel Nov 09 '17 at 09:28
  • @AlexandreMazel, this is a useful link, but unfortunately it does not work. I renewed my question to be clearer. – dim Nov 09 '17 at 13:25
  • Has your question been solved? then please mark the right answer – Oswald Mar 25 '18 at 19:40

2 Answers2

1

Just try this in robot shell (old style proxy connection):

$ python
import naoqi
s = naoqi.ALProxy("ALServiceManager", "localhost", 9559 )
s.stopService('ALTactileGesture')
>>> False
s.startService('ALTactileGesture')
>>> False # (a bit weird, but ...)

So I think it's not completely working, but at least you can connect to the ServiceManager as requested...

Alexandre Mazel
  • 2,462
  • 20
  • 26
  • This is useful, but unfortunately it did not work. My goal is to stop `ALTactileGesture` service during the application because the robot loses focus while touching the head because of the `dialog_touch` application from the basic chanel. – dim Nov 13 '17 at 17:26
  • 1
    That's another reason then, see https://stackoverflow.com/a/46208416/912510 – JLS Nov 13 '17 at 23:04
1

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 :)

Emile
  • 2,946
  • 2
  • 19
  • 22