ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It works, but I wounder if I can have any problem with that the input_key and the output_key has the same name? Should I do in some other way? Right now I have declared both like input and output but only one of them is remapping with another state.

class Calculate_pallet_position(smach.State):
    def __init__(self):
        smach.State.__init__(self, outcomes=['calculation_pallet_done'],
                            input_keys=['calculate_pallet_position_ip','calculate_pallet_position_op'],
                            output_keys=['calculate_pallet_position_ip','calculate_pallet_position_op'])


#-------------------------------------------------------------------------------    
    # Create the sub SMACH state machine 
        sm_go_to_pallet = smach.StateMachine(outcomes=['go_to_pallet_done'])

        # Open the container 
        with sm_go_to_pallet:

            # Add states to the container 
            smach.StateMachine.add('Get_pallet_position', Get_pallet_position(),
                                   transitions={'pallet_position_found':'Calculate_pallet_position'},
                                   remapping={'get_pallet_position_op':'calculate_pallet_position_ip'})

            smach.StateMachine.add('Calculate_pallet_position', Calculate_pallet_position(),
                                   transitions={'calculation_pallet_done':'Move_forklift_to_pallet'},
                                   remapping={'calculate_pallet_position_op':'move_forklift_to_pallet_ip'})