diff --git a/robowaiter/behavior_lib/cond/HasSubTask.py b/robowaiter/behavior_lib/cond/HasSubTask.py index 3bbc52f..571c8c0 100644 --- a/robowaiter/behavior_lib/cond/HasSubTask.py +++ b/robowaiter/behavior_lib/cond/HasSubTask.py @@ -8,7 +8,7 @@ class HasSubTask(Cond): def _update(self) -> ptree.common.Status: # if self.scene.status? - if self.scene.sub_task_seq.children == []: + if not self.scene.sub_task_seq or not self.scene.sub_task_seq.children: return ptree.common.Status.FAILURE else: return ptree.common.Status.SUCCESS diff --git a/robowaiter/robot/robot.py b/robowaiter/robot/robot.py index 6d7b275..185c7d7 100644 --- a/robowaiter/robot/robot.py +++ b/robowaiter/robot/robot.py @@ -70,7 +70,11 @@ class Robot(object): del_sub_tree.set_scene(self.scene) seq.add_child(del_sub_tree) - self.scene.sub_task_seq.add_child(seq) + if self.scene.sub_task_seq: + self.scene.sub_task_seq.add_child(seq) + else: + print('Warning: have none sub task sequence') + self.scene.sub_task_seq = seq print("当前行为树为:") print_tree_from_root(self.bt.root)