由于开发了一个模块来进行自我定位,我需要在 Choreragphe 中构建一个 python 盒子,这有助于避免 Pepper Robot 多次识别同一个地标。原始界标仅负责检测界标,但对同一界标重复该过程。 我的基本想法是构建一个包含已识别地标的数字的字符串。但是在 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 中(如图 3 中的它)与 Naomark 模块并行执行一些本地 python 脚本来保存检测到的 MarkID 等等?