15-494/694 Cognitive Robotics: Lab 6I. Software Update and Initial SetupAt the beginning of every lab you should update your copy of vex-aim-tools. To do this:$ cd vex-aim-tools $ git pull II. Path PlanningThe vex-aim-tools package now offers simple wavefront and RRT path planners that allow you to send the robot to an object or a point in space while avoiding obstacles.
III. Path Planning In A Complex Space
IV. Path Planning Failure
V. RRT Path Planning
VI. HomeworkThe robot's built-in barrel detection code is overly sensitive to lighting conditions. It also has some bounding box accuracy issues at larger distances because it's actually running on a half-resolution image (320 x 240). Can we do better? Write code to detect barrels in a camera image and return a set of detections and bounding boxes of form ("OrangeBarrel", topleft-x, topleft-y, width, height). To avoid spurious barrel detections you'll want to see either two orange regions sandwiching a blue region, or vice versa. But you'll have to relax this requirement if the barrel is very close to the robot, where you can only see the top. Also, one barrel can partially occlude another, as in the image below, so you'll need to allow for that.![]() In the OpenCV lecture you saw some crude code for color image segmentation. You can start with that. Don't use connected components labeling because it's brittle: if two barrels overlap in the camera image it will merge them into one. Instead, since barrels are roughly rectangular, a template matching approach should work well. Strategy: Since most of you are new to OpenCV, rather than writing all the code from scratch, you are encouraged to use an LLM to help you. See this conversation with ChatGPT-5.2 for inspiration. But you are not required to follow the watershed approach recommended in that conversation; you are free to use any approach you like. It's a good idea to use matplotlib when developing your code, because its imshow method provides an easy way to display things like watershed computations by automatically scaling images and applying a color map. See the watershed.py demo (requires water_coins.jpg) for sample code. But you can't use matplotlib with simple_cli, so grab some screenshots using the camera viewer and then use those files as input to your Python program. To save the current camera image, type "s" in the camera viewer. Your code also needs to work for barrels that are so close to the camera that only the upper portion of the barrel is visible, as in the example below. This will require a different strategy since you won't see the usual O-B-O or B-O-B banding pattern. Note that this situation only occurs when the top of the barrel is in the bottom half of the image. ![]() Once your code is working as desired, you can move it to a state machine program. Test your barrel detector under varying lighting conditions and include screenshots showing the current camera image with the detected bounding boxes drawn on top of it. You can use cv2.rectangle() to draw bounding boxes on top of an image, and use the vex-aim-tools imshow() function to display the result in your own window instead of the regular camera viewer window. Your screenshots should show both your window and the camera viewer window so we can compare the accuracy of the bounding boxes. What to Hand InHand in a zip file containing the following:
|