Removed code duplication between robot and controller.