Lab 5

Lab 5: Servoing and Finite State Machines

The objective of this lab is to program Cozmo to locate and go to the ball.

1. Find a ball and a space with clean background, such as a box you can place the Cozmo into. You will use the ball recognition algorithm you developed in lab 4 to find the ball in Cozmo’s camera image. If necessary, update your find_ball() function for the new setting you are working in.

2. You are provided the following file to assist with this assignment:

    • goto_ball.py – this is the main file where you will enter your solution. When Cozmo runs, the code will open a viewer that will display the robot’s camera data. Two viewer annotators are provided, BatteryAnnotator() and BallAnnotator(), that display the battery and ball information, respectively. Feel free to add your own annotators if you find that helpful. The main functionality of the code resides in run() which you should extend to have the robot look around for and go to the ball. Make sure you can execute this Python script and make sure your ball detector is working.

3. Complete the code to enable the robot to search for, then go to, and hit the ball. There are a variety of behaviors you can program to have the robot search, including turning or driving around. The hit can be an existing Cozmo animation or lifting/lowering of the arm. Feel free to integrate animations, sounds and the display into your code. When completed the robot should exhibit the following behavior:

  • The robot executes a search behavior until the ball is in view
  • The robot moves toward the ball
  • When the ball is close enough, the robot moves its arm to hit the ball

Make a video demonstrating this behavior and upload on Youtube.