Software Installation for Cognitive Robotics

Install instructions for:

Ubuntu Linux

Python installation

Ubuntu comes with python3 by default, this can be verified by running this command in the terminal: python3

If Python is not installed then run these commands:

sudo apt update
sudo apt install python3

Git installation

Ubuntu comes with git installed by default, this can be verified by running this command in the terminal:
git --version
If git is not installed, then run these commands:
sudo apt update
sudo apt install git

Setting up the environment

  1. Make a directory to hold your Cognitive Robotics work, e.g., ~/CogRob

  2. cd into the directory you made.

  3. Clone the vex-aim-tools repository by running this command:
    git clone https://github.com/touretzkyds/vex-aim-tools
    
  4. Create a Python virtual environment by running this command:
    python3 -m venv env
    
  5. Activate the virtual environment by running this command:
    source ./env/bin/activate
    
  6. Install the required packages by running this command:
    pip install -r vex-aim-tools/requirements-linux.txt
    
  7. Place the cogrob-google-cloud.json file you received in email into your CogRob directory. Warning: keep this credential file confidential. Do not place the file in a publicly-accessible directory, in a git repository, or anywhere that other people could get to it.

  8. Setting up the environment variables. Edit your ~/.bashrc file and add the following lines to the end (adjust as necessary based on where you put your CogRob directory). For the ROBOT variable, use the number of the robot that was assigned to you.
    export GOOGLE_APPLICATION_CREDENTIALS=~/CogRob/cogrob-google-cloud.json
    export OPENAI_API_KEY=(the API key you received in email)
    export PATH=$PATH:~/CogRob/vex-aim-tools
    export ROBOT=AIM-xxxxxxx.wifi.local.cmu.edu
    
  9. To test the installation, run these commands:
    source ~/.bashrc
    cd ~/CogRob    
    simple_cli
    
    If the installation was successful, you should see simple_cli trying to connect to your robot's IP.

Using the environment

When you come back later and want to work with the robot again, use these commands:
cd ~/CogRob
source ./env/bin/activate
simple_cli

MacOS

Older Macs may be able to run simple_cli, but since Apple dropped support for OpenGL some time ago, PyOpenGL does not work on new Apple Silicon. If you have an Intel Mac, try these steps:

First, install Python. Some people use brew or anaconda for this.

For the remaining steps, follow the instructions for Ubuntu, except:

  • Start by doing "brew install freeglut"
  • Edit ~/.zshrc instead of ~/.bashrc
  • Use requirements-macos.txt instead of requirements-linux.txt

Windows

Python installation

You can use any version of Python from 3.8 up. If you don't already have Python installed on your machine, then follow these steps:
  1. Download a Python installer from the official website: https://www.python.org/downloads/windows/

  2. Run the installer and follow the instructions. Make sure to check the box that says "Add Python to PATH".

  3. Verify the installation by opening Command Prompt and running this command:
    python --version
    

Git installation

  1. Download the Git installer from the official website: https://git-scm.com/download/win

  2. Run the installer and follow the instructions. Make sure to check the box that says "Git Bash Here".

  3. Verify the installation by opening Command Prompt and running this command:
    git --version
    

Setting up the environment

  1. Make a folder to hold your Cognitive Robotics work, e.g., C:\Users\myuserid\CogRob

  2. cd into the CogRob folder you made.

  3. Clone the vex-aim-tools repository by running this command:
    git clone https://github.com/touretzkyds/vex-aim-tools
    
  4. Create a Python virtual environment by running this command:
    python -m venv env
    
  5. Activate the virtual environment by running this command:
    .\env\Scripts\activate
    
  6. Install the required packages by running this command:
    pip install -r vex-aim-tools\requirements-windows.txt
    
  7. Place the cogrob-google-cloud.json file you received in email into your CogRob directory. Warning: keep this credential file confidential. Do not place the file in a publicly-accessible directory, in a git repository, or anywhere that other people could get to it.

Setting up environment variables

  1. Search for "Environment Variables" in the Windows search bar and click on "Edit the system environment variables".

  2. Click on the "Environment Variables" button.

  3. Under "System variables", click on "New" and add the following variables:
    Variable name: GOOGLE_APPLICATION_CREDENTIALS
    Variable value: C:\Users\myuserid\CogRob\cogrob-google-cloud.json
    
    Variable name: OPENAI_API_KEY
    Variable value: (the API key you received in email, beginning with "sk")
    
    Variable name: ROBOT
    Variable value: AIM-xxxxxxxx.wifi.local.cmu.edu
    
  4. Select the PATH variable and edit it to add the path to the simple_cli script:
    Variable name: PATH
    Value to add: C:\Users\myuserid\CogRob\vex-aim-tools
    
  5. Click "OK" to save your changes to the environment variables.

  6. To verify the installation, type "python simple_cli". If the installation was successful, you should see simple_cli trying to connect to your robot's IP.

