Userdata change type
Hi,
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'],
output_keys=['get_pallet_position_op'])
self.move_pallet_A_to_X = Auto_move_info('A','X')
def execute(self, userdata):
time.sleep(2)
userdata.get_pallet_position_op = self.move_pallet_A_to_X
print ("1")
print(self.move_pallet_A_to_X)
print ("2")
rospy.loginfo('Get_pallet_position')
return 'pallet_position_found'
class Calculate_pallet_position(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes=['calculation_pallet_done'],
input_keys=['calculate_pallet_position_ip'],
output_keys=['calculate_pallet_position_op'])
def execute(self, userdata):
time.sleep(2)
print ("3")
print(userdata.calculate_pallet_position_ip)
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:
[]
1
<class_definition.Auto_move_info object at 0xb59ced2c>
2
[INFO] [WallTime: 1476091445.064946] Get_pallet_position
[INFO] [WallTime: 1476091445.065734] State machine transitioning 'Get_pallet_position':'pallet_position_found'-->'Calculate_pallet_position'
3
<smach.user_data.Const object at 0xb6158b4c>
4
[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?