コード例 #1
0
 def execute(self,
             execution_id=-1,
             skill_list=None,
             action=srvs.SkillCommandRequest().START):
     """
     @brief Execute a list of skills
     """
     msg = srvs.SkillCommandRequest()
     msg.action = action
     msg.author = self._author
     msg.execution_id = execution_id
     if skill_list is not None:
         for s in skill_list:
             msg.skills.append(s.toMsg())
     res = self.call(self._skill_exe_client, msg)
     if res is None:
         return -1
     if not res.ok:
         log.error("", "Can t execute task.")
         return -1
     return res.execution_id
コード例 #2
0
 def preempt_all(self, author):
     msg = srvs.SkillCommandRequest()
     msg.action = msg.PREEMPT
     msg.author = author
     msg.execution_id = -1
     res = self.call(self._skill_exe_client, msg)
     if res is None:
         return False
     elif not res.ok:
         log.error("Can t stop tasks.")
         return False
     self._active_tasks = list()
     return True
コード例 #3
0
 def execute(self, skill_list, author):
     msg = srvs.SkillCommandRequest()
     msg.action = msg.START
     msg.author = author
     for s in skill_list:
         msg.skills.append(s.toMsg())
     res = self.call(self._skill_exe_client, msg)
     if res is None:
         return -1
     if not res.ok:
         log.error("Can t execute task ")
         return -1
     self._active_tasks.append(res.execution_id)
     return res.execution_id
コード例 #4
0
 def preempt(self, author, execution_id=None):
     msg = srvs.SkillCommandRequest()
     msg.action = msg.PREEMPT
     msg.author = author
     if not self.active_tasks:
         return False
     if execution_id is None:
         execution_id = self.active_tasks[-1]
     msg.execution_id = execution_id
     res = self.call(self._skill_exe_client, msg)
     if res is None:
         return False
     elif not res.ok:
         log.error("Can t stop task " + execution_id)
         return False
     return True
コード例 #5
0
 def pause_one(self, execution_id=None):
     """
     @brief Pause ticking
     """
     msg = srvs.SkillCommandRequest()
     msg.action = msg.PAUSE
     msg.author = self._author
     if not self.tasks:
         return False
     if execution_id is None:
         execution_id = self.task
     msg.execution_id = execution_id
     res = self.call(self._skill_exe_client, msg)
     if res is None:
         return False
     elif not res.ok:
         log.error("", "Can t stop tasks.")
         return False
     return True
コード例 #6
0
 def preempt_one(self, execution_id=None):
     """
     @brief Stop one task
     """
     msg = srvs.SkillCommandRequest()
     msg.action = msg.PREEMPT
     msg.author = self._author
     if not self.tasks:
         return False
     if execution_id is None:
         execution_id = self.task
     msg.execution_id = execution_id
     res = self.call(self._skill_exe_client, msg)
     if res is None:
         return False
     elif not res.ok:
         log.error("", "Can t stop task " + execution_id)
         return False
     return True
コード例 #7
0
 def tick_once(self, execution_id=-1, skill_list=None):
     """
     @brief Tick behavior tree once
     """
     return self.execute(execution_id, skill_list,
                         srvs.SkillCommandRequest().TICK_ONCE)