Lab 3: Hello Misty


Learning Goals


To Complete Before Lab


Preparing Your Development Environment

To allow you to start programming Misty right away, we are asking all of you to prepare your software development environment in advance of class. Please follow the steps below.

Note: Throughout this course, you will use your own laptop to program Misty and run all code locally.

Important: Before reaching out to the teaching team for help, please read the Common Errors & Troubleshooting section at the end of this lab. Most setup issues can be resolved using those instructions.

  1. Python version: Ensure that your Python version is >= 3.10. You can check your Python version by running in your terminal:
    python3 --version
    If your version is lower than 3.10, install a newer version from python.org.
  2. Create hri_course_misty_programming: Create one folder where you will keep all of your Misty work for this course.

    In the terminal, you can create this folder by running:

    mkdir hri_course_misty_programming
  3. Create your virtual environment (follow this exactly): We use a virtual environment so everyone installs the same Python packages for Misty in one isolated place, which makes setup and debugging much easier. In the terminal, cd into hri_course_misty_programming and create a virtual environment named venv:
    cd hri_course_misty_programming
    python3 -m venv venv
    source venv/bin/activate
    After activation, you should see (venv) in your terminal.
    When you're done coding: To deactivate your virtual environment, run:
    deactivate

    Important: Please name your virtual environment venv, not .venv. A folder that starts with a dot is hidden on macOS/Linux, so it will not appear when you type ls. Hidden folders only show up with ls -a, which has caused confusion for students in the past.
  4. Install dependencies: With your virtual environment activated, install only the packages needed for this lab and the Misty Python SDK by running the following commands in the terminal:
    pip install requests
    pip install --force-reinstall -v websocket-client==0.57.0
    pip install --force-reinstall -v urllib3==1.26.20
    pip install Pillow
    Important: Do not run pip install misty. That is not the SDK we are using for this course, and past students have gotten confused by this.
  5. Clone Misty's Python SDK: Run in the terminal (while in hri_course_misty_programming):
    git clone https://github.com/MistyCommunity/Python-SDK.git
  6. Create your Lab 3 folder and add the starter code: Inside hri_course_misty_programming, either:
    • Use our template repo:
      1. Open the template repo: lab_3_misty_introduction
      2. Click the Code button on GitHub and copy the HTTPS clone URL
      3. In the terminal, change into hri_course_misty_programming (where you want the lab folder to live)
      4. Clone your copy so the folder is named lab_3_misty_introduction and sits directly inside hri_course_misty_programming. Example:
        git clone https://github.com/your-username/lab_3_misty_introduction.git
    • Manually copy the starter code: In the terminal, create the folder and file with:
      cd hri_course_misty_programming
      mkdir lab_3_misty_introduction
      touch lab_3_misty_introduction/misty_introduction.py
      Then copy the following starter code into lab_3_misty_introduction/misty_introduction.py:
      import sys, os, time
      sys.path.append(os.path.join(os.path.join(os.path.dirname(__file__), '..'), 'Python-SDK'))
      
      from mistyPy.Robot import Robot
      from mistyPy.Events import Events
      
      if len(sys.argv) != 2:
          print("Usage: python3 misty_introduction.py <Misty's IP Address>")
          sys.exit(1)
      
      ip_address = sys.argv[1]
      misty = Robot(ip_address)
      
      misty.speak("Hi!")
      
      # TODO: Complete Misty's introduction
      This starter code assumes that lab_3_misty_introduction and Python-SDK are both directly inside hri_course_misty_programming.

      How to run: With your virtual environment activated and while inside lab_3_misty_introduction, run:

      python3 misty_introduction.py <MISTY-IP-ADDRESS>
      Replace <MISTY-IP-ADDRESS> with your robot's IP address.

  7. Use this folder structure: To make debugging easier, everyone should organize their files in the same way:
    hri_course_misty_programming/
    ├── venv/
    ├── Python-SDK/
    ├── lab_3_misty_introduction/
    │   └── misty_introduction.py
    Important:
    • Python-SDK should be directly inside hri_course_misty_programming
    • Your Lab 3 folder should also be directly inside hri_course_misty_programming
    • Do not put Python-SDK inside your lab folder

Working in Groups


During this lab, you will work at a table with 3 students and 1 Misty robot. Each individual within the group is expected to write their own code and implement their own robot introduction. While each student is completing their own work on the robot, we highly encourage your groups to collaborate with one another by sharing ideas and helping each other debug your code.

You will work with this same group for all of the robot programming labs (Labs 3-5). Group assignments can be found on the tables in CSIL 1/2 when you arrive.

Lab 3 Deliverables & Submission


Your work on Lab 3 will involve programming the Misty robot to introduce itself using our starter code as a starting point. Your are expected to upload the following to Canvas after you have completed the lab:

To receive credit for this lab, you will need to submit your video and code to Canvas by Thursday, April 9, 2026 at 11:59pm.

Connecting to Misty


Follow these instructions to connect to Misty. We used the Misty II documentation to create these instructions.

Turning Misty On

Misty On Button

Toggle the power switch on Misty's base (located between the treads at the back of the robot). The robot will take a little bit to fully boot up. The eyes will be fully open once Misty has finished the booting process. To turn Misty off, toggle this same switch.

Connecting to Wi-Fi

In order to program Misty, both your computer, your Misty app, and the robot will need to be connected to the same Wi-Fi network.

Follow these instructions to connect Misty to Bluetooth and Wi-Fi. To connect to Misty, you'll need to have either an iPhone or Apple tablet download the Misty app from the Apple App store and use this app to connect Misty to the same Wi-Fi network.

Misty Studio

Open up the Misty Studio by entering http://{MISTY-IP-ADDRESS}/ in a browser window. If you cannot open Misty Studio, please read the instructions below in HTTP Connection Errors. Play around with Misty Studio! You can have Misty speak, move, change its facial expression and more. Misty Studio should look like the following image:

Misty Studio

Misty Python API

In this class, we recommend that you use the Misty Python API to program Misty. For today's lab, the pages that you'll likely find most useful are:

Labs 3-5 Context


In our robot programming labs (labs 3-5), you will be programming the Misty robot to act as a facilitator of a positive psychology exercise called the "Three Good Things." This is a well-known exercise from positive psychology research. The idea is simple: at the end of the day (or week), a person reflects on three good things that happened and briefly thinks about why they happened. Research has shown that doing this regularly can improve mood, increase well-being, and reduce stress. In this exercise, both the robot and the participant will take turns sharing three things that they are grateful for that have happened to them in the past week. If you want to learn more about this exercise, you can read more here: Three Good Things – Greater Good Science Center (UC Berkeley)

Here are a few simple examples of "Three Good Things":

For this lab sequence, Misty will eventually help guide the user through sharing these kinds of positive reflections.

We will be programming a different part of this interaction in the three labs:

Lab 3 Exercise: Robot Introduction


Your Goal

Your goal for this lab is to program a Misty to introduce itself to a new human participant and also introduce the "Three Good Things" exercise (see above). Your introduction needs to make use of all of the following components:

Note: When starting to test out the wheel/tread movements on the robot we highly recommend that you put the robot on the floor so that we don't have any Mistys taking dives off of the tables.

The following video is a simple example of a Misty introduction that uses all of the components listed above:

Extra Challenge

If you find yourself wanting to take on an extra challenge, you can try to incorporate the Misty events to allow the user to start the Misty's introduction only when it's bump sensor is pressed. We recommend checking out the following resources to implement this:

Common Errors & Troubleshooting


HTTP Connection Errors

If you see an error like the one below, or if you cannot open Misty Studio in your web browser, your computer is usually blocking the connection to Misty:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.0.182', port=80): Max retries exceeded with url: /api/tts/speak (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x101d5a310>: Failed to establish a new connection: [Errno 65] No route to host'))

Before troubleshooting your laptop settings, make sure that:

This error usually means your computer is blocking the connection. Follow the instructions below for your operating system:

For Mac users

If you're running from VS Code Terminal
  1. Open System SettingsPrivacy & SecurityLocal Network.
  2. If Visual Studio Code appears and is unchecked, check it to allow network access.
  3. If Visual Studio Code is not listed, run your code once. macOS often prompts on first use and will then show the app here.
  4. Restart Visual Studio Code after changing the setting, then try again.
