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.
python3 --version
If your version is lower than 3.10, install a newer version from python.org.
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
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.
deactivate
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.
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.
hri_course_misty_programming):
git clone https://github.com/MistyCommunity/Python-SDK.git
hri_course_misty_programming, either:
hri_course_misty_programming (where you want the lab folder to live)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
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.
hri_course_misty_programming/
├── venv/
├── Python-SDK/
├── lab_3_misty_introduction/
│ └── misty_introduction.py
Important:
Python-SDK should be directly inside hri_course_misty_programminghri_course_misty_programmingPython-SDK inside your lab folderDuring 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.
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:
misty_introduction.pyTo receive credit for this lab, you will need to submit your video and code to Canvas by Thursday, April 9, 2026 at 11:59pm.
Follow these instructions to connect to Misty. We used the Misty II documentation to create these instructions.
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.
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.
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:
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:
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: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:
play_audio function that you can use to figure out how to play these audio expressions.The following video is a simple example of a Misty introduction that uses all of the components listed above:
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:
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:
sudo ufw status.sudo ufw status.sudo ufw disable, run your code once, and then re-enable it with sudo ufw enable.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.
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:
Python-SDK folderHere's how to fix it:
/opt/homebrew/bin/python3, that means you're using Homebrew's Python/usr/local/bin/python3 or /Library/Frameworks/Python.framework/Versions/3.x/bin/python3requests package, run in the terminal: pip3 show requestsLocation: line. If it says something like /opt/homebrew/lib/python3.10/site-packages, then the package was installed into Homebrew's Python and may not be accessible from your current interpreterPACKAGE_NAME with the package you want to remove (for example, requests, websocket-client, or Pillow)pip3 is located by running: which pip3/opt/homebrew/..., you can directly run in the terminal something like:
/Library/Frameworks/Python.framework/Versions/3.10/bin/pip3 install --user PACKAGE_NAMELocation: line now shows something like /Users/yourname/Library/Python/3.10/lib/python/site-packagesOnce your packages are installed in the correct location, they should be properly recognized by your Python installation.
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:
(venv))venv rather than .venv?Python-SDK in the correct location?