{"id":378,"date":"2017-11-30T05:43:53","date_gmt":"2017-11-30T05:43:53","guid":{"rendered":"https:\/\/peterklemperer.com\/blog\/?p=378"},"modified":"2017-11-30T15:14:00","modified_gmt":"2017-11-30T15:14:00","slug":"three-dimensional-aruco-boards","status":"publish","type":"post","link":"https:\/\/peterklemperer.com\/blog\/2017\/11\/30\/three-dimensional-aruco-boards\/","title":{"rendered":"Three-Dimensional Aruco Boards"},"content":{"rendered":"<p>I am using Aruco tags to locate mobile robots relative to one another. I have mounted tags on the robots using cubes so that at least one tag will be visible from every side of the robot.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"379\" data-permalink=\"https:\/\/peterklemperer.com\/blog\/2017\/11\/30\/three-dimensional-aruco-boards\/cube-board\/\" data-orig-file=\"https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2017\/11\/Cube-Board.png\" data-orig-size=\"2560,1484\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Cube-Board\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2017\/11\/Cube-Board-300x174.png\" data-large-file=\"https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2017\/11\/Cube-Board-1024x594.png\" class=\"aligncenter size-medium wp-image-379\" src=\"https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2017\/11\/Cube-Board-300x174.png\" alt=\"\" width=\"300\" height=\"174\" srcset=\"https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2017\/11\/Cube-Board-300x174.png 300w, https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2017\/11\/Cube-Board-768x445.png 768w, https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2017\/11\/Cube-Board-1024x594.png 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>In the picture above, the origin is indicated by the red, green, and blue lines overplayed over the video frame.<\/p>\n<p><!--more--><\/p>\n<p>In the past, I had been locating each of the tags individually, but the Aruco library offers a higher precision alternative: Aruco tag boards. Aruco tag boards consist of multiple Aruco tags. The position of the tags is defined in three dimensions <em>a-priori<\/em>, so when multiple tags appear in a frame, a better estimate of the tag boards location can be calculated than using just one single Aruco tag alone.<\/p>\n<p>This post presents information on how I:<\/p>\n<ul>\n<li>learned to define Aruco Boards,<\/li>\n<li>defined the Aruco Board pictured above,<\/li>\n<li>obtained Aruco Board Pose estimates.<\/li>\n<\/ul>\n<h3><strong>Learning to Define Aruco Boards<\/strong><\/h3>\n<p>Aruco boards require three parameter: objPoints, dictionary, and ids. To learn how these variables are formatted, I used the GridBoard_create method to generate an example.\u00a0Following is the contents of those variables for:<\/p>\n<pre>board = aruco.GridBoard_create(2,2,5,5,\r\n              aruco.getPredefinedDictionary(aruco.DICT_6X6_250))\r\n\r\nboard.objPoints =\u00a0\r\n[array([[ 0., 15., 0.],\r\n [ 5., 15., 0.],\r\n [ 5., 10., 0.],\r\n [ 0., 10., 0.]], dtype=float32), \r\narray([[ 10., 15., 0.],\r\n [ 15., 15., 0.],\r\n [ 15., 10., 0.],\r\n [ 10., 10., 0.]], dtype=float32), \r\narray([[ 0., 5., 0.],\r\n [ 5., 5., 0.],\r\n [ 5., 0., 0.],\r\n [ 0., 0., 0.]], dtype=float32), \r\narray([[ 10., 5., 0.],\r\n [ 15., 5., 0.],\r\n [ 15., 0., 0.],\r\n [ 10., 0., 0.]], dtype=float32)]\r\n\r\nboard.ids =\r\narray([[0],\r\n [1],\r\n [2],\r\n [3]], dtype=int32)<\/pre>\n<h3><strong>Defining My Cubic Aruco Board<\/strong><\/h3>\n<p>For my 3-D board:<\/p>\n<pre>board_corners = [np.array([[0.09,0.01,0.0],[0.09,0.09,0.],[0.01,0.09,0.],[0.01,0.01,0.]],dtype=np.float32),\r\n np.array([[0.09,0.10,0.01],[0.09,0.10,0.09],[0.01,0.10,0.09],[0.01,0.10,0.01]],dtype=np.float32),\r\n np.array([[0.09,0.0,0.09],[0.09,0.0,0.01],[0.01,0.0,0.01],[0.01,0.0,0.09]],dtype=np.float32),\r\n np.array([[0.09,0.09,0.10],[0.09,0.01,0.10],[0.01,0.01,0.10],[0.01,0.09,0.10]],dtype=np.float32)]\r\nboard_ids = np.array( [[0],[10],[14],[12]], dtype=np.int32)\r\nboard = aruco.Board_create( board_corners,\r\n aruco.getPredefinedDictionary(aruco.DICT_6X6_250),\r\n board_ids )<\/pre>\n<p>In this case, the model was defined by hand. For more complicated three-dimensional shapes, I will use CAD tools to calculate the tag corners.<\/p>\n<h2>Displaying an Aruco Board Pose<\/h2>\n<p>After defining the board, I was able to estimate the pose of the board as follow:<\/p>\n<pre>corners, ids, rejectedImgPoints = aruco.detectMarkers(gray, aruco_dict)\r\nretval,rvec,tvec = aruco.estimatePoseBoard( corners, ids, board, camera_matrix, dist_coeffs )\r\nframe = aruco.drawAxis( frame, camera_matrix, dist_coeffs, rvec, tvec, aruco_marker_length_meters )\r\nframe = aruco.drawDetectedMarkers( frame, corners, ids )<\/pre>\n<p>As shown in the picture above, the individual markers are outlined and labeled with their respective id numbers. The axis are drawn on from the origin, with x-axis red, y-axis green, and z-axis blue.<\/p>\n<p>Resources:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/ftPeter\/pose-estimation\">My GitHub repository for pose-estimation<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I am using Aruco tags to locate mobile robots relative to one another. I have mounted tags on the robots using cubes so that at least one tag will be visible from every side of the robot. In the picture &hellip; <a href=\"https:\/\/peterklemperer.com\/blog\/2017\/11\/30\/three-dimensional-aruco-boards\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[65,67,80,10,1],"tags":[],"class_list":["post-378","post","type-post","status-publish","format-standard","hentry","category-mobot","category-programming","category-robotics","category-toys","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1VqWo-66","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/posts\/378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/comments?post=378"}],"version-history":[{"count":0,"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/posts\/378\/revisions"}],"wp:attachment":[{"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/media?parent=378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/categories?post=378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/tags?post=378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}