2.12/2.120 Intro to Robotics
Spring 20241
Estimated time of completion: 15 min
Before coming in to lab, please download and install the following software.
-
Download Python here: https://www.python.org/downloads/.
What version of Python do I need?
We recommend at least 3.8 to ensure compatibility with the packages we will use in this class. If you already have Python, you should be able to check its version by entering the command
python --version
in your terminal.Can I get Python via conda?
We recommend getting vanilla Python. The staff may not be able to help troubleshoot issues relating to
conda
. -
Make sure to check "Add python.exe to PATH".
-
Click "Install Now" and finish the installation.
-
Check that you installed Python correctly by entering the command
python
in your terminal. It should returnPython X.X (tags...
.It's returning something else?
If it instead returns
python is not recognized as an internal or external command, operable program, or batch file
orpython: command not found
, you may have forgotten to add Python to PATH during installation. You can fix this using the following instructions: How to Add Python to PATH.
For Windows:
-
Open PowerShell in administrator mode by right-clicking and selecting "Run as administrator".
-
Enter
wsl --install
. This installs Windows Subsystem for Linux (WSL) with Ubuntu as the default distribution.Not working?
Please refer to this tutorial: How to install Linux on Windows with WSL.
-
Restart your machine.
-
Open Powershell and enter
wsl
to open a WSL terminal window. You might be asked to create a username and password. This can be whatever you want as long as you remember it. -
Enter the following sequentially:
sudo apt update sudo apt upgrade sudo apt install python3-pip pip3 install ur_rtde
Tip: You can paste text from your clipboard by right-clicking in Powershell.
For Linux:
- Open Terminal.
- Follow step 5 under "For Windows".
For MacOS:
-
Open Terminal.
-
Enter
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
to install Homebrew, a package manager similar to Linuxapt
. -
Enter
echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
to add Homebrew to PATH. -
Enter the following sequentially:
brew update brew upgrade brew install boost brew install cmake git clone https://gitlab.com/sdurobotics/ur_rtde.git cd ur_rtde git submodule update --init --recursive mkdir build cd build cmake .. make sudo make install
Not working?
We are still debugging why this doesn't work especially for Apple chip Macs. Feel free to send the staff an email with the error you are getting.
Additional references:
In lab, we will perform a supervised run-through of controlling the UR5.
Estimated time of completion: 20 min
Clone this repository. Open matlab/MotorModel.mlx
in MATLAB and follow along the guided tutorial to find the nominal controller gains for the motors.
Estimated time of completion: 10 min
Like in the previous labs, we first want to make sure the parts work individually! Faulty wiring or hardware can be very difficult to debug in complex systems.
Make sure that motor power is turned off any time you are uploading code to your microcontroller. The arm has a tendency to spin around and hit itself if motor power is on during upload. As a reminder, motor power should only be on when you expect the motors to move. Otherwise, please keep motor power off.
How to know if the motor power is on?
The yellow LED on the motor driver indicates whether motor power is on or off.
Clone this repository and run robot/blink_test.cpp
. You should see the onboard LED change colors!
Forget how to clone?
Please refer to the instructions from Lab 1.
Orient the arm straight up, in default starting position. Run test_code/motor_drive_test.cpp
to validate your motor setup. You should see both motors oscillating back and forth. Remember, motor 1 is attached to the base and motor 2 is attached to the second link.
Run test_code/encoder_test.cpp
to validate your encoder setup. Open the Serial Monitor to see the output and confirm that both the direction and the magnitude make sense!
Run test_code/joystick_test.cpp
to validate your joystick setup. You should be able to see joystick readings within the range [-1, 1]
.
Estimated time of completion: 20 min
We will be using lab_code/sinusoidal_input.cpp
to tune our controllers. We will tune the two motors separately.
- Uncomment
#define MOTOR1
and comment out#define MOTOR2
. - Update the parameters under the
#ifdef MOTOR1
section to be the nominal parameters computed from MATLAB. - Run
lab_code/sinusoidal_input.cpp
. - Open
matlab/TuningPlot.m
in MATLAB. Update the COM port. - Run
matlab/TuningPlot.m
in MATLAB to visualize the performance of your controller. - Tune your controller by incrementally changing
Ti1
,Td1
,Kp1
, andalpha1
and seeing how that affects performance. Ideally, we want minimal overshoot, oscillations, and steady state error. - Once you are satisfied with the performance, repeat the process for
MOTOR2
.
Estimated time of completion: 10 min
We will now use your tuned controllers to improve the drawing from last lab!
- Open
lab_code/drawing.cpp
and update the parameters. - Set
trajectoryType = HORIZONTAL_LINE
. - Run
lab_code/drawing.cpp
and observe whether the arm performs better than last lab. - Open
matlab/TrajectoryPlot.m
in MATLAB. Update the COM port. - Run
matlab/TrajectoryPlot.m
to visualize the target and actual trajectories. - Set
trajectoryType = JOYSTICK
and runlab_code/drawing.cpp
again. - Draw something awesome using your joystick!
✅ CHECKOFF 1 ✅ |
---|
Show your work of art to a TA or LA so we can pin it up on the board! |
Before you leave, please fill out https://tinyurl.com/212-feedback.
✅ CHECKOFF 2 ✅ |
---|
Show the feedback form completion screen to a TA or LA. |
Here are some optional challenges you can try if you finish lab early!
- Run
lab_code/drawing.cpp
withtrajectoryType = VERTICAL_LINE
. - Run
lab_code/drawing.cpp
withtrajectoryType = CIRCLE
. - Connect the joystick to a separate microcontroller and make it wireless.
- Try using another type of input besides the joystick. For example, you can use potentiometers or an IMU!
Footnotes
-
Version 1 - 2020: Dr. Harrison Chin
Version 2 - 2021: Phillip Daniel
Version 3 - 2023: Ravi Tejwani and Kentaro Barhydt
Version 4 - 2024: Joseph Ntaimo, Jinger Chong, Josh Sohn ↩