Your Privacy
We use cookies to give you a better experience in United Robotics Group
You can learn more about what kind of cookies we use, why, and how from our Privacy Policy. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings in our cookie banner to change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer. For more details, check out our Privacy Policy link below.
Strictly Necessary Cookies
These cookies are necessary for the website to function and cannot be switched off in our systems, but do not store any person information. They are usually set in response to your actions that triggers a request for services, such as setting your privacy preferences, logging in or filling forms. You can change your browser settings to alert you about these cookies, but some parts of the Website may not work.
View Cookies
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 over 1 year 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