STEMLabs V5
Speedy Delivery Teacher

Teacher Portal

# Behavior-Based Programming

### Programming Complexity

Robots can be designed to perform a wide range of tasks. Some of these tasks are very simple, like opening an automatic door. Others can be far more complex, like an autonomous car navigating an urban environment. No matter how complex the task is, it can be broken down into simpler tasks. These tasks are known as behaviors and are the building blocks of robotics programming.

A behavior is a way that a robot acts, and can range in complexity depending on how the robot is built or programmed. A simple mobile robot like the VEX V5 Speedbot only has two motors, while the Clawbot has four motors, including two additional motors for the Arm and Claw. Behaviors for both robots will involve turning those motors to accomplish set goals. With more design and programming, you can start from this simple behavior and do more complex behaviors.

Below is a list of robot behaviors increasing from simple to complex for both the Speedbot and the Clawbot. In parentheses, you can see the simpler behaviors that compose each one.

• Rotate a motor assigned to a certain port

• Drive forward (rotate both the left and right motors using the Drivetrain)

• Travel 5 meters (drive forward, then stop)

• Grab a distant object (travel 2 meters, rotate the claw motor to grab it)

• Retrieve an object and put it on a high shelf (grab a distant object, turn around, travel 2 meters, use the arm and claw motors to raise and release the object)

You can see how you can deconstruct any of the more complex behaviors into simpler behaviors. These become the building blocks of any complex task.

Teacher Tips

• Instruct students to break down the complex robot behaviors into smaller, simple steps. This process is known as decomposition.

• Explain to students that decomposing (breaking down) complex behaviors into simpler tasks is an important part of planning and programming.

• Allow students to run their autonomous projects if there is enough class time.

To connect this activity to computational thinking and decomposition, ask students to map out, or list, the behavioral steps that a robot would carry out to complete the activities below:

• Activity One: Travel 1 meter and return to the starting spot.

• Activity Two: Flip a box located 60 cm in front of the robot.

• Activity Three: Pick up an object, shake it, travel 30 cm, place the object down on the ground, and return to the starting point.

Motivate Discussion

Students should share the behavioral steps that they listed for the activities from the Extend Your Learning above. Each of the following questions can be asked after any or all of the activities.

Q: Which steps or behaviors did each group list to successfully complete this activity?
A: Students will need to consider the length the robot must travel and the movement and speed of the arm, in addition to listing the simple robot behaviors required to complete the activity or task (driving forward, in reverse, turning left or right). Students should create their lists of behaviors so that each step is represented.

Q: What were the similarities and differences between the solutions (lists of steps) for this activity?
A: Students will make comparisons based on their solutions. A Venn diagram might be a good way to organize the steps students share. If the majority of students name a particular step, add it to the center where the circles overlap. If only one or a few students name a particular step, add it to one circle or the other. When done, the steps in the center should be reliably simple and unable to be broken down further whereas the steps listed in only one of the circles are likely not as simple as they could be. However, this pattern might be reversed depending on the class's experience in breaking down complex behaviors into their simplest steps.

Q: Were there similarities to the successful solutions? If so, what were they?
A: The most successful solutions were those that included the most detail and specificity. The robot is programmed in a language with very specific behaviors that have been broken down into their smallest components. For example, it might be common to say a robot "travels 1 meter and returns to the starting spot" but that high-level description does not easily translate when programming. You have to break it down further: drives forward for 1 meter, turns 180 degrees, and drives forward for 1 meter. But even that might not be precise enough and you need this level of detail to be programming-ready: set the drive and turning velocities to 40%, drive forward for 1 meter, wait 3 seconds, turn left for 180 degrees, wait 1 second, and drive forward for 1 meter. The further we break down complex behaviors to make them programming-ready robot behaviors, the better prepared we are to complete a project.