You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the add_auto function, the resulting transitions are not as expected from the documentation. I am not sure if it is a bug or I am misreading the text (if so, many of my colleagues have done the exact mistake)
Using this method, I add connector_outcomes for all the outcomes of the state. I then use transitions with the intent of overwriting some of the outcomes defined by connector_outcomes, following the documentation:
@param transitions: A dictionary mapping state outcomes to other state
labels. If one of these transitions follows the connector outcome
specified in the constructor, **the provided transition will override
the automatically generated connector transition**.
However, when running this, the transition specified do not actually overwrite connector_outcomes and instead are ignored.
Example (modified from the tutorial)
class Foo(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes=['succeeded','failed'])
self.counter = 0
def execute(self, userdata):
rospy.loginfo('Executing state FOO')
if self.counter < 3:
self.counter += 1
return 'succeeded'
else:
return 'failed'
# define state Bar
class Bar(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes=['succeeded'])
def execute(self, userdata):
rospy.loginfo('Executing state BAR')
return 'succeeded'
# main
def main():
rospy.init_node('smach_example_state_machine')
# Create a SMACH state machine
sm = smach.StateMachine(outcomes=['succeeded', 'failed'])
# Open the container
with sm:
# Add states to the container
smach.StateMachine.add_auto('FOO', Foo(),
connector_outcomes=['succeeded', 'failed'],
transitions={'failed': 'failed'})
smach.StateMachine.add('BAR', Bar(),
transitions={'succeeded':'succeeded'})
# Execute SMACH plan
outcome = sm.execute()
if __name__ == '__main__':
main()
My expectation in this case is the Foo will have transition from succeeded to BAR and from failed to failed. However, visualizing this SM, I get:
The text was updated successfully, but these errors were encountered:
When using the
add_auto
function, the resulting transitions are not as expected from the documentation. I am not sure if it is a bug or I am misreading the text (if so, many of my colleagues have done the exact mistake)Using this method, I add
connector_outcomes
for all the outcomes of the state. I then usetransitions
with the intent of overwriting some of the outcomes defined byconnector_outcomes
, following the documentation:However, when running this, the transition specified do not actually overwrite
connector_outcomes
and instead are ignored.Example (modified from the tutorial)
My expectation in this case is the
Foo
will have transition fromsucceeded
toBAR
and fromfailed
tofailed
. However, visualizing this SM, I get:The text was updated successfully, but these errors were encountered: