简体   繁体   English

Pepper 机器人一直显示相同的图像

[英]Pepper robot keeps showing the same Image

I am programing a pepper robot with choregraphe and when I show and image and try to show another image in the same behavior or a different behavior it shows the same image.我正在用 choregraphe 对辣椒机器人进行编程,当我显示和图像并尝试以相同的行为或不同的行为显示另一个图像时,它会显示相同的图像。 Does anyone know how to actually show the image I want?有谁知道如何实际显示我想要的图像?

this is from a different thread, I cant find it again but make sure your show image box looks like this (look at the bottom for additional code)这是来自不同的线程,我无法再次找到它,但请确保您的显示图像框看起来像这样(查看底部的附加代码)

def onLoad(self):
    pass

def onUnload(self):
    pass

def _getTabletService(self):
    tabletService = None
    try:
        tabletService = self.session().service("ALTabletService")
    except Exception as e:
        self.logger.error(e)
    return tabletService

def _getAbsoluteUrl(self, partial_url):
    import os
    subPath = os.path.join(self.packageUid(), os.path.normpath(partial_url).lstrip("\\/"))
    # We create TabletService here in order to avoid
    # problems with connections and disconnections of the tablet during the life of the application
    return "http://%s/apps/%s" %(self._getTabletService().robotIp(), subPath.replace(os.path.sep, "/"))

def onInput_onStart(self):
    # We create TabletService here in order to avoid
    # problems with connections and disconnections of the tablet during the life of the application
    import time
    tabletService = self._getTabletService()
    if tabletService:
        try:
            url = self.getParameter("ImageUrl")
            if url == '':
                self.logger.error("URL of the image is empty")
            if not url.startswith('http'):
                url = self._getAbsoluteUrl(url)
            url += "?" + str(time.time())
            tabletService.showImage(url)
        except Exception as err:
            self.logger.error("Error during ShowImage : %s " % err)
            self.onStopped()
    else:
        self.logger.warning("No ALTabletService, can't display the image.")
        self.onStopped()

def onInput_onHideImage(self):
    # We create TabletService here in order to avoid
    # problems with connections and disconnections of the tablet during the life of the application
    tabletService = self._getTabletService()
    if tabletService:
        try:
            tabletService.hideImage()
        except Exception as err:
            self.logger.error("Error during HideImage : %s " % err)
            self.onStopped()
    else:
        self.logger.warning("No ALTabletService, can't hide the image.")
        self.onStopped()

def onInput_onPreLoadImage(self):
    # We create TabletService here in order to avoid
    # problems with connections and disconnections of the tablet during the life of the application
    tabletService = self._getTabletService()
    if tabletService:
        try:
            partialUrl = self.getParameter("ImageUrl")
            fullUrl = self._getAbsoluteUrl(partialUrl)
            self.logger.warning(fullUrl)
            os.remove(fullUrl)
        except Exception as err:
            self.logger.warning("Error during preLoadImage : %s " % err)
            self.onStopped()
    else:
        self.logger.warning("No ALTabletService, can't preload the image.")
        self.onStopped()

def onInput_onStop(self):
    self.onUnload()
    self.onStopped()

def _getAppName(self):
    import os
    if self.frameManager:
        behaviorPath = os.path.normpath(self.frameManager.getBehaviorPath(self.behaviorId))
        appsFolderFragment = os.path.join("PackageManager", "apps")
        if not (appsFolderFragment in behaviorPath):
            self.logger.error("appsFolderFragment is not in behaviorPath")
        fragment = behaviorPath.split(appsFolderFragment, 1)[1]
        #Additional code:from here
        fragment = fragment.split('/')[1]
        #Additional code:So far
        return fragment.lstrip("\\/")
    else:
        self.logger.warning("No ALFrameManager")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM