How can I handle Pepper robot shutdown event?

℡╲_俬逩灬. 提交于 2020-01-06 14:13:19

问题


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?


回答1:


Unfortunately this won't be possible as when you trigger a shutdown naoqi will exit as well and destroy your service.

If you are coding in c++ you could use a destructor, but there is no proper equivalent for python...

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.

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



来源:https://stackoverflow.com/questions/51498056/how-can-i-handle-pepper-robot-shutdown-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!