Skip to content

mit212/ur_2024

Repository files navigation

Sample Code for UR5 Robot

2.12/2.120 Intro to Robotics
Spring 20241

1 Installation

Please refer to the Lab 4 Handout for instructions on how to install the UR Real-Time Data Exchange (RTDE) package.

2 Getting Started

Clone this repository and run test_import.py. It should print Yay! Your import was successful!. If not, try the following steps.

2.1 Windows

Opening the file in VSCode and clicking "Run" will probably result in a ModuleNotFoundError. Since you installed ur_rtde via WSL, you also need to run your code via WSL. There are two ways to do this.

Option 1: VS Code (Recommended)

  1. Open VSCode and install the "WSL" extension by Microsoft.
  2. Type "> WSL" in the search bar at the top of the screen. Select "WSL: Open Folder in WSL..." from the dropdown that appears.
  3. Navigate to this repository and click "Select Folder". In the pop-up window asking whether you trust the authors of the files in the folder, click "Yes, I trust the authors".
  4. Open test_import.py. VSCode may ask if you want to install the "Python" extension by Microsoft. Click "Install".
  5. Click the play icon at the top-right corner of the screen to run test_import.py. VSCode may ask you to choose an interpreter first. Select the option from the dropdown that says "Recommended" on the right side. You should see the success print!

Note: Only this folder has been opened in WSL, and only in this window. In the future, if you want to open another folder without WSL, you can open it as usual by clicking "File" then "Open Folder...". Similarly, if you want to open another folder with WSL, you can open it by repeating these steps.

Option 2: WSL Terminal

  1. Open a WSL terminal by entering wsl in Command Prompt. Your terminal should say something like LAPTOP_NAME: mnt/c/Users/yourname$. This is the current directory.

  2. Since the file you want to run is likely in another folder, we will change the current directory to be that folder. Open File Explorer and navigate to that folder.

  3. Right-click the address bar at the top of the screen and select "Copy Address" from the dropdown that appears.

    Where is the address bar?

    It is located to the left of the search bar. It should say something like "Documents > MIT > ur_2024".

  4. Go back to the WSL terminal and type cd ". Right-click to paste the address you copied and type " at the end. Don't hit enter yet!

  5. Replace all the \ with / and replace C: with /mnt/c. Your command should now look like

    cd "/mnt/c/Users/yourname/Documents/MIT/ur_2024"
    
  6. Hit enter. Your terminal should show a new current directory.

    Directory not found error?

    Make sure you included the / before mnt. Also, if your original current directory had a different disk letter, make sure to use that instead of c, e.g. /mnt/e.

  7. Enter python3 test_import.py. You should see the success print!

Note: In these steps, we navigated to our desired directory by entering its exact address. In the future, you may prefer to navigate incrementally via the terminal using the basic commands below.

  • ls: returns the contents of your current directory
  • cd example: goes to example subfolder within the current directory
  • cd ..: goes to the folder that contains your current directory, think of this as going up by a level

Footnotes

  1. Version 1 - 2023: Ravi Tejwani, Erik Ballesteros, Chengyuan Ma, Kamal Youcef-Toumi
    Version 2 - 2024: Jinger Chong

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages