Structured learning and inference for robot motion generation