由于开发模块进行自我定位的原因,我需要在Choreragphe中构建一个python框,这有助于避免Pepper Robot多次识别相同的Landmark。 原始地标仅负责检测地标,但对同一地标重复此过程。 我的基本想法是构建一个字符串,其中包括已识别地标的编号。但是在Choreragphe中,如果我们基于获取AlMemory模块的值来执行此操作;每当检测到地标时,变量都会被刷新,无论它是否是新的。 (请参见图片1) 这段代码
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
#put initialization code here
self.markIDs = []
moreInfo = []
self.memory = ALProxy("ALMemory")
# Connect the event callback.
# Get the services ALMotion & ALRobotPosture.
self.motion_service = ALProxy("ALMotion")
# Get the services ALTextToSpeech, ALLandMarkDetection and ALMotion.
self.motion_service = ALProxy("ALMotion")
self.got_landmark = False
def onLoad(self):
self.logger.debug("Loaded box %s", self.getName())
def onUnload(self):
#puts code for box cleanup here
pass
def onInput_onStart(self, p):
markIDs = []
moreInfo = []
# Generic Extractor output format:
# p = [ [timeStampMaj, timeStampMin], [ tag0, tag1, ... tagN] ] with tag = [ shapeInfo, moreInfo ]
if(len(p) > 0)&(not (moreInfo in markIDs)):
self.logger.info("moreInfo in markIDs=")
self.logger.info((moreInfo in markIDs))
markInfoArray = p[1]
self.logger.info("markInfoArray =")
self.logger.info(markInfoArray)
for markInfo in markInfoArray:
moreInfo = markInfo[1]
# moreInfo = [ landmarkID ]
self.logger.info("markInfo =")
self.logger.info(str(markInfo))
self.logger.info("moreInfo=")
self.logger.info(str(moreInfo))
if not (moreInfo[-1] in markIDs):
self.got_landmark = True
markIDs.append(moreInfo[-1])
self.logger.info("markIDs =")
self.logger.info(str(markIDs))
self.onStopped(markIDs)
将结果返回:
[INFO ] behavior.box :onInput_onStart:30 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: moreInfo in markIDs=
[INFO ] behavior.box :onInput_onStart:31 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: False
[INFO ] behavior.box :onInput_onStart:34 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: markInfoArray =
[INFO ] behavior.box :onInput_onStart:35 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [[[1, 0.18835650384426117, 0.14215253293514252, 0.12947072088718414, 0.12947072088718414, 16], [84]]]
[INFO ] behavior.box :onInput_onStart:40 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: markInfo =
[INFO ] behavior.box :onInput_onStart:41 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [[1, 0.18835650384426117, 0.14215253293514252, 0.12947072088718414, 0.12947072088718414, 16], [84]]
[INFO ] behavior.box :onInput_onStart:42 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: moreInfo=
[INFO ] behavior.box :onInput_onStart:43 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [84]
[INFO ] behavior.box :onInput_onStart:49 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: markIDs =
[INFO ] behavior.box :onInput_onStart:22 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/ProcessMarksList_2: p[0] =
[INFO ] behavior.box :onInput_onStart:23 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/ProcessMarksList_2: 84
[INFO ] behavior.box :onInput_onStart:51 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [84]
[INFO ] behavior.box :onInput_onStart:30 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: moreInfo in markIDs=
[INFO ] behavior.box :onInput_onStart:31 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: False
[INFO ] behavior.box :onInput_onStart:34 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: markInfoArray =
[INFO ] behavior.box :onInput_onStart:40 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: markInfo =
[INFO ] behavior.box :onInput_onStart:42 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: moreInfo=
[INFO ] behavior.box :onInput_onStart:35 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [[[1, 0.18835650384426117, 0.14215253293514252, 0.12947072088718414, 0.12947072088718414, 16], [84]]]
[INFO ] behavior.box :onInput_onStart:49 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: markIDs =
[INFO ] behavior.box :onInput_onStart:43 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [84]
[INFO ] behavior.box :onInput_onStart:41 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [[1, 0.18835650384426117, 0.14215253293514252, 0.12947072088718414, 0.12947072088718414, 16], [84]]
[INFO ] behavior.box :onInput_onStart:51 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [84]
[INFO ] behavior.box :onInput_onStart:30 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: moreInfo in markIDs=
[INFO ] behavior.box :onInput_onStart:31 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: False
[INFO ] behavior.box :onInput_onStart:34 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: markInfoArray =
[INFO ] behavior.box :onInput_onStart:41 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [[1, 0.08169912546873093, 0.14497141540050507, 0.12635093927383423, 0.12635093927383423, 17], [84]]
[INFO ] behavior.box :onInput_onStart:35 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [[[1, 0.08169912546873093, 0.14497141540050507, 0.12635093927383423, 0.12635093927383423, 17], [84]]]
[INFO ] behavior.box :onInput_onStart:43 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [84]
[INFO ] behavior.box :onInput_onStart:42 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: moreInfo=
[INFO ] behavior.box :onInput_onStart:49 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: markIDs =
[INFO ] behavior.box :onInput_onStart:40 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: markInfo =
[INFO ] behavior.box :onInput_onStart:51 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11241679648:/NAOMark_3/Get Marks List_1: [84]
但是,如果我们仅使用python脚本执行此操作,然后将其导入Choregraphe,则建议我遵循Mr.Emile的Github项目中的工作流程,robot-jumpstarter未能在Choregraphe中使用它。
因此,是否可以在Choregraphe中与Naomark模块并行地执行一些本地python脚本(如picture3中所示),以在其中保存检测到的MarkID,依此类推 >?
答案 0 :(得分:0)
我也许没有抓住困难,但是解决起来似乎很简单: 添加一个连接到DetectLandmark输出的盒子,并执行以下代码:
def onInput( self, p ):
if p != self.last
self.last = p
self.output(p)