If you're running from your local Terminal (outside VS Code)
  1. Open System SettingsNetworkFirewallOptions… (you may need to enter your password).
  2. If Terminal or Python is listed, set it to Allow incoming connections.
  3. If it's not listed, temporarily disable the firewall to test: toggle the Firewall switch to Off, run your code, then re-enable the firewall.
  4. If disabling the firewall fixes the issue, add a permanent allow rule for Terminal or Python via Options… rather than leaving the firewall off.

For Windows users

If you're running from VS Code Terminal
  1. Open Windows SecurityFirewall & network protectionAllow an app through firewall.
  2. Click Change settings, then look for Visual Studio Code.
  3. If it appears, make sure it is allowed on the network you are using. For most students, allowing it on Private networks is enough.
  4. If Visual Studio Code is not listed, run your code once and watch for a Windows Firewall pop-up. If prompted, allow access on your current network.
  5. Restart Visual Studio Code after changing the setting, then try again.
If you're running from Command Prompt, PowerShell, or Windows Terminal
  1. Open Windows SecurityFirewall & network protectionAllow an app through firewall.
  2. Look for your terminal app or for Python. If it is listed, allow it on your current network.
  3. If Python is not listed, run your code once and watch for a Windows Firewall pop-up asking whether to allow access.
  4. If you do not get a pop-up, temporarily turn off the firewall for your current network to test, run your code once, and then immediately turn the firewall back on.
  5. If disabling the firewall fixes the issue, add a permanent allow rule for Python or your terminal app rather than leaving the firewall off.

For Linux users

If you're running from VS Code Terminal
  1. Check whether your system firewall is enabled. On Ubuntu, many students can do this with sudo ufw status.
  2. If a firewall is active, allow outgoing and local network traffic for Visual Studio Code or for Python, depending on how your Linux setup manages application rules.
  3. If Visual Studio Code was installed as a Snap or Flatpak, also check that sandboxed app permissions are not blocking local network access.
  4. Restart Visual Studio Code after changing the setting, then try again.
If you're running from your local Terminal
  1. Check whether your firewall is enabled. For example, on Ubuntu you can run sudo ufw status.
  2. If it is active, temporarily disable it to test with sudo ufw disable, run your code once, and then re-enable it with sudo ufw enable.
  3. If disabling the firewall fixes the issue, add a more specific allow rule for local network traffic or for Python rather than leaving the firewall off.
  4. If your distribution does not use ufw, check your firewall tool's documentation, such as firewalld or iptables, and allow the relevant local network traffic there.

Security note: Do not leave your firewall disabled — only use disabling briefly for testing. Prefer adding a specific allow rule for the app that needs network access.

Module Not Found Errors

Even after running pip install, you might still see errors like these:

ModuleNotFoundError: No module named 'requests'
ModuleNotFoundError: No module named 'websocket'
ModuleNotFoundError: No module named 'PIL'

For this lab, the most common causes are:

Here's how to fix it:

Once your packages are installed in the correct location, they should be properly recognized by your Python installation.

Misty SDK Import Errors

If you see the following error:

from mistyPy.Robot import Robot
ModuleNotFoundError: No module named 'mistyPy.Robot'

This usually means Python cannot find the Misty Python SDK.

Step 1: Verify your folder structure

Make sure your folders look like this:

hri_course_misty_programming/
├── Python-SDK/
├── lab_3_misty_introduction/

Step 2: Check the path in your code

If your Python file is inside lab_3_misty_introduction, then the path to the SDK should usually be:

import sys, os
    sys.path.append(os.path.join(os.path.join(os.path.dirname(__file__), '..'), 'Python-SDK'))

Step 3: Print the path if you still cannot locate the SDK

Add the following debugging code and check whether the printed path matches where your Python-SDK folder is actually located on your computer:

import sys, os

    sdk_path = os.path.join(os.path.join(os.path.dirname(__file__), '..'), 'Python-SDK')
    print("SDK path:", sdk_path)

    sys.path.append(sdk_path)
    print("Python path:")
    for p in sys.path:
        print(p)

If the printed SDK path is wrong, update the path in your code so it matches your actual folder location.

Common causes:

Quick Debug Checklist