TAR: Trajectory adaptation for recognition of robot tasks to improve teamwork