{"id":3139,"date":"2019-09-12T11:11:49","date_gmt":"2019-09-12T10:11:49","guid":{"rendered":"http:\/\/dronesonen.hibu.no\/?p=3139"},"modified":"2019-09-12T11:11:49","modified_gmt":"2019-09-12T10:11:49","slug":"group-02-project-report-week-3-5-09-2019","status":"publish","type":"post","link":"https:\/\/dronesonen.usn.no\/?p=3139","title":{"rendered":"Group 02 &#8211; Project Report &#8211; Week 3 (5.09.2019)"},"content":{"rendered":"\n<p>For this Thursday, we had our usual meeting, where each of us recounted to one another what we had accomplished since last time, what issues we encountered, and what we planned to do next. Using Trello, we browsed through the first sprint, discussing the various tasks and their status, making sure we had some idea where we were with each one. Once we were satisfied, we decided to proceed to the second&nbsp;sprint. Below is an overview of the progress for each discipline.&nbsp;<\/p>\n\n\n\n<p><strong>Mechanical<\/strong> <strong>department<\/strong><\/p>\n\n\n\n<p>The last two weeks have primarily&nbsp;involved further improving the design of the air hockey board&nbsp;and&nbsp;creating an initial design for&nbsp;the stick system. We wanted to be able to&nbsp;start&nbsp;creating&nbsp;a&nbsp;1<sup>st<\/sup>&nbsp;prototype already on Thursday 12. Sept, but&nbsp;because&nbsp;we&nbsp;lack&nbsp;some&nbsp;of&nbsp;the&nbsp;parts needed,&nbsp;as well as&nbsp;uncertain delivery times&nbsp;and an unknown budget from&nbsp;the lecturers,&nbsp;this was pushed&nbsp;back one week.&nbsp;Below you can see the newest version of the 3D model for the prototype&nbsp;of the stick system.&nbsp;The prototype will be used for testing of the stick system. Where the orientation of the stick will be determined by two motors connected to each&nbsp;other with a timing belt. A visual representation of this will be applied to the blog at a later stage.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"698\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-7-1024x698.png\" alt=\"\" class=\"wp-image-3140\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-7.png 1024w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-7-300x204.png 300w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-7-768x524.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>One of the changes to the actual board from last week is&nbsp;that we made the corners 90<sup>o<\/sup>&nbsp;rather than curved. This is because most air hockey tables are made this way and it will be simpler to calculate the discs path for the robot&nbsp;since there are less variables.&nbsp;<\/p>\n\n\n\n<p>To\u00a0reduce the time waiting for components and\u00a0budget from the lecturers we made a\u00a0budget\u00a0list\u00a0for\u00a0components we need to buy. These components are shown with hyperlinks\u00a0in the\u00a0table\u00a0below.\u00a0\u00a0<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"658\" height=\"206\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-9.png\" alt=\"\" class=\"wp-image-3144\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-9.png 658w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-9-300x94.png 300w\" sizes=\"auto, (max-width: 658px) 100vw, 658px\" \/><\/figure>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/www.byggmax.no\/48x98-konstruksjonsvirke-c24-p08148098\" target=\"_blank\"><em>48X98 Konstruksjonsvirke<\/em><\/a><em><br> <\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/no.rs-online.com\/web\/p\/aluminium-tubes\/9186374\/\" target=\"_blank\"><em>6063-T6 Round Aluminium Tube 1m x 10 mm<\/em><\/a><em>\u00a0 <br> <\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/www.banggood.com\/no\/LM10UU-10mm-Linear-Ball-Bearing-Linear-Bushing-10x19x29mm-p-931398.html?gmcCountry=NO&amp;currency=NOK&amp;createTmp=1&amp;utm_source=googleshopping&amp;utm_medium=cpc_bgs&amp;utm_content=xibei&amp;utm_campaign=xibei-pla-no-pc-no-tis-0826-13anv&amp;gclid=EAIaIQobChMI4e7IopTI5AIVT-aaCh1h5wESEAQYBCABEgJ9NvD_BwE&amp;cur_warehouse=CN\" target=\"_blank\"><em>Linear Bearings<\/em><\/a><em>\u00a0 <br> <\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/www.byggmax.no\/23x48-lekt-p08123048\" target=\"_blank\"><em>23X48 LEKT<\/em><\/a><em>\u00a0 <\/em><\/p>\n\n\n\n<p>These\u00a0components were picked from more local distributors rather than cheapest\u00a0price\u00a0possible.\u00a0This is because of the timeline of the project\u00a0and the necessity of\u00a0testing the functionality of the system sooner rather than later so that we ensure a functioning system at the\u00a0end of the project period.\u00a0<\/p>\n\n\n\n<p>There was also a need to 3D print some components for the system.\u00a0This is primarily for trialing and error\u00a0testing at first and getting a functional system as soon as possible. It would be ideal to have\u00a0as few components 3D printed as possible, but\u00a0as of now\u00a0for the prototype it is more time efficient.\u00a0(PS. These are early models which is used to see the functionality of the system, each part will be modified throughout the project):\u00a0<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"756\" height=\"341\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-10.png\" alt=\"\" class=\"wp-image-3145\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-10.png 756w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-10-300x135.png 300w\" sizes=\"auto, (max-width: 756px) 100vw, 756px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"755\" height=\"343\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-11.png\" alt=\"\" class=\"wp-image-3146\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-11.png 755w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-11-300x136.png 300w\" sizes=\"auto, (max-width: 755px) 100vw, 755px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"756\" height=\"372\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-12.png\" alt=\"\" class=\"wp-image-3147\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-12.png 756w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-12-300x148.png 300w\" sizes=\"auto, (max-width: 756px) 100vw, 756px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"759\" height=\"431\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-13.png\" alt=\"\" class=\"wp-image-3148\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-13.png 759w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-13-300x170.png 300w\" sizes=\"auto, (max-width: 759px) 100vw, 759px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"755\" height=\"365\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-14.png\" alt=\"\" class=\"wp-image-3149\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-14.png 755w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-14-300x145.png 300w\" sizes=\"auto, (max-width: 755px) 100vw, 755px\" \/><\/figure>\n\n\n\n<p>We have also been able to 3D print some components. Below you can see the pulleys that are designed for attachment&nbsp;to the&nbsp;motors&nbsp;both in SolidWorks and as a&nbsp;produced product.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"466\" height=\"337\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-15.png\" alt=\"\" class=\"wp-image-3150\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-15.png 466w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-15-300x217.png 300w\" sizes=\"auto, (max-width: 466px) 100vw, 466px\" \/><\/figure>\n\n\n\n<p><strong>Electrical department\u00a0<\/strong><\/p>\n\n\n\n<p>In the last two weeks,\u00a0the electrical engineering students\u00a0have been experimenting with the stepper motors, so that we can get used to them and how they function. We encountered a lot of problems when trying to get them to work exactly as we want, especially because we are not very familiar with this type of motor. Furthermore, we are not entirely certain which driver we\u2019re using to control them, as there doesn\u2019t appear to be any model information or reference on the unit.\u00a0<\/p>\n\n\n\n<p>One day was spent trying to get the motor moving and learning how we had to wire the control circuit. Despite our best efforts, however, the circuit that we made wasn\u2019t\u00a0working, even though everything\u00a0appeared\u00a0to be in order. We tried to change it, looking for more examples and tutorials on the internet, but we didn\u2019t find any good results. That day we left the school so disappointed.\u00a0<\/p>\n\n\n\n<p>The next week the computer science professor, Steven, who was also helping us the other day, informed us that he might have the solution: it was a problem with the intensity that we are applying to the coils of the motor. Furthermore, we realized that in addition to that problem, it turned out we\u2019ve been configuring the micro steps switches incorrectly, as we were leaving them in the NC position (not connected)!\u00a0Once\u00a0we solved that problem, the motor finally begun responding as it should.\u00a0<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"852\" height=\"639\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-2.jpeg\" alt=\"\" class=\"wp-image-3142\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-2.jpeg 852w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-2-300x225.jpeg 300w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-2-768x576.jpeg 768w\" sizes=\"auto, (max-width: 852px) 100vw, 852px\" \/><\/figure>\n\n\n\n<p style=\"text-align:left\">With the motor working, the next step was to get an idea of what speed we should move the motor to be able to create a competent computer opponent that could provide a good playing experience. For that task we decided to write a control code (in\u00a0Arduino\u00a0C) to vary the speed of the motor as we desired, after which we filmed the motor and a chronometer at slow-motion to be able to count how many rotations the motor\u00a0is\u00a0able to do in one second. Using this method, we got an approximation of the max rev\/s of the motor. Furthermore, to be certain of the veracity of the past procedure we made some calculations about the relation of the steps that the motor does every second, and the number of steps needed to do one revolution. We got the following results:\u00a0<br><br> 1s \/ 300\u03bcs\/stp = 3333,3\u00a0stp\/s\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 3333,3stps \/ 400stp\/rev = 8,3 rev\/s\u00a0 <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/dhWwnttsVNKC4x5fcbLrwI1KBaa-_iq-jdmGZacPJhehXpp2j8KhTlXHUvjJLymuuUdPAuIqJU6AgtB2BRMVIXJxOHfa88MbXk1x8oLrhW541AqvrRf-hAAbW9METQ\" alt=\"[video-to-gif output image]\" \/><\/figure>\n\n\n\n<p>These results are approximately the same that we get with our slow-motion experiment, and consequently, we concluded that it\u2019s a good estimation of the real speed.&nbsp;<\/p>\n\n\n\n<p><strong>Computer\u00a0department<\/strong><\/p>\n\n\n\n<p>We\u2019ve made progress on the software side of things as well, where we\u2019ve now started to watch and read tutorials about&nbsp;OpenCV, and experiment with the library. One minor issue we ran into early had to do with the camera\u2019s interface with the raspberry pi; when we set it up initially, it worked fine, but when we restarted the raspberry pi, the camera would no longer work. We discovered this was because we had to manually load modules into the kernel, specifically the \u201cbcm2835-4vl2\u201d module, using the \u201cmodprobe\u201d command. To avoid this issue later, we will likely have to create a script, so that it is loaded automatically every time.&nbsp;<\/p>\n\n\n\n<p>As for the programming and usage of\u00a0OpenCV\u00a0itself, to begin with, we wanted to make the camera capable of detecting, and subsequently track any given object, like this:\u00a0<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/vz4rYh7ZG5uTySbxvis5wCno2CLIF4htEKZPwdpwIET-mNBdIOucawtFi-ihZmpsNmzJkzfMlC0NGeiguk_c_oOBRLL1ZRb1DZjRA-zjecJiCZcG13FSls5FcfyjMVM9r1b_xjE1\" alt=\"\" \/><\/figure>\n\n\n\n<p>The code for this that we found was&nbsp;fairly complex&nbsp;(relative to our experience), but we managed to make it work eventually, and we successfully detected a board marker, and partially managed to track it.&nbsp;<\/p>\n\n\n\n<p>The issue we ran into here was that the FPS of the tracking was so low (2-5 fps) that it couldn\u2019t properly keep track of the object. Consequently, when the object moved too fast, or was even partially obscured, the tracking was lost. First, we figured it could perhaps be because the GPU didn\u2019t have enough memory, so we attempted to double it, to no avail. To get a better idea of memory usage and the like, we installed \u201chtop\u201d, which is a sort of system monitor that could serve our needs. Here, we discovered that a single core of the CPU was working at 100% capacity, whereas the other cores were maintaining around 10% capacity. Instead of beginning to look too deep into why this was the case, and how we might solve it, we decided instead to\u00a0look into\u00a0other methods we could use with\u00a0OpenCV, such as color tracking.\u00a0<\/p>\n\n\n\n<p>We started out by making a simple Python&nbsp;program that tracked objects of blue&nbsp;color&nbsp;by defining&nbsp;the&nbsp;color&nbsp;range to be detected and masking the rest of the video image. This simple yet useful&nbsp;method&nbsp;helped us get a bit more familiar with OpenCV library and its basic functions.&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"564\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-8-1024x564.png\" alt=\"\" class=\"wp-image-3143\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-8.png 1024w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-8-300x165.png 300w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/09\/image-8-768x423.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Our second Python-program detected the presence of a blue&nbsp;colored&nbsp;object using computer vision techniques as we did earlier, but this time it would also track the object\u2019s movement in the video frames and draw its previous positions as it moves. We computed the contour of the object and drew it in on our frame by detecting contours in the mask and computing&nbsp;the&nbsp;enclosing circle and centroid since our object will be a disk.&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/q_N6ZE146uDbb7isohjgdjmPxC-BwPDJTpy0ngI2nRz3MtLSUMs2qbEgiAADn57yRDi0kC0Vm7P8nZ51G9pGr7ayjFitIn2x003ONLD3bWBWFmu-KBeOd4b8OJh57JqVAGByDW5J\" alt=\"[video-to-gif output image]\" \/><\/figure>\n\n\n\n<p>We tried to evolve our program further by computing the\u00a0centre\u00a0(x, y)\u00a0coordinates of the detected object and using it to compute the direction the object is moving in.\u00a0 The problem we faced is that\u00a0the\u00a0video feed from\u00a0the\u00a0pi-camera on\u00a0the\u00a0raspberry pi freezes on the first frame of our live video stream from\u00a0the\u00a0camera. <\/p>\n\n\n\n<p>So,\u00a0the question is: can we identify the source of this problem and fix it? With that being said, we experienced a lot of freezing in OS of the Raspberry Pi in general while working with it this week. This got us thinking that maybe this is a performance issue with the current Raspberry Pi. If it freezes at this point, will it be powerful enough for our object\u2019s live position\u00a0&amp;\u00a0movement tracking,\u00a0as well as\u00a0other computing\u00a0when\u00a0our program becomes more\u00a0complex? We are using\u00a0the\u00a0Raspberry Pi 3 Model B (2015)\u00a0currently,\u00a0but\u00a0we do have access to\u00a0the\u00a0Raspberry Pi 3 Model B+ (2017) that we could potentially program instead for better performance. But first, we could try resizing the image to a smaller resolution;\u00a0there is no need for\u00a0full HD (1080p).\u00a0<\/p>\n\n\n\n<p>Going forward, we want to deepen our understanding of the library,\u00a0determine whether it\u2019s necessary to use a newer Raspberry Pi,\u00a0learn how to derive information from the tracking (e.g. angle, velocity), and test it with an actual disk and board.\u00a0\u00a0<\/p>\n\n\n\n<p><strong>Sources:<\/strong><\/p>\n\n\n\n<p><em>Car object tracking gif:<\/em>  <a rel=\"noreferrer noopener\" href=\"https:\/\/www.pyimagesearch.com\/2018\/07\/30\/opencv-object-tracking\/\" target=\"_blank\">https:\/\/www.pyimagesearch.com\/2018\/07\/30\/opencv-object-tracking\/<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>For this Thursday, we had our usual meeting, where each of us recounted to one another what we had accomplished since last time, what issues we encountered, and what we planned to do next. Using Trello, we browsed through the first sprint, discussing the various tasks and their status, making sure we had some idea [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51,52],"tags":[],"class_list":["post-3139","post","type-post","status-publish","format-standard","hentry","category-smart-systems-2019","category-the-unbeatable-air-hockey-team"],"_links":{"self":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/3139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3139"}],"version-history":[{"count":1,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/3139\/revisions"}],"predecessor-version":[{"id":3151,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/3139\/revisions\/3151"}],"wp:attachment":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}