Please find a partner to work with for this exercise. While both you and your partner are expected to write you own code and make your own individual submission, this exercise is designed to work through together. You and your partner will help each other understand the starter code and the concepts behind the line follower, and you will be able to discuss and troubleshoot together. Also, you'll need to likely share some Turtlebots.
To get started on this exercise, clone the lab_b_line_follower git repository ROS2 package - the starter code that we'll be using for this lab.
$ cd ~/intro_robo_ws/src
$ git clone https://github.com/Intro-Robotics-UChicago-Fall-2025/lab_b_line_follower.git
$ cd ~/intro_robo_ws
$ colcon build --symlink-install --packages-select lab_b_line_follower
$ source install/setup.bash
Connect with a Turtlebot4, remembering to run:
$ set_robot_num [robot-number]
Then, to run the code, you can run:
$ ros2 run lab_b_line_follower line-follower
The starter code implements a helpful debugging window to help visualize the center of the computed orange pixels. Once you've correctly identified the center of the orange pixels, your window should look something like the following:
Read through the starter code in line_follower.py with your partner. Discuss it together so that both of you understand what's going on. We encourage you to look up what certain OpenCV functions do to better understand what's going on. Make sure that you all discuss and understand what the following variables represent and what values they will hold: h, w, d,
cx, cy.
This programming exercise contains 2 main components:
H: 0-179, S: 0-255, V: 0-255. This means
that any colors defined using the standard HSV ranges (H: 0-360, S: 0.0-1.0, V: 0.0-1.0) will
need to have their components normalized accordingly.
To run your code:
$ ros2 run lab_b_line_follower line-follower
Once you've successfully implemented your proportional control line follower, it should look something like the following:
If you and your partner(s) finish early, feel free to use this time to work independently on your Warmup Project assignment.
For your Lab B Deliverables, submit the following via Canvas/Gradescope by 2:00pm on Thursday, October 9th:
The line-following exercise and code was taken and modified from Gaitech EDU.