Skip to content

Instantly share code, notes, and snippets.

@nilbus
Forked from swalke16/gist:cbc8fd10180d9d04d682
Last active August 29, 2015 14:25
Show Gist options
  • Save nilbus/740a05b9454d6794e804 to your computer and use it in GitHub Desktop.
Save nilbus/740a05b9454d6794e804 to your computer and use it in GitHub Desktop.
Robot Controller Exercise

#Assignment:

Create a controller for a robot

Forward
Left 0 Right
Back

##Requirements:

  1. Controller starts at rest, speed: 0, direction: none.
  2. Controller can issue four directional instructions (Forward, Back, Left, Right).
  3. When at rest, instructions to move in a certain direction will set direction to that direction and speed to 1.
  4. When moving, instructions to move in the same direction as currently moving increment speed in that direction by 1.
  5. When moving, instructions to move in the opposite direction as currently moving decrement speed by 1 until reaching 0, at which point the controller is now at rest, and the instructions for moving from rest apply.
  6. When moving, Instructions to move in a perpendicular direction to current direction will change direction to that direction and speed to 1.
  7. When moving, once reaching speed level four in a given direction further instructions to move in that direction return speed to 0 and directon to "none".

Additional Requirements for non-web version

  1. Controller should be written so that the input and output can be varied independently of each other. For example I may want to drive the controller either programatically or manually and I may want to have it output to a console or a physical hardware device.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment