{"id":256,"date":"2013-04-24T14:41:59","date_gmt":"2013-04-24T14:41:59","guid":{"rendered":"http:\/\/bech.in\/?p=256"},"modified":"2021-10-22T16:02:34","modified_gmt":"2021-10-22T16:02:34","slug":"lesson-8","status":"publish","type":"post","link":"https:\/\/bech.in\/?p=256","title":{"rendered":"Lesson 8"},"content":{"rendered":"<p><strong>Date:<\/strong> 18th of April 2013<br \/>\n<strong>Participating group members:<\/strong> Kenneth Baag\u00f8e, Morten D. Bech and Thomas Winding<br \/>\n<strong>Activity duration:<\/strong> 6 hours<\/p>\n<p><strong>Goal<\/strong><br \/>\nThe goal of this lab session is to construct a robot for the Lego Sumo Wrestling contest as described in the <a href=\"http:\/\/legolab.cs.au.dk\/DigitalControl.dir\/NXT\/Lesson8.dir\/Lesson.html\" title=\"Lesson plan\" target=\"_blank\" rel=\"noopener\">lesson plan<\/a>. <\/p>\n<p><strong>Plan<\/strong><br \/>\nThe plan is first follow the instruction in the lesson plan and then improve the robot to increase our chances of winning the contest.<\/p>\n<p><strong>Progress<\/strong><br \/>\n<em>Construction and first observations<\/em><br \/>\nWe started out by constructing the robot as described in the lesson plan, pictured below.<\/p>\n<div id=\"attachment_261\" style=\"width: 594px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0087.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-261\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0087-1024x678.jpg\" alt=\"Sumo Wrestler - basic setup\" width=\"584\" height=\"386\" class=\"size-large wp-image-261\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0087-1024x678.jpg 1024w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0087-300x198.jpg 300w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0087-452x300.jpg 452w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/a><p id=\"caption-attachment-261\" class=\"wp-caption-text\">Sumo Wrestler &#8211; basic setup<\/p><\/div>\n<p>Next, we installed the basic program on the robot and tried running it in the arena. Below is a short video of it, showing the behaviour of the robot when running in the arena without an opponent, can also be viewed here: <a href=\"http:\/\/youtu.be\/7NbRPb7FulY\" title=\"Sumo Wrestler - basic program\" target=\"_blank\" rel=\"noopener\">http:\/\/youtu.be\/7NbRPb7FulY<\/a>.<\/p>\n<p><iframe loading=\"lazy\" width=\"640\" height=\"360\" src=\"http:\/\/www.youtube.com\/embed\/7NbRPb7FulY?feature=player_embedded\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>From observing the robot running the program we saw what we expected to be two triggers: When the robot saw the white edge on the arena and every five seconds, these can also be seen in the video above.<\/p>\n<p>The behaviour of the robot wheen seeing the white edge is that it backs up a bit and then turns, where both the backwards distance moved and the angle turned are constant. The behaviour related to the trigger that happens every five seconds is that it turns, this time the angle of the turn is random. Finally when none of the two mentioned triggers were triggered the robot would simply move forward at full speed.<\/p>\n<p><em>The SumoBot code<\/em><br \/>\nLooking into the code we found that the structure of the lower and higher levels of control can be depicted as seen in the figure below.<\/p>\n<div id=\"attachment_266\" style=\"width: 639px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/Control-levels.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-266\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/Control-levels.png\" alt=\"Control levels for the basic SumoBot\" width=\"629\" height=\"424\" class=\"size-full wp-image-266\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/Control-levels.png 629w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/Control-levels-300x202.png 300w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/Control-levels-445x300.png 445w\" sizes=\"auto, (max-width: 629px) 100vw, 629px\" \/><\/a><p id=\"caption-attachment-266\" class=\"wp-caption-text\">Control levels for the basic SumoBot<\/p><\/div>\n<p>This means that the drive function is the lowest priority of the behaviours of the robot, whenever a trigger is triggered the drive behaviour will be suspended. The second-lowest behaviour is the turn behaviour which turns the robot in place, this behaviour can be suspended only by the edge avoiding behaviour. Finally the highest priority behaviour of the robot is avoiding the edge, being the highest priority means that it can never be suspended and will always take precendece over any other behaviour.<\/p>\n<p>Taking an example from the code, the turn behaviour is implemented with the following code.<\/p>\n<div id=\"attachment_298\" style=\"width: 332px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/turnBehaviour.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-298\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/turnBehaviour.png\" alt=\"The main part of the Turn behaviour code\" width=\"322\" height=\"331\" class=\"size-full wp-image-298\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/turnBehaviour.png 322w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/turnBehaviour-291x300.png 291w\" sizes=\"auto, (max-width: 322px) 100vw, 322px\" \/><\/a><p id=\"caption-attachment-298\" class=\"wp-caption-text\">The main part of the Turn behaviour code<\/p><\/div>\n<p>As can be seen our assumption that the turn behaviour happened roughly every five seconds was correct as there is a delay of 5000ms. When the turn behaviour starts actually doing something, that is, when the delay has been completed, it starts by suppressing the behaviour that has priority right below it. This is then followed by the functions that makes the robot turn a random angle. Finally the behaviour releases the suppression on the behaviour that it suppressed when it started. <\/p>\n<p>This basic idea of &#8220;suppress behaviour below in regards to priority &#8211; execute behaviour &#8211; release suppression&#8221; is used in all the behaviours in the SumoBot and should make it fairly straightforward to add extra behaviours to the robot.<\/p>\n<p>The way that each behaviour knows what to suppress is implemented in the abstract class Behavior.java where the constructor asks for a behaviour. This provided behaviour is then treated as the one right below in a subsumption architecture. If one should be interested in creating a new lowest priority behaviour, it should be noted that the lowest priority behaviour is simply provided <code>null<\/code> as its subsumed behaviour.<br \/>\nWhen a behaviour receives a subsumed behaviour it creates a SuppressNode which, in its essence, contains a counter for the number of times it has been suppressed. When a behaviour suppresses another behaviour the suppress cascades down the subsumption architecture, basically incrementing the suppress counter for every lower priority behaviour by one, and vice versa for the release function. <\/p>\n<div id=\"attachment_300\" style=\"width: 492px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/suppress.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-300\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/suppress.png\" alt=\"The suppress() method\" width=\"482\" height=\"121\" class=\"size-full wp-image-300\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/suppress.png 482w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/suppress-300x75.png 300w\" sizes=\"auto, (max-width: 482px) 100vw, 482px\" \/><\/a><p id=\"caption-attachment-300\" class=\"wp-caption-text\">The suppress() method<\/p><\/div>\n<p>The function of the SuppressNode is then to tell whether or not a behaviour is suppressed which is determined by the simple function of whether the suppress counter is zero or not.<\/p>\n<div id=\"attachment_301\" style=\"width: 309px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/isSuppressed.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-301\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/isSuppressed.png\" alt=\"The isSuppressed() method that determines whether a behaviour is suppressed or not\" width=\"299\" height=\"62\" class=\"size-full wp-image-301\" \/><\/a><p id=\"caption-attachment-301\" class=\"wp-caption-text\">The isSuppressed() method that determines whether a behaviour is suppressed or not<\/p><\/div>\n<p><em>OverturnOpponent\/Improving the SumoBot<\/em><br \/>\nAfter finishing construction of the base SumoBot we started adding the functionality for overturning an opponent in the arena, we went about this by adding a supersonic distance sensor to the robot to determine whether there is something in front of it and adding a forklift arm to do the overturning.<\/p>\n<p>Our first attempt was following the <a href=\"http:\/\/legolab.cs.au.dk\/DigitalControl.dir\/NXT\/Lesson8.dir\/ExpressBot.pdf\" title=\"Extension guide\">extension guide<\/a> for the base car to add the forklift arm and the supersonic sensor to build a robot that looked like the picture below.<\/p>\n<div id=\"attachment_303\" style=\"width: 1136px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBot.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-303\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBot.png\" alt=\"First attempt\" width=\"1126\" height=\"601\" class=\"size-full wp-image-303\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBot.png 1126w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBot-300x160.png 300w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBot-1024x546.png 1024w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBot-500x266.png 500w\" sizes=\"auto, (max-width: 1126px) 100vw, 1126px\" \/><\/a><p id=\"caption-attachment-303\" class=\"wp-caption-text\">First attempt<\/p><\/div>\n<p>This way of constructing the robot, however, presented a number of problems: The forklift arm was not very rigid, owing to the fact that it was only secured in one side. The forklift arm could also not be lowered all the way to a horizontal position because it would hit the light sensor. Finally the supersonic sensor could not always be used to detect whether there was something in front of it since it was mounted to point straight ahead. Testing against the base car which is not very tall we found that the sensor would not pick up the opponent at all.<\/p>\n<p>The above things taken into consideration we rebuilt the extensions somewhat to remedy the problems. This meant that we moved the forklift arm forward a bit so it would not hit the light sensor, secured the arm on the other side of the robot to stabilize it and tilted the supersonic sensor downwards so it could pick up objects in front of it that were short.<\/p>\n<div id=\"attachment_314\" style=\"width: 1136px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBotModified.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-314\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBotModified.png\" alt=\"The modified SumoBot\" width=\"1126\" height=\"587\" class=\"size-full wp-image-314\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBotModified.png 1126w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBotModified-300x156.png 300w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBotModified-1024x533.png 1024w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/SumoBotModified-500x260.png 500w\" sizes=\"auto, (max-width: 1126px) 100vw, 1126px\" \/><\/a><p id=\"caption-attachment-314\" class=\"wp-caption-text\">The modified SumoBot<\/p><\/div>\n<p>This construction worked well as all the problems described above were resolved: The arm could now lower all the way to a horizontal position, it wasn&#8217;t as wobbly and the supersonic sensor could be used to detect smaller robots in front of it.<\/p>\n<p>A final problem was that the even though the forklift was now pretty rigid and more sturdy than the first build, the motor that controlled it was not strong enough to actually lift an opponent robot. We tried to remedy this by gearing the forklift motor up but that still did not output enough power to lift another robot. We also noted found that the distance sensor was angled too much downwards to properly detect opponents, therefore we angled it just a bit more up which made the detections of opponents more reliable.<\/p>\n<div id=\"attachment_317\" style=\"width: 594px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0096.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-317\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0096-1024x678.jpg\" alt=\"The finished Sumo Wrestler\" width=\"584\" height=\"386\" class=\"size-large wp-image-317\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0096-1024x678.jpg 1024w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0096-300x198.jpg 300w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0096-452x300.jpg 452w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/DSC_0096.jpg 1280w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/a><p id=\"caption-attachment-317\" class=\"wp-caption-text\">The finished Sumo Wrestler<\/p><\/div>\n<p><em>The Forklift behaviour<\/em><br \/>\nAs we added a new functionality to the robot when we added the forklift arm, we had to add a new behaviour. This behaviour would utilize the forklift arm to try to overturn the opponent when the robot detected the opponent by way of the supersonic sensor.<\/p>\n<p>The behaviour was implemented in <a href=\"http:\/\/bech.in\/code\/digital_control\/lab8\/Forklift.java\" title=\"Forklift.java\" target=\"_blank\" rel=\"noopener\">Forklift.java<\/a>, the main part of the behaviour is pictured below (where uss is the supersonic sensor and motor is the motor that controls the forklift arm).<\/p>\n<div id=\"attachment_324\" style=\"width: 303px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/forklift.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-324\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/forklift.png\" alt=\"The Forklift behaviour\" width=\"293\" height=\"181\" class=\"size-full wp-image-324\" \/><\/a><p id=\"caption-attachment-324\" class=\"wp-caption-text\">The Forklift behaviour<\/p><\/div>\n<p>The behaviour checks the distance until it finds something less than 15 cms away from the robot, when this happens the robot suppresses the lower prioritized behaviours, raises the forklift arm and moves forward at full speed for two seconds and then lowers the arm again, followed by releasing the suppression.<\/p>\n<p>When programming this behaviour we did not implement a functionality to suppress the access to the motor that moves the forklift arm as we knew that only a single behaviour would be accessing it. This is important to keep in mind should we ever want to expand upon this program since it would create problems if we tried to access the motor from multiple behaviours.<\/p>\n<p>We added the forklift behaviour as the second-highest priority for the robot (<a href=\"http:\/\/bech.in\/code\/digital_control\/lab8\/SumoBot.java\" title=\"SumoBot.java\" target=\"_blank\" rel=\"noopener\">SumoBot.java<\/a>), leaving the avoid-edge behaviour as the highest priority. This gave us the levels of control depicted in the figure below.<\/p>\n<p><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/Control-levels-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/04\/Control-levels-2.png\" alt=\"Control levels\" width=\"629\" height=\"574\" class=\"alignnone size-full wp-image-327\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/Control-levels-2.png 629w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/Control-levels-2-300x273.png 300w, https:\/\/bech.in\/wp-content\/uploads\/2013\/04\/Control-levels-2-328x300.png 328w\" sizes=\"auto, (max-width: 629px) 100vw, 629px\" \/><\/a><\/p>\n<p>As we were adding the forklift behaviour we also wrote another behaviour that could possibly be used in lieu of the forklift. This behaviour (<a href=\"http:\/\/bech.in\/code\/digital_control\/lab8\/Ultrasonic.java\" title=\"Ultrasonic.java\" target=\"_blank\" rel=\"noopener\">Ultrasonic.java<\/a>) would simply move the robot forward at full speed when something was detected in front of the robot.<\/p>\n<p><strong>Conclusion<\/strong><br \/>\nAs noted above, even when gearing up the motor that controls the forklift arm it did not output enough power to actually lift another robot. We don&#8217;t know whether it&#8217;s possible to add further strength to the arm, but it seems to be necessity to actually be able to overturn opponents. Otherwise a different approach to the SumoBot could be the &#8220;move-forward-when-opponent-detected&#8221; behaviour that was described above. This approach would simply attempt to push the opponent out of the arena instead of flipping him over.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Date: 18th of April 2013 Participating group members: Kenneth Baag\u00f8e, Morten D. Bech and Thomas Winding Activity duration: 6 hours Goal The goal of this lab session is to construct a robot for the Lego Sumo Wrestling contest as described &hellip; <a href=\"https:\/\/bech.in\/?p=256\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-256","post","type-post","status-publish","format-standard","hentry","category-digicon"],"_links":{"self":[{"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/posts\/256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bech.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=256"}],"version-history":[{"count":46,"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/posts\/256\/revisions"}],"predecessor-version":[{"id":782,"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/posts\/256\/revisions\/782"}],"wp:attachment":[{"href":"https:\/\/bech.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bech.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bech.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}