We use cookies to try and give you a better experience in Freshdesk.
You can learn more about what kind of cookies we use, why, and how from our Privacy policy. If you hate cookies, or are just on a diet, you can disable them altogether too. Just note that the Freshdesk service is pretty big on some cookies (we love the choco-chip ones), and some portions of Freshdesk may not work properly if you disable cookies.
We’ll also assume you agree to the way we use cookies and are ok with it as described in our Privacy policy, unless you choose to disable them altogether through your browser.
Hello to everybody,
i'm a newbie in coding with python an den NoaQI API. Since 1999 i code only Java and i want to learn more about Python and the NaoQi API.
I habe try to code a "Killswitch" thats kill a running applikation. E.g. i have code an application where the Robot say something and i want to terminate the app by touching the Headsensor.
The Porgramm terminate the app, but it throws Exceptions.
Has anybody an idea or a good notice, what i can make better ??
Thanks in advance and best regards
Oliver
This is the excpetion:
Traceback (most recent call last):
File "E:\$daten\NAO\Python\ppra01\aufg01\MyTouchTest.py", line 45, in <module>
myC = MyClass(app)
File "E:\$daten\NAO\Python\ppra01\aufg01\MyTouchTest.py", line 18, in __init__
self.mySpeak()
File "E:\$daten\NAO\Python\ppra01\aufg01\MyTouchTest.py", line 33, in mySpeak
self.my_tts.say("Hallo sdiufhsfkasdkjasdnaskjfbnsdkfbskfjn")
RuntimeError: Future canceled.
[W] 1677076113.009489 5832 qitype.signal: disconnect: No subscription found for SignalLink 14.
[E] 1677076113.009489 13872 python: Bug: error while getting python error
[E] 1677076113.015617 13872 python: Bug: error while getting python error
[W] 1677076113.015617 7864 qitype.signal: disconnect: No subscription found for SignalLink 0.
And that's my code:
# -*- encoding: UTF-8 -*-
import qi
import sys
class MyClass(object):
def __init__(self, app):
super(MyClass, self).__init__()
my_session=app.session
app.start()
self.my_tts=my_session.service("ALTextToSpeech")
self.my_memory = my_session.service("ALMemory")
self.touch = self.my_memory.subscriber("FrontTactilTouched")
self.id=self.touch.signal.connect(self.killSwitch)
self.mySpeak()
def killSwitch(self,qwe):
bool_okay=self.touch.signal.disconnect(self.id)
#print("Test")
try:
self.my_tts.stopAll()
app.stop()
sys.exit(1)
except RuntimeError, e:
print("Fehler:" + e)
def mySpeak(self):
self.my_tts.setVolume(0.1)
self.my_tts.say("Hallo sdiufhsfkasdkjasdnaskjfbnsdkfbskfjn")
if __name__ == "__main__":
try:
app = qi.Application(["MyClass", "--qi-url=" + "tcp://192.168.95.80:9559"])
except RuntimeError:
print ("Verbindungsfehler")
sys.exit(1)
myC = MyClass(app)
app.run()
0 Votes
1 Comments
Oliver.mathews posted 27 days ago
I found a solition for me that's works:
I have edit the following Method, i markt the changed code in bold letters:
0 Votes
Login or Sign up to post a comment