{"id":3324,"date":"2019-10-03T12:31:26","date_gmt":"2019-10-03T11:31:26","guid":{"rendered":"http:\/\/dronesonen.usn.no\/?p=3324"},"modified":"2019-10-03T12:31:26","modified_gmt":"2019-10-03T11:31:26","slug":"group-02-project-report-week-5","status":"publish","type":"post","link":"https:\/\/dronesonen.usn.no\/?p=3324","title":{"rendered":"Group 02 &#8211; Project Report &#8211; Week 5"},"content":{"rendered":"\n<p><strong>Mechanical\u00a0&amp; Electrical\u00a0<\/strong><\/p>\n\n\n\n<p>This week we have finally started creating the first parts of the board.\u00a0We have found that\u00a0the building part with wood will take a bit longer than anticipated since none of the group members have any carpenter experience.\u00a0<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"718\" height=\"404\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-2.png\" alt=\"\" class=\"wp-image-3329\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-2.png 718w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-2-300x169.png 300w\" sizes=\"auto, (max-width: 718px) 100vw, 718px\" \/><figcaption>Cutting wood for board frame<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"397\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-3.png\" alt=\"\" class=\"wp-image-3330\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-3.png 703w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-3-300x169.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><figcaption>Mounting board walls with angle brackets<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"613\" height=\"462\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-4.png\" alt=\"\" class=\"wp-image-3331\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-4.png 613w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-4-300x226.png 300w\" sizes=\"auto, (max-width: 613px) 100vw, 613px\" \/><figcaption>Finishing build of air hockey board frame<\/figcaption><\/figure>\n\n\n\n<p>We have also tested out different dimensions for\u00a0the 3D-printed parts that are going to connect with the \u00d810 aluminum pipe, and we have found that\u00a0different structures\u00a0shrink\u00a0at different\u00a0dimensions. Therefore,\u00a0we quickly realized after talking with Richard that we should\u00a0try every fit in a smaller scale first, rather than producing everything at once and then realize that\u00a0nothing\u00a0fits.\u00a0\u00a0<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"634\" height=\"358\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-5.png\" alt=\"\" class=\"wp-image-3332\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-5.png 634w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-5-300x169.png 300w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><figcaption>Modifying component dimensions to fit aluminium pipe<\/figcaption><\/figure>\n\n\n\n<p>Also,&nbsp;another lesson learned the hard way was that even if everything that is shown in Solid Works seems logical, it might not be&nbsp;in real life.&nbsp;This was the case when we modelled and produced the holed-out board plate. We will now produce a smaller piece of&nbsp;the plate with a more frequent number of smaller holes and check out the pressure we get with the fans when they arrive.&nbsp;<\/p>\n\n\n\n<p>Earlier in the project we have created parts that are meant for testing purposes.\u00a0This means that they might not be very common or producible.\u00a0Since we\u2019re now at a later stage in the project we have started to redesign\u00a0all the components so that they are easier and more economical to produce\u00a0if they were ever\u00a0to be\u00a0made in a larger scale.\u00a0<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"757\" height=\"486\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-12.png\" alt=\"\" class=\"wp-image-3346\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-12.png 757w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-12-300x193.png 300w\" sizes=\"auto, (max-width: 757px) 100vw, 757px\" \/><figcaption>Overview of redesigned SW model<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"758\" height=\"315\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-13.png\" alt=\"\" class=\"wp-image-3347\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-13.png 758w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-13-300x125.png 300w\" sizes=\"auto, (max-width: 758px) 100vw, 758px\" \/><figcaption>Redesigned side mount for aluminium pipe<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"758\" height=\"315\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-14.png\" alt=\"\" class=\"wp-image-3348\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-14.png 758w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-14-300x125.png 300w\" sizes=\"auto, (max-width: 758px) 100vw, 758px\" \/><figcaption>Pulley for side mount<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"760\" height=\"330\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-15.png\" alt=\"\" class=\"wp-image-3349\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-15.png 760w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-15-300x130.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/><figcaption>Redesigned slider<\/figcaption><\/figure><\/div>\n\n\n\n<p>We\u00a0have also designed and modelled a first\u00a0sketch of the\u00a0bridge\u00a0that\u00a0will be where we mount the camera used to film the movement of the disc. It\u00a0might\u00a0also\u00a0contain both a scoreboard and a timer.\u00a0<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"759\" height=\"415\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-16.png\" alt=\"\" class=\"wp-image-3350\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-16.png 759w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-16-300x164.png 300w\" sizes=\"auto, (max-width: 759px) 100vw, 759px\" \/><figcaption>Bridge<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"760\" height=\"516\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-17.png\" alt=\"\" class=\"wp-image-3351\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-17.png 760w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-17-300x204.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/><figcaption>Bridge mounted on the air hockey board<\/figcaption><\/figure><\/div>\n\n\n\n<p><strong>Computer\u00a0<\/strong><\/p>\n\n\n\n<p>Last week presented us with the critical problem of our Raspberry Pi version 3 not being powerful enough to facilitate the object tracking and calculation of the data we need. Consequently, we have divided our attention, where one of us keep developing the program for the object tracking, and the other solves the performance problem.&nbsp;<\/p>\n\n\n\n<p><strong>For the program<\/strong>, last week\u2019s goals have been achieved to some degree, and we believe we have managed to implement both displacement and velocity calculation. It\u2019s difficult to tell whether it calculates the correct values, as the unit is currently in pixels per second, but the values doesn\u2019t appear to be entirely unreasonable, and the value is negative or positive depending on which direction it moves in relation to the coordinate system. Additional testing will be required to verify if this functionality was implemented correctly.\u00a0<\/p>\n\n\n\n<p>Implementing this took longer than we hoped for. As mentioned in last week\u2019s blog, there were no modern, simple-to-follow tutorials on how to implement this that we could find, and so we had to rely primarily on our own experience and knowledge, and figure it out by experimenting. It is a fairly simple problem to solve in\u00a0actuality, but\u00a0implementing and making it work in the context of a relatively complicated program, while attempting to make use of the existing resources within it, was challenging.\u00a0<\/p>\n\n\n\n<p>In order to implement velocity calculation, two things are necessary:&nbsp;<\/p>\n\n\n\n<p><strong>Velocity = Displacement \/ Time\u00a0<\/strong><\/p>\n\n\n\n<p>So, we had to figure out a way to get <strong>displacement<\/strong>, and a way to get <strong>time<\/strong>. In order to obtain the former, we simply had to calculate the delta of its position for each frame; for frame 1, we calculated its position and put it in an array; for frame 2, we calculated the position again. In that way, we can obtain the delta of its position by taking the position from frame 2 and subtract the position from frame\u00a01, and\u00a0repeat the process for each frame.\u00a0<\/p>\n\n\n\n<p>Obtaining the latter seemed like a slightly more complicated problem to us, but as it turned out after (too) much deliberation, we could simply calculate the amount of time each frame took, and calculate the delta of the time by subtracting the time for frame 2 by the time for frame 1, and repeat for each frame.&nbsp;The following figure illustrates the process:&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-1024x490.png\" alt=\"\" class=\"wp-image-3325\" width=\"616\" height=\"295\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image.png 1024w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-300x144.png 300w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2019\/10\/image-768x368.png 768w\" sizes=\"auto, (max-width: 616px) 100vw, 616px\" \/><figcaption>Process for obtaining displacement and time<\/figcaption><\/figure><\/div>\n\n\n\n<p>In pseudocode, it would look something like this:&nbsp;<\/p>\n\n\n\n<p>getFrame1\u00a0<br>start = time()<br>&#8230;<br>positionX = currentX<br>positionY = currentY<br>position.append(squareRoot(square(positionX) + square(positionY)))<br>&#8230;<br>end = time()<br>time.append(end-start)<br>if (length(position) &gt; 2):<br>         calculateDisplacement()<br>         calculateVelocity()<br>getFrame2<br>(Repeat the above)<\/p>\n\n\n\n<p>Where the calculateDisplacement() and calculateVelocity() functions simply calculates the deltas between two frames; for the first two frames, using the figure above, it would be:\u00a0<\/p>\n\n\n\n<p>V = (pos2 \u2013 pos1) \/ (f2 time \u2013 f1 time)&nbsp;<\/p>\n\n\n\n<p>As <strong>for the performance problems<\/strong>, this week we did some hardware upgrades. As mentioned before\u00a0the\u00a0Raspberry PI 3 did not meet our\u00a0performance requirements,\u00a0so after doing\u00a0some\u00a0testing\u00a0we decided that hardware upgrade was\u00a0a must.\u00a0\u00a0The best upgrade regarding the performance and by keeping in mind that the new hardware needed to be obtained quickly, we decided that Raspberry Pi 4 was the most optimal solution. We used almost a whole week\u00a0(week 39)\u00a0on\u00a0getting approval from USN to buy the new Pi and the necessary components (microSD card and\u00a0microHDMI\u00a0adapter). Luckily, as soon as the purchases were\u00a0approved\u00a0we where\u00a0able to obtain everything locally in Kongsberg, avoiding any delivery time.\u00a0<\/p>\n\n\n\n<p>After obtaining the new Pi it had to be set up with&nbsp;a&nbsp;OS, OpenCV library etc.&nbsp;&nbsp;<\/p>\n\n\n\n<p>We installed the OS&nbsp;on the&nbsp;SDcard&nbsp;by following the setup guide provided by Raspberry Pi foundation; this did not&nbsp;work&nbsp;and it would get stuck on the \u201crainbow screen\u201d when we tried to boot it.&nbsp;The problem was solved by \u201cfull overwrite\u201d-formatting the memory card prior to the OS installation instead of \u201cquick\u201d formatting as the setup guide suggested.&nbsp;&nbsp;<\/p>\n\n\n\n<p>Next,\u00a0we had to compile the OpenCV from source.\u00a0We tried to follow the same guide for installing OpenCV as we did last time on our Raspberry Pi 3, but it did not work; the compilation was interrupted by an error. This type of error did not give any helpful results when googling the\u00a0problem\u00a0so we had to try and figure it out on our own. We almost gave up after spending about 8 hours on trying to fix the problem by updating and upgrading, reinstalling dependencies, libraries, optimization packages for OpenCV, recompiling and so on.\u00a0\u00a0<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/uisn-my.sharepoint.com\/personal\/216980_usn_no\/Documents\/Smart_systems\/Blog%20Posts\/Drafts\/Blogpost5_Alina\/compiling.gif\" alt=\"\" \/><figcaption>OpenCV compilation on the newly acquired Raspberry Pi 4<\/figcaption><\/figure>\n\n\n\n<p>The only thing we could think of&nbsp;was&nbsp;to start from&nbsp;scratch (the error could have been a consequence of an error in OS-installation).&nbsp;This time instead of using \u201cthe easy OS installer\u201d NOOBS,&nbsp;we&nbsp;installed&nbsp;Raspbian Buster with desktop and recommended software&nbsp;by&nbsp;flashing the&nbsp;Buster&nbsp;.img&nbsp;file&nbsp;to the memory card using Etcher software.&nbsp;&nbsp;<\/p>\n\n\n\n<p>We found a new updated guide on how to install OpenCV 4 on Raspberry Pi 4 and Raspbian Buster&nbsp;[1]. This guide&nbsp;gave us a much better understanding of the whole process by thoroughly&nbsp;explaining every step. The following is the summary of what we did after inserting the microSD card into the Pi and booting it up:&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Expanded the filesystem to\u00a0include all 32GB of the micro-SD card\u00a0<\/li><li>Updated and upgraded all existing packages\u00a0\u00a0<\/li><li>Installed dependences,\u00a0I\/O libraries, and optimization packages for OpenCV\u00a0<\/li><li>Created\u00a0Python 3 virtual environment, installed NumPy and\u00a0PiCamera\u00a0API\u00a0<\/li><li>Increased\u00a0SWAP space\u00a0in order to\u00a0compile OpenCV with all four cores of the RP<\/li><li>Compile and install the full, optimized OpenCV library\u00a0from source\u00a0<\/li><li>Restored SWAP in order to\u00a0not to\u00a0burn out\u00a0the\u00a0microSD card\u00a0\u00a0\u00a0<\/li><li>Backup the .img\u00a0file (with OpenCV + Python)\u00a0<\/li><\/ol>\n\n\n\n<p>Success! We have now installed the OpenCV 4 on our Raspberry Pi 4.&nbsp;&nbsp;<\/p>\n\n\n\n<p>While working with the new Pi we noticed some serious overheating of the board and we\u00a0actually had\u00a0to pack it in ice to keep it cool through the compiling process. The next sprint we are planning on researching this issue some more to find out if the CPU is throttling due to overheating, and maybe consider investing in a cooling system.\u00a0<\/p>\n\n\n\n<p>References:&nbsp;<\/p>\n\n\n\n<p>[1]&nbsp;<a href=\"https:\/\/www.pyimagesearch.com\/2019\/09\/16\/install-opencv-4-on-raspberry-pi-4-and-raspbian-buster\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.pyimagesearch.com\/2019\/09\/16\/install-opencv-4-on-raspberry-pi-4-and-raspbian-buster\/<\/a>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mechanical\u00a0&amp; Electrical\u00a0 This week we have finally started creating the first parts of the board.\u00a0We have found that\u00a0the building part with wood will take a bit longer than anticipated since none of the group members have any carpenter experience.\u00a0 We have also tested out different dimensions for\u00a0the 3D-printed parts that are going to connect with [&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-3324","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\/3324","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=3324"}],"version-history":[{"count":7,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/3324\/revisions"}],"predecessor-version":[{"id":3355,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/3324\/revisions\/3355"}],"wp:attachment":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}