Skip to content

User Story #3 -- Robot Movement #8

Description

@medinafdzz

To move into the room, the robot receives a command (i.e., a string) from the RMS. When this happens, the robot controls the wheel motor and the rotation motor in order to execute the command, then updates its status (see User Story #1), and finally returns a string (representing its new status) to the RMS.

The robot moves one cell forward when it receives the command f. If the robot receives the command r or l, it turns right or left respectively – i.e., it rotates clockwise or counterclockwise 90° around itself. The robot cannot move backward.

The two motors that control, respectively, the wheels and the rotation of the robot are DC motors. They have already been set up in the constructor of the CleaningRobot class. To control the motors, use the following two methods (already implemented):

  • CleaningRobot.activate_wheel_motor() -> None, which activates the wheel motor to let the robot move forward.
  • CleaningRobot.activate_rotation_motor(direction: str) -> None, which activates the rotation motor to let the robot turn left or right based on a string representing the direction (i.e., l to turn left, r to turn right).

Requirement:

  • Implement CleaningRobot.execute_command(command: str) -> str to execute the command passed by the RMS (i.e., f, l, or r), update the status of the robot, and then return a string representing the new status of the robot.

Examples:

  • If the robot status is (0,0,N) and it receives the command f, the robot moves one cell forward – i.e., the robot controls the wheel motor in order to move one cell forward – and returns the new status (0,1,N).
  • If the robot status is (0,0,N) and it receives the command r, the robot rotates clockwise 90° – i.e., the robot controls the rotation motor in order to rotate 90° – and returns the new status (0,0,E). Similarly, if it receives the command string l, the robot rotates counter 90° and returns the new status (0,0,W).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions