Perception, Planning and Control for Mobile Robots

ECE417 2022 Lab 9, Detect chessboard hints

Summary of steps

Creating a new ROS package for final project

We learned about creating a ROS package in turtlesim tutorials. Create a new ROS package for the final project. Name it appropriately, so that it reflects the topic of your project.

OpenCV

OpenCV stands for open source computer vision library. We have used OpenCV to implement loading images and converting them from ROS messages to Eigen matrices. If you look back at the template code of Birds Eye View Lab and Homography lab, you can find code using OpenCV.

OpenCV and CMake

You will need to find the package OpenCV using

find_package(OpenCV 4.2 REQUIRED)

And then include_directories and target_link_libraries with the target

include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(some_target_name_here 
other_libraries_names_here like ${catkin_LIBRARIES}, Eigen3::Eigen
${OpenCV_LIBRARIES}
)

Reading, Displaying and Writing an Image

  1. Read an image from file (using cv::imread)
  2. Display an image in an OpenCV window (using cv::imshow)
  3. Write an image to a file (using cv::imwrite)

For details please follow the tutorial here

Find Chessboard Corners

  1. Read an image from file (using cv::imread)
  2. Find chessboard corners using cv::findChessboardCornersSB

You might find this tutorial helpful: https://docs.opencv.org/4.x/d9/dab/tutorial_homography.html

Template code for the project

  1. The template code (a catkin workspace) for the project is here. All the files linked below are in that folder.

  2. You have to run the cv_camera_node (or usb_cam_node) to publish the image topics at /cv_camera/image_raw

    rosrun cv_camera  cv_camera_node   _image_width:=800 _image_height:=600 _frame_id:=camera __name:=cv_camera
    
  3. While the above node is running, you can catkin_make the provided ROS node try fixing the math in this file

    cd "path where you downloaded the above files"/catkin_ws
    catkin_make
    source devel/setup.bash
    rosrun camera_calibration_3d camera_calibration
    

    The camera_calibration node will cycle through “sliding windows” in the image to find the chessboard. You might have to tweak some parameters to make it work on your image. I tested it on this image

  4. If you like launch files, here is a launch file to run multiple nodes.