ros / executive_smach

A procedural python-based task execution framework with ROS integration.
Other
173 stars 141 forks source link

Input keys check on StateMachine doesn't check if the keys are already there #92

Closed gerardcanal closed 1 year ago

gerardcanal commented 1 year ago

Hi, I'm not sure if this is actively maintained or not, but worth to ask.

I think there's an issue with the checks of input keys in statemachines. Example: I define a StateMachine with defined input keys, and then set the input keys manually on the userdata such as:

sm = smach.StateMachine(outcomes=['aborted','succeded'], input_keys=['a'])
sm.userdata.a = 1

This will trigger an error Userdata key 'a' not available. Available keys are: []. And this is not fully true, as the keys are there. This seems to come from https://github.com/ros/executive_smach/blob/31cc55743431f48e37ee71d26acd5833ebd3753e/smach/src/smach/state_machine.py#L316 Where the parent_ud is set to empty userdata instead of None. This is only used in the _copy_input/output_keys, where the error is triggered: https://github.com/ros/executive_smach/blob/31cc55743431f48e37ee71d26acd5833ebd3753e/smach/src/smach/container.py#L104

There may be the need to still check the input_keys are available or pre-written (or maybe not, as I guess the error would trigger when the keys are used later on by one of the States). This could be done inside check_consistency.

Happy to make a PR if this makes sense, but would be good to know if there's anyone there to check it and merge it!

gerardcanal commented 1 year ago

I gladly saw that there was some recent movement in the repo, so I went ahead with PR #107 to fix this issue. I hope that maybe @130s (or someone else, not sure who is maintaining?) will be able to check these PRs.