The goals of assignment 02 are to build your robot and to establish computer control over it, including sending commands and receiving sensor measurements. The subgoals of assignment 02 include:
Calculate wheel rotation as a function of encoder measurements.
Calculate wheel distance travelled as a function of wheel rotation.
Calculate the change in robot position and orientation as a function of wheel distance travelled.
Predict a robot's global position using encoder measurements.
The key deliverables for Assignment 02 are to be submitted on Brightspace, one submission per team, from either team member:
Assignment 02 Video 1: illustrating a real robot driving a square pattern
Assignment 02 Video 2: illustrating a robot on the GUI driving a square pattern. This video should correspond with Video 1.
3. Assignment 02 Square Plot: Illustrating the robot's predicted position and orientation for the path followed in the video. The plot should be a top-down view of the path, plotted as small circles (e.g., with the 'o' setting when plotting with matplotlib). Indicate robot orientation on the plot with a short line that extends from the small circles, pointed in the direction the robot is driving.
4. Motion Characterization Plots: Drive the same command many times and plot where the robot ends up each time. This shows how repeatable your robot's motion is.
Use the Raw Timed Move panel so every run gets exactly the same PWM values and duration. Choose a duration that drives the robot about 1.5–2 m.
Do three sets of 10 runs (30 runs total). Within a set, keep PWM A, PWM B, and the duration identical for every run.
Straight
Left curve
Right curve
Start every run the same way. Place the robot at the same spot and heading, then press RESET ODOMETRY so each run starts at (0, 0) facing +x.
Record each run as its own CSV. Press START RECORDING before GO, and stop recording once the robot has come to rest.
Make three plots, one per set. Each plot shows all 10 runs from that set, drawn from the odom_x_m and odom_y_m columns of the CSVs.
Top-down view, with the same scale on both axes.
Mark each run's final position.
Label the plot with the duration/distance you used.
For this section of the assignment, you will calculate wheel rotations as a function of encoder measurements. Then you will add code to the functions get_wheel_rotation_left(encoder_rotation_left) and get_wheel_rotation_right(encoder_rotation_right) to the code base in file GUI_lab2.py.
To start, beach the robot. Then mark a spot on the tire of each wheel with chalk or a piece of tape. At the top of the GUI, you find the wheel encoder measurement (in encoder counts) for each wheel and write it down. Use your phone camera to record the wheel spinning. Use the GUI to run the motors at some nominal speed, for 10 to 20 revolutions. Once done, play back the video and observe the number of radians of rotation the mark on the tire spun around. Use this value, along with the change in encoder counts, to determine the linear mapping function from encoder counts to wheel rotation in radians. Do this for both wheels.
For this section, you will calculate wheel distance travelled as a function of wheel rotations. Use a ruler, calipers, or some experiment to measure the effective radius R of the left and right tires. Then, use the knowledge that one wheel rotation is equivalent to traveling a distance of 2πR along the ground.
Write functions in the code base file GUI_lab2.py called get_wheel_distance_left(wheel_rotation_left) and get_wheel_distance_right(wheel_rotation_right).
For this section, you will calculate the change in robot position and orientation as a function of wheel distance travelled. To the file GUI_lab2.py, you will add the functions get_wheel_distance_left(wheel_rotation_left) and get_state_change(wheel_distance_right, wheel_distance_left) that returns a list with the change in x, y, and theta.
You must write code that leverages the equations from lecture to derive the change in position and orientation. ([x,y,θ])
For this section, you will add code to the existing function predict_robot_state(last_state, encoder_rotation_right, encoder_rotation_left) that returns a list with the x, y, theta value of the robot's state. Currently this function returns [0, 0, 0]. The GUI currently updates the state of the robot on the plot using this function.
When adding code to predict_robot_state, use the functions you wrote for sections 1,2, and 3.
Experiment 1: Use the GUI do drive the robot in a 1meter x 1meter square pattern. Take videos for the deliverables. Also, log the x, y, theta data for the plot deliverable described above. There should be a button in the GUI to do this consistently.
Experiment 2: In Raw Timed Move, choose a duration that drives the robot 1.5–2 m and 2 robot rotation values. Keep these values identical across every run in a set. For each run, place the robot at the same starting mark and heading, press RESET ODOMETRY, press START RECORDING, press GO, and stop recording once the robot comes to rest, so each run gets its own CSV. Do 10 runs per set, 30 in total, and label the files by set as you go. Then make three plots, one per set, overlaying all 10 trajectories with each final position marked and the rotation values and duration in the title.