Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about generating an app for localization of Pepper robot #1

Open
Frederik201314 opened this issue Jul 4, 2018 · 0 comments

Comments

@Frederik201314
Copy link

Frederik201314 commented Jul 4, 2018

Hi there,

These days I have tried to generate an application using the pythonapp template to do the localization of Pepper. My basic idea is to combine the LandmarkDetector module in the generated app „Lokalisierung“(Localization of German).
mainlandmarkdetection

You can read the whole code here:

“ MainLandmarkDetection.py“:

"""
A sample showing how to make a Python script as an app.
"""

__version__ = "0.0.8"

__copyright__ = "Copyright 2015, Aldebaran Robotics"
__author__ = 'YOURNAME'
__email__ = 'YOUREMAIL@aldebaran.com'

import stk.runner
import stk.events
import stk.services
import stk.logging

class Activity(object):
    "A sample standalone app, that demonstrates simple Python usage"
    APP_ID = "com.aldebaran.lokalisierung"
    def __init__(self, qiapp):
        self.qiapp = qiapp
        self.events = stk.events.EventHelper(qiapp.session)
        self.s = stk.services.ServiceCache(qiapp.session)
        self.logger = stk.logging.get_logger(qiapp.session, self.APP_ID)

    def on_touched(self, *args):
        "Callback for tablet touched."
        if args:
            self.events.disconnect("ALTabletService.onTouchDown")
            self.logger.info("Tablet touched: " + str(args))
            self.s.ALTextToSpeech.say("Yay!")
            self.stop()

    def on_start(self):
        "Ask to be touched, waits, and exits."
        # Two ways of waiting for events
        # 1) block until it's called

        self.s.ALTextToSpeech.say("Touch my forehead.")
        self.logger.warning("Listening for touch...")
        while not self.events.wait_for("FrontTactilTouched"):
            pass

        # 2) explicitly connect a callback
        if self.s.ALTabletService:
            self.events.connect("ALTabletService.onTouchDown", self.on_touched)
            self.s.ALTextToSpeech.say("okay, now touch my tablet.")
            # (this allows to simltaneously speak and watch an event)
        else:
            self.s.ALTextToSpeech.say("touch my tablet ... oh. " + \
                "I don't haave one.")
            self.stop()

    def stop(self):
        "Standard way of stopping the application."
        self.qiapp.stop()

    def on_stop(self):
        "Cleanup"
        self.logger.info("Application finished.")
        self.events.clear()

if __name__ == "__main__":
    stk.runner.run_activity(Activity)

This is how it worked in cmd.exe:

bugs_for_mainlandmarkdetection02
bugs_for_mainlandmarkdetection03
And I have a question to the parameter by ”landmark_detector = Activity(Parameter)” in line 157 at almost the end of the program because of the Error in the image, which I should pass, if you have a little time for that. I think it schould be a value that should be given to the "qiapp", but what value?

Best regards,
Frederik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant