# Class Meeting 06: Advanced Blockly - Battle of the ClicBots

## Learning Goals

• You will learn about rotational angles and angle arithmetic
• You will build upon your existing knowledge on conditional statements (if, else if, else) in Blockly.
• You will think outside the box and build something fun (and defeat your classmates)

## Lecture Overview

Here is a link to the presentation slides for today.

## Programming Exercise #1: Getting the first joint pair to work together.

In this first exercise, get some hands on experience with measuring joint angles and using that measurement to move other joints. To begin, build a ClicBot that has 6 joints with the base, a long arm, a gripper, and a brain, as pictured below.

Then, create a new program that measures the angle of joint A (pictured). HINT: use the "detect servo angle" sensor in the sensors tab.

Once you're familiar with how the angle reading of joint A changes as you rotate the joint upon its axis, add additional logic to make joint B mimic the movements of joint A.

HINT 1: you can use constant offsets to account for the angle difference in which joint A and joint B start at.

HINT 2: is your logic correct but the program not doing anything? Maybe it is doing something really but just doing once, really quickly that you didn't notice. How do you get it to keep doing it?

This is what your finished product should do.

Discuss as a group: Once you're done, compare your program with your neighbors - are there any drastic differences? If so, what do you think contributed to this disparity?

## Programming Exercise #2: Please pair up with your neighbor and build a big robot

IMPORTANT: In order to ensure that everyone in the group has a chance to participate, please refer to the Group Assignment Sheet to see who is responsible for which task. Please check with an instructor when you're done with each task.

Please build the following robot as pictured below. Note: you will need to borrow your neighbor's joints to make this work.

This robot will require 9 joints, 1 long arm, 1 gripper, 1 brain, and 1 smart foot. Once you're settled in with your combined group, raise your hand and we will hand you a smart foot.

## Programming Exercise #3: Program 3 of the Big Robot's joints

Please refer to the following diagrams for the correct joint pairing. Note that there are 2 vertically rotating joints and 1 horizontally rotating joint. The exercise is broken down into 3 parts, 3.1, 3.2, and 3.3. The individual assigned to each task must complete that task, discussion with the team is encouraged.

1. Blue joint pair
2. Green joint pair.
3. Red joint pair.

Here's a demo of what your end product should be able to do. Note: Your implementation doesn't have to be exactly the same, as long as it does something similar, you're good.

Discuss as a group: This exercise will likely challenge your debugging skills. It's important to note that there are usually multiple ways to solve a problem - I would encourage y'all to try whatever comes to mind!

## Programming Exercise #4: Program the Gripper & Smart Foot

You're nearly done! The last thing you'll need to program as a group is the gripper and the smart foot. Your program logic should aim to open/close the gripper based on pressure input on the smart foot. Note: the units of force used by the smart foot is Newton

Here's a demo of what your end product should be able to do. Note: Your implementation doesn't have to be exactly the same, as long as it does similar things, you're good.

## Programming Exercise #5: Optimizing Your Program and Powering Up Your Robot Build

Now that you're done with building and coding the Big Robot, take turns trying to pick up blocks and drop them into the Accessories box.

This is also a good opportunity to fine tune your program so that it behaves exactly like you want it to. You're also encouraged to modify the structural design of your robot by adding additional joints, grippers, etc. This will give you an edge in the competition you'll have against your neighbors in the next exercise. Winners will get prizes! Feel free to check out the rules in Exercise 6.

## Programming Exercise #6: Battle of the ClicBots

The objective of this game would be to score the most points by picking up blocks and placing them into your team's box. The different blocks are worth different number of points!

• PURPLE: 1
• GREEN: 2
• YELLOW: 3
• RED: 4
• ORANGE: 5
• SCREW DRIVER: 10

If you manage to decapitate your opponent's robot, your team will win by knockout!

## Optional Programming Exercise #7: Using a Joint as a Sensor

If you're done with the other exercises, please work on this exercise from last week: The goal of this exercise is to create a ClicBot robot that is controlled by the rotation of one of it's joints. If you rotate the joint quickly, the robot will move fast. If you rotate the joint slowly, the robot will move slowly. Let's get started.

First, build a ClicBot that looks like the following picture:

As mentioned before, you'll rotate one of the ClicBot's joints to guide it's forward speed. We've attached the ClicBot holder to make this joint easier to rotate. See below for an example of how to rotate this joint for this exercise.

Now that we have the robot set up, let's get more specific about it's behavior. You'll design three "modes" for the robot:

• Fast: When you rotate the robot's joint at a fast speed, have the robot move forward for a short distance very quickly.
• Medium: When you rotate the robot's joint at a medium speed, have the robot move forward for a short distance with a moderate speed.
• Slow: When you rotate the robot's joint at a slow speed, have the robot move forward for a short distance slowly.

The following piece of code gives you a snippet of what you'll need for this program.

You'll want to use the if block to detect how fast your joint is moving. You'll use the sensor block Detect rotation speed of Joint [NO.X] to get the rotation speed of the joint. You'll need to compare it to a numeric value. Then, you'll need to specify the wheel rotations that will follow that joint rotation speed using the Wheel [NO.X + Direction] rotation, speed block.

Some tips for this exercise:

• Before you start programming, it might be helpful to talk through and write out your if, else if, and else logic.
• You'll want to include some delay blocks to: (1) avoid the robot fleeing right after you rotate the joint and (2) determine how long the robot moves forward.
• You'll also need to think about whether or not you need an else condition at the end and what that could be used for.

## Requirements to Meet Expectations for Today's Class

• Your small team completed exercise 1
• Your large team completed the Big Robot build.