如何处理Pepper机械手关机事件? [英] How can I handle Pepper robot shutdown event?
问题描述
我需要在启动关闭过程时处理该事件(例如,长按机器人的胸部按钮或电池电量严重不足时).问题是我没有找到处理关机/关机事件的方法.您知道如何以某种方便的方式完成此操作吗?
I need to handle the event when the shutdown process is started(for example with long press the robot's chest button or when the battery is critically low). The problem is that I didn't find a way to handle the shutdown/poweroff event. Do you have any idea how this can be done in some convenient way?
推荐答案
不幸的是,这无法实现,因为当您触发关闭操作时,naoqi也会退出并破坏您的服务.
Unfortunately this won't be possible as when you trigger a shutdown naoqi will exit as well and destroy your service.
如果您使用C ++进行编码,则可以使用析构函数,但是python没有合适的等效项...
If you are coding in c++ you could use a destructor, but there is no proper equivalent for python...
另一种选择是在脚本退出时出于某种原因执行一些代码.为此,您可以将脚本作为服务启动,并使用qiApplication.run()等待结束".该方法将一直阻塞,直到naoqi要求您退出服务为止.
An alternative would be to execute some code when your script exits whatever the reason. For this you can start your script as a service and wait for "the end" using qiApplication.run(). This method will simply block until naoqi asks your service to exit.
注意:在关机的情况下,所有服务都会被杀死,因此您无法从机械手API运行任何命令(因为它们可能不再可用!)
Note: in case of shutdown, all services are being killed, so you cannot run any command from the robot API (as they are probably not available anymore!)
这篇关于如何处理Pepper机械手关机事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!