Cognitive Approach to Hierarchical Task Selection for Human-Robot Interaction in Dynamic Environments