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

pv's profile - activity

2017-12-04 04:16:32 -0500 received badge  Famous Question (source)
2017-11-26 17:26:54 -0500 received badge  Famous Question (source)
2017-10-09 09:25:34 -0500 received badge  Notable Question (source)
2017-10-09 09:25:34 -0500 received badge  Popular Question (source)
2016-11-29 08:23:33 -0500 asked a question Preempt a state doesn't work


I have tried to do a concurrence state with one one monitor-state that check for a reset topic and one state with a lot of sub-states that do the actual work. The goal is to and the work if someone publish on the reset topic. My problem is that then I publish and the monitor-state get active and try to preempt the other state nothing happen and the work continue:

For every sub state it said:

[INFO] [WallTime: 1480428562.104071] [3378.814000] Preempt requested on state machine before executing the next state. 
[INFO] [WallTime: 1480428562.105243] [3378.814000] Last state 'First task' did not service preempt. Preempting next state 'Second task' before executing...

But then continue. Do I have to add something to all the state that should happend then preempting? They are ordinary smach.state.

2016-11-28 19:24:35 -0500 received badge  Notable Question (source)
2016-10-13 08:27:23 -0500 commented answer Userdata change type

Thanks for the answers!

2016-10-12 02:09:57 -0500 received badge  Supporter (source)
2016-10-12 02:09:24 -0500 answered a question Userdata change type

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'],

    # 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(),

            smach.StateMachine.add('Calculate_pallet_position', Calculate_pallet_position(),
2016-10-11 17:13:38 -0500 received badge  Popular Question (source)
2016-10-10 05:03:36 -0500 received badge  Editor (source)
2016-10-10 05:00:12 -0500 asked a question Userdata change type


I try to du a small smach tree and pass a class between the state with userdata, the code look like this

class Auto_move_info(object):
        __pallet_position = None
        __pallet_place_position = None

    def __init__(self, pallet_position=None, pallet_place_position=None):
        self.__pallet_position = pallet_position
        self.__pallet_place_position = pallet_place_position

    def set_pallet_position(self, pallet_position):
        self.__pallet_position = pallet_position

    def get_pallet_position(self):
        return self.__pallet_position

    def set_pallet_place_position(self, pallet_place_position):
        self.__pallet_place_position = pallet_place_position

    def get_pallet_place_position(self):
        return self.__pallet_place_position

class Get_pallet_position(smach.State):
    def __init__(self):
        smach.State.__init__(self, outcomes=['pallet_position_found'],
        self.move_pallet_A_to_X = Auto_move_info('A','X')

    def execute(self, userdata):
        userdata.get_pallet_position_op = self.move_pallet_A_to_X
        print ("1")
        print ("2")
        return 'pallet_position_found'

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

    def execute(self, userdata):
        print ("3")
        print ("4")
        rospy.loginfo('Executing state Calculate_pallet_position')
        return 'calculation_pallet_done'

The result the become:

[INFO] [WallTime: 1476091443.061490] State machine starting in initial state 'Get_pallet_position' with userdata: 
<class_definition.Auto_move_info object at 0xb59ced2c>
[INFO] [WallTime: 1476091445.064946] Get_pallet_position
[INFO] [WallTime: 1476091445.065734] State machine transitioning 'Get_pallet_position':'pallet_position_found'-->'Calculate_pallet_position'
<smach.user_data.Const object at 0xb6158b4c>
[INFO] [WallTime: 1476091447.070927] Executing state Calculate_pallet_position

Why does the object move_pallet_A_to_X change from an Auto_move_info object to a Const?