$24
The goals of this lab are to understand
Basic reactive behaviors such as attraction and avoidance
How to compose multiple behaviors into more complex ones
The notion of state and basic ways of implementation
You need:
A functional Sparkiduino development environment
Sparki robot
Line-following map
Overview
A very simple way to program a robot is to directly tie its sensor input to wheel motion. Examples include obstacle avoidance, for example "turn right if you see an obstacle in front", light following or avoidance, or line following. One type of these robots is a "Braitenberg Vehicle". It would be quite limiting, however, if robots would exhibit always the same behavior when presented with stimuli. To achieve more complex behaviors, robots need to switch between different operational modes based on the context they’re in. In the first part of this lab, you will play with different standard behaviors. You will then create a simple finite state machine and switch between different behaviors to accomplish a complex task.
Instructions
Each group must develop their own software implementation and turn in individual lab reports. You are encouraged to engage with your lab partners for collaborative problem-solving, but are expected to turn in your own write-ups. If your group does not finish the implementation by the end of the class, you may continue this lab on your own time as a complete group. A limited number of Sparkis will be available to sign out after each lab, and must be returned by the following lecture.
Part 1: Introduction to Arduino/Sparki
Use the instructions on the Sparki website to run and understand a series of basic reactive behaviors:
Wall avoidance
Light following
Line following.
Part 2: Implementation
Implement a state machine-based controller that recreates the following behavior:
The robot rotates in place until it detects an object within 30cm with its ultrasound sensor. The robot then drives to within 7cm of the detected object and captures it in its gripper. Once the object is secured, the robot turns 180 degrees and drives until it detects a line. Once it has found a line, the robot will follow it until reaching the "start" marker, at which point it stops, beeps, and drops the carried object.
HINT 1: If you are stuck on the “C” syntax or the Arduino code peculiarities, look for help in the “Coding” section of the Sparki Website
HINT 2: This code will be more readable if you use a "switch" statement. You can use “pound defines” such as "#define STATENAME number" to make your code more readable (e.g., #define START_STATE 1).
HINT 3: Planning your answer for Part 3 - #1 before writing code will make this easier.
Part 3: Lab Report
Create a report that includes/answers the following:
A drawing of your state machine. Make sure all the states and transitions are labeled and that it is faithful to your implementation.
The names of everyone in your lab group.
Were you able to get your program to complete the task? If not, which parts failed? Why?
A statement indicating whether you have worked with the C programming language before, and if so, describe your experience.
A statement indicating your level of prior experience with the Arduino platform, if any.
How much time did you spend programming Part 2 of this lab?
(Optional, confidential, not for credit) A brief description of any problems (either technical or collaborative) encountered while performing this lab (e.g., issues with the clarity of instructions, clarity of documentation, lab colleague’s behavior, etc.).