Using the environment

When you come back later and want to work with the robot again, open Command Prompt and use these commands:
cd C:\Users\myuserid\CogRob
.\env\Scripts\activate
python simple_cli

Virtual Andrew

Virtual Andrew uses Windows, but you can access it from a Mac via your browser, or by installing the VMware Horizon Client. In either case, connect to Virtual Andrew by opening
https://virtual.andrew.cmu.edu in Chrome. (The page will give you a link from which you can download the VMware Horizon Client if you wish.) If you're not using the client, then click on "Launch Via Browser", then click on "CMU vLab".
  1. Make a folder called CogRob on your desktop to hold your Cognitive Robotics work.

  2. Open Google Chrome within Virtual Andrew. (Yes, you're running a browser within a browser.)

  3. Download the file vex-aim-tools.zip from the course web site.

  4. Open Windows File Explorer, and move the file from your Downloads folder to your Desktop\CogRob folder.

  5. Navigate to your CogRob folder, right click on vex-aim-tools.zip, and choose "Extract all", then click the Extract button.

  6. Go to your desktop, right click on the CogRob folder, and select "Open in Terminal". This opens a Powershell terminal window.

  7. Type "dir" in the terminal window. You should see your vex-aim-tools folder. Make note of your current directory path as shown by dir.

  8. If you don't already have one, create a Powershell Profile by typing the following command in the terminal:
            New-Item -ItemType File -Path $PROFILE -Force
        
  9. Edit your profile by typing: notepad $PROFILE

  10. Insert the following lines into your profile, changing the path to match yours:
    	function prompt { $(Split-Path -Path $pwd -Leaf) + "> " }
            function simple_cli { param ($file) python \\andrew.ad.cmu.edu\users\users14\dst\Desktop\CogRob\vex-aim-tools\simple_cli $file }
            function genfsm { param ($file) python \\andrew.ad.cmu.edu\users\users14\dst\Desktop\CogRob\vex-aim-tools\genfsm $file }
            $env:PYTHONPATH = "\\andrew.ad.cmu.edu\users\users14\dst\Desktop\CogRob\vex-aim-tools"
    	$env:ROBOT = "AIM-xxxxxxxx.wifi.local.cmu.edu"
    	$env:OPENAI_API_KEY = "the API key you received in email, beginning with sk"
    	$env:GOOGLE_APPLICATION_CREDENTIALS = "\\andrew.ad.cmu.edu\users\users14\dst\Desktop\CogRob\cogrob-google-cloud.json"
        
  11. Activate your profile by typing "powershell $PROFILE".

  12. Create a Python virtual environment by typing the following command:
    	python -m venv env1
        
  13. Activate the virtual environment by typing:
    	.\env1\Scripts\activate
        
  14. cd into your vex-aim-tools folder.

  15. Install required software modules by typing the following command:
    	pip install -r requirements-windows.txt
        
  16. Download the cogrob-google-cloud.json file you received in email and move it into your Desktop\CogRob folder.

  17. Type "notepad" in the terminal and enter the following lines:
    	.\env1\Scripts\activate
        
  18. Save the file as "setup.ps1" in your Desktop\CogRob folder.

Using Your Virtual Andrew Installation

To run simple_cli in a fresh Virtual Andrew session, do the following:
  1. Connect to Virtual Andrew.

  2. Right-click on the CogRob folder on your desktop and select "Open in Terminal".

  3. Make sure your robot number matches the number in your $PROFILE file.

  4. In the PowerShell window, type the following:
    	.\setup.ps1
        
  5. Now, whenever you want to run the robot do:
    	simple_cli
        
  6. The robot is slow to connect over Virtual Andrew, so simple_cli will likely fail with a "no image was received" message. Just run start_robot.ps1 several more times and eventually the system will catch up with the robot.

  7. Speech input from the browser also takes a few seconds to get started. Be patient. Also, it does not work with Safari; you must use Chrome to run Virtual Andrew if you want speech input to work.