QR code tracking

1 Ready to start

Before tracking the QR code, we need to make some preparations.

  1. Print the QR code, the QR code is placed in the /handsfree_ros_ws/src/handsfree/handsfree_ar_tags/config directory picture

    tips:Due to the algorithm here, if you open the QR code on your phone for recognition, it will be difficult for the camera to recognize it!

  2. Make sure the camera can work normally, according to rgbd_camera in Drive Test Test completes this step. (If the test has been completed before, please ignore this step)

Note: To close a terminal with a process running, use Ctrl+C in the window to interrupt the program, and then close the window.

2 Concise steps

You only need to open a terminal and enter the following commands respectively

ros launch hands free_ar_tags robot_follow_ar_marker.launch

Then shake the paper with the QR code in front of the camera (don’t shake it too fast!), and the robot will move accordingly.

3 Tracking QR code

When the robot successfully recognizes the two-dimensional code, we can start to try to make the robot track the two-dimensional code, and move the two-dimensional code to make the robot follow forward and backward, and move left and right. Open two terminals, enter the following two commands respectively, and the robot can recognize the QR code. For the detailed process, refer to QR code recognition

roslaunch handsfree_camera view_astra_dabai.launch
roslaunch hands free_ar_tags ar_indiv_rgb_camera.launch
  1. Close all previous terminals, open a new terminal, and enter the following command

      ros launch hands free_ar_tags robot_follow_ar_marker.launch
    

    Normally, rviz will display camera data and model data handsfree_hw

    The terminal will display, below the red line is the information printed out by the robot after recognizing the QR code ar_follower

  2. Put the QR code in front of the camera and start testing to see if the robot can track the QR code to move.

    If the distance between the camera and the QR code is within the approximate range of (70 ~ 80) cm (manual measurement will cause errors, please forgive me!), the robot will not move forward or backward, but can turn; if the distance is less than this range, the robot will It will move backwards and keep the distance; if the distance is greater than this range, the robot will move forward following the QR code and keep the distance.

    But be careful not to move the QR code too fast, otherwise the robot will not be able to keep up. In addition, the robot will not automatically avoid obstacles in this mode, so protect your robot from damage!

  3. Summary

    Tracking the QR code is carried out on the basis of recognizing the QR code, so it is necessary to operate on the basis of recognizing the QR code. You need to run a command in the terminal to open a node.

    • It is necessary to start the robot tracking node with one key, make sure the robot tracks the QR code recognized by the camera, and then move.

      In the chapter on identifying QR codes, we can see the position and posture of the QR code in digital representation through the rostopic echo command. Of course, the robot also has its own position and posture. The role of the tracking node is to process the position and posture of the QR code, so that the robot and the QR code remain in a relative state.

  4. Expand

    At this point, we have completed the identification and tracking of the QR code. Let's talk about how to generate a QR code that the robot can recognize. If you are interested, you can find out.

    We can complete the creation of the QR code through the ar_track_alvar function package, which is already in the local.

    Open the terminal and enter the following command

      rosrun ar_track_alvar createMarker
    

    ar-track-alvar

    From the pictures, we can see that this function package is still very powerful, it can generate codes of any number between 0 and 65535, it can generate strings, it can generate URLs, etc.

    Let's demonstrate the generation of numbers, strings and URLs separately, open the terminal, and enter the following three lines of commands respectively

      rosrun ar_track_alvar createMarker 4
      rosrun ar_track_alvar createMarker -1 "handsfree"
      rosrun ar_track_alvar createMarker -3 www.taobotics.com
    

    creatMarker

    The generated picture can be seen in Home home-picture

results matching ""

    No results matching ""