You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
6.5 KiB

2 years ago
  1. ## ArUco Marker Detector
  2. For this tutorial, we will go over how to detect Stretch's ArUco markers and how to files the hold the information for each tag.
  3. ### Visualize ArUco Markers in RViz
  4. Begin by running the stretch driver launch file.
  5. ```bash
  6. # Terminal 1
  7. roslaunch stretch_core stretch_driver.launch
  8. ```
  9. To activate the RealSense camera and publish topics to be visualized, run the following launch file in a new terminal.
  10. ```bash
  11. # Terminal 2
  12. roslaunch stretch_core d435i_low_resolution.launch
  13. ```
  14. Next, run the stretch ArUco launch file which will bring up the [detect_aruco_markers](https://github.com/hello-robot/stretch_ros/blob/master/stretch_core/nodes/detect_aruco_markers) node.
  15. ```bash
  16. # Terminal 3
  17. roslaunch stretch_core stretch_aruco.launch
  18. ```
  19. Within this tutorial package, there is an [RViz config file](https://github.com/hello-robot/stretch_tutorials/blob/main/rviz/aruco_detector_example.rviz) with the topics for transform frames in the Display tree. You can visualize these topics and the robot model by running the command below in a new terminal.
  20. ```bash
  21. # Terminal 4
  22. rosrun rviz rviz -d /home/hello-robot/catkin_ws/src/stretch_tutorials/rviz/aruco_detector_example.rviz
  23. ```
  24. You are going to need to teleoperate Stretch's head to detect the ArUco marker tags. Run the following command in a new terminal and control the head in order to point the camera towards the markers.
  25. ```bash
  26. # Terminal 5
  27. rosrun stretch_core keyboard_teleop
  28. ```
  29. <p align="center">
  30. <img src="https://raw.githubusercontent.com/hello-robot/stretch_tutorials/main/images/aruco_detector.gif"/>
  31. </p>
  32. ### The ArUco Marker Dictionary
  33. When defining the ArUco markers on Stretch, hello robot utilizes a YAML file, [stretch_marker_dict.yaml](https://github.com/hello-robot/stretch_ros/blob/master/stretch_core/config/stretch_marker_dict.yaml), that holds the information about the markers.
  34. If [detect_aruco_markers](https://github.com/hello-robot/stretch_ros/blob/master/stretch_core/nodes/detect_aruco_markers) node doesn’t find an entry in [stretch_marker_dict.yaml](https://github.com/hello-robot/stretch_ros/blob/master/stretch_core/config/stretch_marker_dict.yaml) for a particular ArUco marker ID number, it uses the default entry. For example, most robots have shipped with the following default entry:
  35. ```yaml
  36. 'default':
  37. 'length_mm': 24
  38. 'use_rgb_only': False
  39. 'name': 'unknown'
  40. 'link': None
  41. ```
  42. and the following entry for the ArUco marker on the top of the wrist
  43. ```yaml
  44. '133':
  45. 'length_mm': 23.5
  46. 'use_rgb_only': False
  47. 'name': 'wrist_top'
  48. 'link': 'link_aruco_top_wrist'
  49. ```
  50. **Dictionary Breakdown**
  51. ```yaml
  52. '133':
  53. ```
  54. The dictionary key for each entry is the ArUco marker’s ID number or `default`. For example, the entry shown above for the ArUco marker on the top of the wrist assumes that the marker’s ID number is `133`.
  55. ```yaml
  56. 'length_mm': 23.5
  57. ```
  58. The `length_mm` value used by [detect_aruco_markers](https://github.com/hello-robot/stretch_ros/blob/master/stretch_core/nodes/detect_aruco_markers) is important for estimating the pose of an ArUco marker.
  59. **IMPORTANT NOTE:** If the actual width and height of the marker do not match this value, then pose estimation will be poor. Thus, carefully measure custom Aruco markers.
  60. ```yaml
  61. 'use_rgb_only': False
  62. ```
  63. If `use_rgb_only` is `True`, [detect_aruco_markers](https://github.com/hello-robot/stretch_ros/blob/master/stretch_core/nodes/detect_aruco_markers) will ignore depth images from the [Intel RealSense D435i depth camera](https://www.intelrealsense.com/depth-camera-d435i/) when estimating the pose of the marker and will instead only use RGB images from the D435i.
  64. ```yaml
  65. 'name': 'wrist_top'
  66. ```
  67. `name` is used for the text string of the ArUco marker’s [ROS Marker](http://docs.ros.org/en/melodic/api/visualization_msgs/html/msg/Marker.html) in the [ROS MarkerArray](http://docs.ros.org/en/melodic/api/visualization_msgs/html/msg/MarkerArray.html) Message published by the [detect_aruco_markers](https://github.com/hello-robot/stretch_ros/blob/master/stretch_core/nodes/detect_aruco_markers) ROS node.
  68. ```yaml
  69. 'link': 'link_aruco_top_wrist'
  70. ```
  71. `link` is currently used by [stretch_calibration](https://github.com/hello-robot/stretch_ros/blob/master/stretch_calibration/nodes/collect_head_calibration_data). It is the name of the link associated with a body-mounted ArUco marker in the [robot’s URDF](https://github.com/hello-robot/stretch_ros/blob/master/stretch_description/urdf/stretch_aruco.xacro).
  72. It’s good practice to add an entry to [stretch_marker_dict.yaml](https://github.com/hello-robot/stretch_ros/blob/master/stretch_core/config/stretch_marker_dict.yaml) for each ArUco marker you use.
  73. ### Create a New ArUco Marker
  74. At Hello Robot, we’ve used the following guide when generating new ArUco markers.
  75. We generate ArUco markers using a 6x6 bit grid (36 bits) with 250 unique codes. This corresponds with[ DICT_6X6_250 defined in OpenCV](https://docs.opencv.org/3.4/d9/d6a/group__aruco.html). We generate markers using this [online ArUco marker generator](https://chev.me/arucogen/) by setting the Dictionary entry to 6x6 and then setting the Marker ID and Marker size, mm as appropriate for the specific application. We strongly recommend to measure the actual marker by hand prior to adding an entry for it to [stretch_marker_dict.yaml](https://github.com/hello-robot/stretch_ros/blob/master/stretch_core/config/stretch_marker_dict.yaml).
  76. We select marker ID numbers using the following ranges.
  77. * 0 - 99 : reserved for users
  78. * 100 - 249 : reserved for official use by Hello Robot Inc.
  79. * 100 - 199 : reserved for robots with distinct sets of body-mounted markers
  80. * Allows different robots near each other to use distinct sets of body-mounted markers to avoid confusion. This could be valuable for various uses of body-mounted markers, including calibration, visual servoing, visual motion capture, and multi-robot tasks.
  81. * 5 markers per robot = 2 on the mobile base + 2 on the wrist + 1 on the shoulder
  82. * 20 distinct sets = 100 available ID numbers / 5 ID numbers per robot
  83. * 200 - 249 : reserved for official accessories
  84. * 245 for the prototype docking station
  85. * 246-249 for large floor markers
  86. When coming up with this guide, we expected the following:
  87. * Body-mounted accessories with the same ID numbers mounted to different robots could be disambiguated using the expected range of 3D locations of the ArUco markers on the calibrated body.
  88. * Accessories in the environment with the same ID numbers could be disambiguated using a map or nearby observable features of the environment.