{"id":78,"date":"2013-05-10T14:07:53","date_gmt":"2013-05-10T14:07:53","guid":{"rendered":"http:\/\/cto.dyalog.com\/?p=78"},"modified":"2014-02-17T09:54:37","modified_gmt":"2014-02-17T09:54:37","slug":"driving-my-pi","status":"publish","type":"post","link":"https:\/\/www.dyalog.com\/blog\/2013\/05\/driving-my-pi\/","title":{"rendered":"Driving my Pi"},"content":{"rendered":"<p>Back from the APL meeting in Hamburg, where my C3Pi made it&#8217;s first appearance on German soil (and a few days meeting with APL users in Milan). I&#8217;ve extended the control program which was used to\u00a0make last week&#8217;s\u00a0<a title=\"C3Pi doing a Figure 8\" href=\"http:\/\/www.youtube.com\/watch?feature=player_embedded&amp;v=5UvPouq2c7M\">figure 8 video<\/a>\u00a0to give me some &#8220;hand controls&#8221;. I do appreciate that it is inadvisable for humans to control motor vehicles directly, but in the privacy of my own home I have risked a little careful driving:<\/p>\n<iframe loading=\"lazy\"  id=\"_ytid_92362\"  width=\"584\" height=\"329\"  data-origwidth=\"584\" data-origheight=\"329\"  src=\"https:\/\/www.youtube.com\/embed\/5KZxaXbsTIk?enablejsapi=1&autoplay=0&cc_load_policy=0&iv_load_policy=1&loop=0&modestbranding=0&rel=1&fs=1&playsinline=0&autohide=2&theme=dark&color=red&controls=1&\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  allow=\"autoplay; encrypted-media\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe>\n<h2>The APL Code<\/h2>\n<p>You can see the latest code at <a title=\"The APLBot GitHub Repository\" href=\"https:\/\/github.com\/APLPi\/APLBot\" target=\"_blank\">https:\/\/github.com\/APLPi\/APLBot<\/a>. However, beware that significant changes will be made next week &#8211; both to the APL code and the Arduino \/ I2C interface layers. We will be adding support for our first sensor &#8211; an Infra-Red sensor that will allow us to measure the distance to the nearest obstacle (in front of the &#8216;bot) &#8211; and this requires some extensions.<\/p>\n<p>The APL code currently consists of three files: I2C.dyalog, DyaBot.dyalog and DrivePi.dyalog. These need to be placed in the same folder on your C3Pi.<\/p>\n<p>The I2C.dyalog file relies on the library lib2c-com.so, which will be installed along with Dyalog APL for the Pi when this becomes available.<\/p>\n<p>The final piece of the puzzle is the control program for the Arduino. That&#8217;s in <a title=\"Arduino\/I2C Command Interpreter on GitHub\" href=\"https:\/\/github.com\/APLPi\/ArduinoComm\" target=\"_blank\">APLPi\/I2CArduinoComm<\/a>. Install it by following the relevant part of <a title=\"How to build a C3Pi with Dyalog APL on it, Part 1\" href=\"http:\/\/www.jasonrivers.co.uk\/2013\/04\/using-dyalog-apl-and-a-raspberry-pi-to-drive-a-robot-part-1-hardware\/\" target=\"_blank\">Jason&#8217;s instructions on building your own C3Pi<\/a>.<\/p>\n<p>The three APL code files implement the following layers:<\/p>\n<p><strong>I2C:<\/strong>\u00a0A namespace which loads libi2-com.so and makes four interface functions available in the active workspace. Strictly speaking, this file belongs in the libi2c-com repo, and will move there when I have time to co-ordinate rewriting some test cases with Liam.<\/p>\n<p><strong>DyaBot:<\/strong> A class, built upon I2C, which allows APL applications to control the robot by setting a field named &#8220;Speed&#8221; to a 2-element vector containing values between \u00af100 (full reverse) and 100 (full speed ahead) for each of the 2 wheels.<\/p>\n<p><strong>DrivePi:<\/strong> A namespace, built upon DyaBot, containing a function Run which provides a very simple &#8220;game interface&#8221; for driving the C3Pi, and a function Play which accepts 3-column matrices of (Right Wheel Speed, Left Wheel Speed, Duration) records, which are &#8220;played back&#8221;.<\/p>\n<h2>What next?<\/h2>\n<p>The ultimate goal of our project is to write some code which allows the C3Pi to perform <a title=\"SLAM - Wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/Simultaneous_localization_and_mapping\" target=\"_blank\">Simultaneous Localization and Mapping (SLAM)<\/a>: The robot should be able to examine its surroundings, build a map, and accept high-level instructions to move from point to point, avoiding obstructions. As mentioned above, we&#8217;ll be addding the first collision-avoidance sensor next week. Once that is done, I&#8217;ll be back to discuss the other sensors that we are planning to add to the C3Pi in the coming weeks. I hope that some of you will join us in building your own robots and helping write the software!<\/p>\n<h2><\/h2>\n","protected":false},"excerpt":{"rendered":"<p>Back from the APL meeting in Hamburg, where my C3Pi made it&#8217;s first appearance on German soil (and a few days meeting with APL users in Milan). I&#8217;ve extended the control program which was used to\u00a0make last week&#8217;s\u00a0figure 8 video\u00a0to &hellip; <a href=\"https:\/\/www.dyalog.com\/blog\/2013\/05\/driving-my-pi\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,9,5],"tags":[],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-cto","category-raspberry-pi","category-robots"],"_links":{"self":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/comments?post=78"}],"version-history":[{"count":31,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":412,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/78\/revisions\/412"}],"wp:attachment":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/media?parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/categories?post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/tags?post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}