Exemplo n.º 1
0
    def test_sequence(self):
        p = ParallelAnyTask()
        with p:
            ParallelAnyTask.add(TrueTask())
            ParallelAnyTask.add(FalseTask())

        s = SequenceTask()
        with s:
            SequenceTask.add(p)
            SequenceTask.add(FalseTask())

        p2 = ParallelAnyTask()
        with p2:
            ParallelAllTask.add(s)
            ParallelAllTask.add(SleepTask(1.0, succeed=False))

        s2 = SelectorTask()
        with s2:
            SelectorTask.add(p2)
            SelectorTask.add(SleepTask(1.0))

        bt = smach_bt.BehaviorTreeContainer()
        bt.set_root(s2)
        sis = smach_ros.IntrospectionServer('server_name', bt, '/SM_ROOT')
        sis.start()
        wait_start = rospy.Time.now()
        while (rospy.Time.now() -
               wait_start).to_sec() < 10 and not rospy.is_shutdown():
            rospy.sleep(0.1)
            rospy.loginfo("Executing...")
            outcome = bt.execute()
Exemplo n.º 2
0
 def test_sequence(self):
     p = ParallelAnyTask()
     with p:
         ParallelAnyTask.add(TrueTask())
         ParallelAnyTask.add(FalseTask())
         
     s = SequenceTask()
     with s:
         SequenceTask.add(p)
         SequenceTask.add(FalseTask())
         
     p2 = ParallelAnyTask()
     with p2:
         ParallelAllTask.add(s)
         ParallelAllTask.add(SleepTask(1.0, succeed=False))
         
     s2 = SelectorTask()
     with s2:
         SelectorTask.add(p2)
         SelectorTask.add(SleepTask(1.0))
         
     bt = smach_bt.BehaviorTreeContainer()
     bt.set_root(s2)
     sis = smach_ros.IntrospectionServer('server_name', bt, '/SM_ROOT')
     sis.start()
     wait_start = rospy.Time.now()
     while (rospy.Time.now() - wait_start).to_sec() < 10 and not rospy.is_shutdown():
         rospy.sleep(0.1)
         rospy.loginfo("Executing...")
         outcome = bt.execute()
Exemplo n.º 3
0
 def test_run_false(self):
     seq = SequenceTask()
     with seq:
         SequenceTask.add(SleepTask(0.1))
         SequenceTask.add(FalseTask())
     bt = smach_bt.BehaviorTreeContainer()
     bt.set_root(seq)
     self.assertEqual(bt.execute(), 'aborted')
Exemplo n.º 4
0
 def test_run_true(self):
     seq = SequenceTask()
     with seq:
         SequenceTask.add(SleepTask(0.1))
         SequenceTask.add(TrueTask())
     bt = smach_bt.BehaviorTreeContainer()
     bt.set_root(seq)
     self.assertEqual(bt.execute(), 'succeeded')
Exemplo n.º 5
0
 def test_run_false(self):
     seq = SequenceTask()
     with seq:
         SequenceTask.add(SleepTask(0.1))
         SequenceTask.add(FalseTask())
     bt = smach_bt.BehaviorTreeContainer()
     bt.set_root(seq)
     self.assertEqual(bt.execute(), 'aborted')
Exemplo n.º 6
0
 def test_run_true(self):
     seq = SequenceTask()
     with seq:
         SequenceTask.add(SleepTask(0.1))
         SequenceTask.add(TrueTask())
     bt = smach_bt.BehaviorTreeContainer()
     bt.set_root(seq)
     self.assertEqual(bt.execute(), 'succeeded')