![](/img/trans.png)
[英]Pepper the robot (softbank robotics) keeps asking the same question from a certain intent in Dialogflow
[英]Pepper robot keeps showing the same Image
我正在用 choregraphe 對辣椒機器人進行編程,當我顯示和圖像並嘗試以相同的行為或不同的行為顯示另一個圖像時,它會顯示相同的圖像。 有誰知道如何實際顯示我想要的圖像?
這是來自不同的線程,我無法再次找到它,但請確保您的顯示圖像框看起來像這樣(查看底部的附加代碼)
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.