(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.


Description: 本教程将展示如何实现一个通用SMACH状态

Tutorial Level: BEGINNER

Next Tutorial: CB 状态

   1 from smach import State


   1   class Foo(smach.State):
   2      def __init__(self, outcomes=['outcome1', 'outcome2']):
   3        # Your state initialization goes here
   5      def execute(self, userdata):
   6         # Your state execution goes here
   7         if xxxx:
   8             return 'outcome1'
   9         else:
  10             return 'outcome2'


  • 不要在构造函数中阻塞。如果你的状态需要等待另一个组件出现,请在单独的线程中执行此操作。

Wiki: cn/smach/Tutorials/Generic State (last edited 2018-03-10 07:26:12 by Playfish)