{"id":8291,"date":"2017-01-20T09:00:01","date_gmt":"2017-01-20T14:00:01","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=8291"},"modified":"2017-01-20T08:35:15","modified_gmt":"2017-01-20T13:35:15","slug":"lego-mindstorms-ev3-bike-project","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2017\/01\/20\/lego-mindstorms-ev3-bike-project\/","title":{"rendered":"Lego Mindstorms EV3 Bike Project"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\n   <introduction><\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>&#8216;s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/58-routh-m\">Lego Mindstorms EV3 Bike Project<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3168356\">Michele Basso<\/a> and a team of students at University of Florence.\n      <\/p>\n<p>   <\/introduction><\/p>\n<p>This submission contains the work done for a senior design project to build a Lego motorcycle and control it.  The authors<br \/>\n      have provided:\n   <\/p>\n<div>\n<ul>\n<li>Simulink simulation model, including 3d animation!<\/li>\n<li>Simulink model that is connected to the Lego<\/li>\n<li>Lego hardware design steps<\/li>\n<li>MATLAB script to generate parameters used by the models<\/li>\n<li>Report and presentation covering the project<\/li>\n<\/ul><\/div>\n<p>They&#8217;ve also provided a very nice <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/58-routh-m-lego-mindstorms-ev3-bike-project\">overview video<\/a>.  In it, one of the authors describes the hardware design, and discusses how Simulink was used to design the controller.\n   <\/p>\n<p>Because there is a simulation-only model, those of us without the hardware can run it and see the behavior with the 3d animation.<br \/>\n       Note: <a href=\"https:\/\/www.mathworks.com\/products\/3d-animation.html\">Simulink 3d Animation<\/a> required.\n   <\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainLegoBike\/legobikesim.png\"> <\/p>\n<p>The simulation is set up to stream data to <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/simulation-data-inspector-overview.html\">Simulink Data Inspector<\/a> so you can compare simulation runs and see the design choices they made.\n   <\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainLegoBike\/legobikesdi.png\"> <\/p>\n<p>My only point of feedback would be to use <a href=\"https:\/\/www.mathworks.com\/products\/stateflow.html\">Stateflow<\/a> for the switching logic for calibration\/control\/stopping.  Right now, the model is keeping track of time itself with an integrator, implementing a bunch of logic to check which state is current, and then enabling the correct subsystem. This strategy doesn&#8217;t scale well and could easily yield bugs if the logic allows multiple states to be active at the same time.  I&#8217;ve highlighted it below with the purple area and will send MathWorks swag to whoever emails me (<i>first.last@mathworks.com<\/i>) or posts a link to a working version of this model using a Stateflow chart that gives identical results.\n   <\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainLegoBike\/legobikestatelogic.png\"> <\/p>\n<h3>Comments<a name=\"2\"><\/a><\/h3>\n<p>Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=8291#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/58-routh-m#comments\">comment<\/a> for Michele and the team at University of Florence.\n   <\/p>\n<p><script language=\"JavaScript\">\n<!--\n\n    function grabCode_b88572b9d1524380acfe1dc5c8cad90e() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='b88572b9d1524380acfe1dc5c8cad90e ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' b88572b9d1524380acfe1dc5c8cad90e';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Sean de Wolski';\n        copyright = 'Copyright 2016 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }   \n      \n-->\n<\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><a href=\"javascript:grabCode_b88572b9d1524380acfe1dc5c8cad90e()\"><span style=\"font-size: x-small;        font-style: italic;\">Get<br \/>\n            the MATLAB code<br \/>\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>      Published with MATLAB&reg; R2017a<\/p>\n<\/div>\n<p><!--\nb88572b9d1524380acfe1dc5c8cad90e ##### SOURCE BEGIN #####\n%% Lego Mindstorms EV3 Bike Project\n%\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s pick this week is\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/58-routh-m Lego Mindstorms EV3 Bike Project> by\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3168356 Michele Basso>.\n% \n\n%% \n% This submission contains the work done for a senior design project to\n% build a Lego motorcycle and control it.  The authors have provided:\n%\n% * Simulink simulation model, including 3d animation!\n% * Simulink model that is connected to the Lego\n% * Lego hardware design steps\n% * MATLAB script to generate parameters used by the models\n% * Report and presentation covering the project\n%\n% They've also provided an\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/58-routh-m-lego-mindstorms-ev3-bike-project\n% overview video>.  The video is really well done.  She goes over the\n% hardware design, and how Simulink was used to design the controller.\n%\n% Because there is a simulation-only model, those of us without the\n% hardware can run it and see the behavior with the 3d animation.  Note:\n% <https:\/\/www.mathworks.com\/products\/3d-animation.html Simulink 3d Animation> required.\n%\n% <<legobikesim.png>>\n%\n% The simulation is set up to stream data to\n% <https:\/\/www.mathworks.com\/help\/simulink\/ug\/simulation-data-inspector-overview.html\n% Simulink Data Inspector> so you can compare simulation runs and see the\n% design choices they made.\n%\n% <<legobikesdi.png>>\n%\n% My only point of feedback would be to use\n% <https:\/\/www.mathworks.com\/products\/stateflow.html Stateflow> for the\n% switching logic for calibration\/control\/stopping.  Right now, the model\n% is keeping track of time itself with an integrator, implementing a bunch\n% of logic to check which state is current, and then enabling the correct\n% subsystem. This strategy doesn't scale well and could easily yield bugs\n% if the logic allows multiple states to be active at the same time.  I've\n% highlighted it below with the purple area and will send MathWorks swag to\n% whoever emails me ( _first.last@mathworks.com_ ) or posts a link to a working\n% version of this model using a Stateflow chart that gives identical\n% results.\n%\n% <<legobikestatelogic.png>>\n\n%% Comments\n% \n% Give it a try and let us know what you think\n% <https:\/\/blogs.mathworks.com\/pick\/?p=8291#respond here> or leave a\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/58-routh-m#comments\n% comment> for Michele and the team at University of Florence.\n%\n \n\n##### SOURCE END ##### b88572b9d1524380acfe1dc5c8cad90e\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainLegoBike\/legobikesim.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>Sean&#8216;s pick this week is Lego Mindstorms EV3 Bike Project by Michele Basso and a team of students at University of Florence.<\/p>\n<p>This submission contains the work done for a senior&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2017\/01\/20\/lego-mindstorms-ev3-bike-project\/\">read more >><\/a><\/p>\n","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8291"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=8291"}],"version-history":[{"count":6,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8291\/revisions"}],"predecessor-version":[{"id":8298,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8291\/revisions\/8298"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=8291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=8291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=8291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}