예제 #1
0
    def test_deserializeParamMap(self):
        ph = param.ParamHandler()
        ph.addParam("MyDict", dict, param.ParamTypes.Required)
        d_ph = param.ParamHandler(
            utils.deserializeParamMap(utils.serializeParamMap(ph._params)))
        self.assertEqual('MyDict:[] ', d_ph.printState())

        ph.addParam("MyList", list, param.ParamTypes.Required)
        d_ph = param.ParamHandler(
            utils.deserializeParamMap(utils.serializeParamMap(ph._params)))
        self.assertEqual('MyDict:[] MyList:[] ', d_ph.printState())
예제 #2
0
def skill2msg(skill):
    msg = msgs.ResourceDescription()
    msg.type = skill._type
    msg.name = skill._label
    msg.params = utils.serializeParamMap(
        skill._description._params.getParamMap())
    return msg
예제 #3
0
 def _on_progress_update(self, *args, **kwargs):
     """
     @brief Publish skill progress
     """
     log.debug(
         "[{}]".format(self.__class__.__name__),
         "{}:Task[{task_id}]{type}:{label}[{id}]: Message[{code}]: {msg} ({state})"
         .format(self.sm._agent_name[1:], **kwargs))
     msg = msgs.SkillProgress()
     msg.robot = rospy.get_name()
     msg.task_id = kwargs['task_id']
     msg.id = kwargs['id']
     msg.type = kwargs['type']
     msg.label = kwargs['label']
     if self.publish_runtime_parameters:
         msg.params = utils.serializeParamMap(kwargs['params'])
     msg.state = kwargs['state'].value
     msg.processor = kwargs['processor']
     msg.parent_label = kwargs['parent_label']
     msg.parent_id = kwargs['parent_id']
     msg.progress_code = kwargs['code']
     msg.progress_period = kwargs['period']
     msg.progress_time = kwargs['time']
     msg.progress_message = kwargs['msg']
     self._monitor.publish(msg)
예제 #4
0
    def _on_progress_update(self, *args, **kwargs):
        """
        @brief Publish all skill progress
        """
        task_id = kwargs['task_id']
        tree = kwargs['tree']
        messages = msgs.TreeProgress()
        for (idd, desc) in tree:
            log.debug(
                "[{}]".format(self.__class__.__name__),
                "{}:Task[{task_id}]{type}:{label}[{id}]: Message[{code}]: {msg} ({state})"
                .format(self.sm._agent_name[1:],
                        task_id=task_id,
                        id=idd,
                        **desc))
            msg = msgs.SkillProgress()
            msg.robot = rospy.get_name()
            msg.task_id = task_id
            msg.id = idd
            msg.type = desc['type']
            msg.label = desc['label']
            if self.publish_runtime_parameters:
                msg.params = utils.serializeParamMap(desc['params'])
            msg.state = desc['state'].value
            msg.processor = desc['processor']
            msg.parent_label = desc['parent_label']
            msg.parent_id = desc['parent_id']
            msg.progress_code = desc['code']
            msg.progress_period = desc['period']
            msg.progress_time = desc['time']
            msg.progress_message = desc['msg']

            messages.progress.append(msg)
        self._monitor.publish(messages)
예제 #5
0
    def test_serialize_ParamMap(self):
        ph = param.ParamHandler()
        ph.addParam("MyDict", dict, param.ParamTypes.Required)
        s_param_map = utils.serializeParamMap(ph._params)
        self.assertSameItems(s_param_map_strings[0], str(s_param_map))

        ph.addParam("MyList", list, param.ParamTypes.Required)
        s_param_map = utils.serializeParamMap(ph._params)
        self.assertSameItems(s_param_map_strings[1], str(s_param_map))

        params = {}
        params["MyDict"] = param.Param("MyDict", "", dict,
                                       param.ParamTypes.Required)
        s_param_map = utils.serializeParamMap(params)
        self.assertSameItems(s_param_map_strings[0], str(s_param_map))

        params = {}
        params["MyString"] = param.Param("MyString", "", "String",
                                         param.ParamTypes.Required)
        s_param_map = utils.serializeParamMap(params)
        self.assertSameItems(s_param_map_strings[2], str(s_param_map))
예제 #6
0
파일: utils.py 프로젝트: dhled/skiros-demo
 def toMsg(self):
     msg = msgs.ResourceDescription()
     msg.type = self.type
     msg.name = self.name
     msg.params = serializeParamMap(self.ph.getParamMap())
     return msg