{"id":645,"date":"2018-05-11T20:12:31","date_gmt":"2018-05-11T20:12:31","guid":{"rendered":"http:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/?page_id=645"},"modified":"2018-05-11T23:32:13","modified_gmt":"2018-05-11T23:32:13","slug":"algorithms","status":"publish","type":"page","link":"https:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/algorithms\/","title":{"rendered":"Algorithms"},"content":{"rendered":"<p><strong>Emergency braking for obstacle avoidance<\/strong><\/p>\n<p><span style=\"font-weight: 400\">DJI provides Onboard SDK which can be used to communicate with DJI flight controller to receive real-time data and to control the quadcopter. Our DJI interface is built around the ros wrapper of Onboard SDK which allows receiving data as ros topics and publish commands by subscribing to ROS services.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">DJI provides information related to state of the aircraft which includes position, attitude, velocity, pilot commands, etc. A separate node was written for emergency brake functionality. This node subscribes to pilot control inputs and based on position of a switch on the radio controller it either enables or disables our custom flight mode. This custom flight mode converts pilot commands to velocity commands for the quadcopter. These velocity commands are constrained if pilot\u2019s commands are leading to a collision.\u00a0<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-765 img-responsive\" src=\"http:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-content\/uploads\/sites\/24\/2018\/05\/ob1.png\" alt=\"\" width=\"1052\" height=\"387\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">For obstacle avoidance we can easily determine the time to impact from zeroing the speed equation and introducing its value back into the position equation.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-767 img-responsive\" src=\"http:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-content\/uploads\/sites\/24\/2018\/05\/eq1.png\" alt=\"\" width=\"827\" height=\"110\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">This equation can be solved for the equilibrium speed that a pilot input should give, that given a non-zero initial speed at a particular point, would stop at the obstacle location. Nonetheless, the equation is transcendent (product log) and Matlab\/Mathematica are really bad solving it (C++ is bound to be even worse).<\/span><\/p>\n<p><span style=\"font-weight: 400\">Instead of doing this, we solve for two types of situations that are really simple: the \u201cNo Return\u201d range (what is the distance the quad travels starting from a non-zero speed and having full reverse input) and the \u201cZero Input\u201d range (the distance the quad travels with a zero input when starting from a non-zero initial speed).<\/span><\/p>\n<p><span style=\"font-weight: 400\">We then fit a straight line between the two limit cases, simplifying the inverse dynamics and getting a control that reacts faster than the original function and should be more stable than a non-linear control with a function whose numerical computation is problematic. As a bonus, the straight line can be extended beyond the \u201cZero Input\u201d as we no longer have a domain problem as we did in the \u201cProduct Log\u201d. The point where we can give maximum input in the direction of the obstacle and still stop on time is referred to as \u201cFull Control\u201d.<\/span><\/p>\n<p><span style=\"font-weight: 400\">With this approach we were able to operate seamlessly in four different regimes:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Type I: The quad is in a state where the obstacle is further away from the \u201cFull Control\u201d and the pilot can do whatever he pleases<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Type II: the quad is in a state where the obstacle is further than the \u201cZero Input\u201d range and the algorithm operates in the region of positive thrust inputs (which is a one to mapping to a target steady state speed) that tend gradually to zero as the obstacle approaches<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Type III: the quad is in state further away from the \u201cNo return range and the algorithms operates in the region of negative thrust inputs that tend gradually to zero as the object approaches<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Type IV: the quad is in a state closer than the \u201cNo return\u201d range and only accepts inputs of \u201cfull reverse\u201d<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">So, in directions where there are no obstacles, the pilot is by default in the \u201cType 1\u201d regime. The detailed test cases can be found in the Annex 1 of this report.<\/span><span style=\"font-weight: 400\"> In figure 11:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Y is the computed range (output in m), X is the equilibrium speed (input in m\/s)<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Blue is the \u201creal\u201d product log function and <\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">Red is the simplified control (please note that this is not a classic linearization about a single point instead it is a simplification that fits across <\/span><span style=\"font-weight: 400\">two<\/span><span style=\"font-weight: 400\"> different points\/regimes).<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-766 img-responsive\" src=\"http:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-content\/uploads\/sites\/24\/2018\/05\/ob2.png\" alt=\"\" width=\"560\" height=\"312\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Emergency braking for obstacle avoidance DJI provides Onboard SDK which can be used to communicate with DJI flight controller to receive real-time data and to control the quadcopter. Our DJI interface is built around the ros wrapper of Onboard SDK which allows receiving data as ros topics and publish commands by subscribing to ROS services. &#8230; <a href=\"https:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/algorithms\/\" class=\"more-link text-uppercase small\"><strong>Continue Reading<\/strong> <i class=\"fa fa-angle-double-right\" aria-hidden=\"true\"><\/i><\/a><\/p>\n","protected":false},"author":107,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-645","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-json\/wp\/v2\/pages\/645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-json\/wp\/v2\/users\/107"}],"replies":[{"embeddable":true,"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-json\/wp\/v2\/comments?post=645"}],"version-history":[{"count":5,"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-json\/wp\/v2\/pages\/645\/revisions"}],"predecessor-version":[{"id":768,"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-json\/wp\/v2\/pages\/645\/revisions\/768"}],"wp:attachment":[{"href":"https:\/\/mrsdprojects.ri.cmu.edu\/2017teamc\/wp-json\/wp\/v2\/media?parent=645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}