{"id":1022,"date":"2021-03-08T14:55:54","date_gmt":"2021-03-08T14:55:54","guid":{"rendered":"http:\/\/www.igfasouza.com\/blog\/?p=1022"},"modified":"2021-04-26T14:35:09","modified_gmt":"2021-04-26T13:35:09","slug":"connected-vehicles-self-driving-cars-with-kafka","status":"publish","type":"post","link":"http:\/\/www.igfasouza.com\/blog\/connected-vehicles-self-driving-cars-with-kafka\/","title":{"rendered":"Connected vehicles &#038; Self-driving cars with Kafka"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/ankicar1.jpg\" alt=\"\" class=\"alignnone size-full wp-image-1023\" width=\"666\" height=\"298\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/ankicar1.jpg 666w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/ankicar1-300x134.jpg 300w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/ankicar1-624x279.jpg 624w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/p>\n<p><b>How\u2019s the form?<\/b><br \/>\n<small style=\"color:#9f9f9f\">2021\/03\/08<\/small><\/p>\n<p>The term connected vehicles refer to applications, services, and technologies that connect a vehicle to its surroundings. A connected vehicle includes the different communication devices (embedded or portable) present in the vehicle, that enable in-car connectivity with other devices present in the vehicle and\/or enable connection of the vehicle to external devices, networks, applications, and services.<\/p>\n<p>Self-driving cars are vehicles capable of sensing their environment and operating without human involvement.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/Connected-Vehicles_ktDePriK.jpg\" alt=\"\" class=\"alignnone size-full wp-image-1024\" width=\"620\" height=\"413\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/Connected-Vehicles_ktDePriK.jpg 620w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/Connected-Vehicles_ktDePriK-300x200.jpg 300w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/p>\n<p>So today I want to show a simple demo where I can stream car data in real-time using Kafka. Because I don\u2019t have a real autonomous car and came with the idea to use Anki Car or Anki Overdrive.<\/p>\n<p>Anki Overdrive is an intelligent battle racing system that lets you explore the power of artificial intelligence (AI). You can see a nice overview, <a href=\"https:\/\/www.pocket-lint.com\/parenting\/buyers-guides\/132703-anki-overdrive-vs-anki-drive-all-the-new-features-explained\" rel=\"noopener\" target=\"_blank\">all the new features explained<\/a>.<\/p>\n<p>All naming rights for Anki, Anki Drive and Anki Overdrive are property of Anki.<\/p>\n<p>With the standard Anki Overdrive Kit, you get two cars, some road pieces to construct simple road maps and a charging platform for the cars. It is all you need to start playing around with.<br \/>\nCheck the <a href=\"https:\/\/github.com\/anki\/drive-sdk\" rel=\"noopener\" target=\"_blank\">driver-sdk<\/a>.<\/p>\n<p>Using a Bluetooth Low Energy (BLE) API you can connect and disconnect from Anki, change some settings and of course you can get some real-time information.<\/p>\n<p>I found this <a href=\"https:\/\/github.com\/jacopotagliabue\/anki-drive-python-sdk\" rel=\"noopener\" target=\"_blank\">anki-drive-python-sdk<\/a> that uses Python and node to get the real-time data using BLE<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/end_flow.jpg\" alt=\"\" class=\"alignnone size-full wp-image-1025\" width=\"500\" height=\"144\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/end_flow.jpg 500w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/end_flow-300x86.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<p>Here is the info that I can get.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/anki_data.jpg\" alt=\"\" class=\"alignnone size-full wp-image-1026\" width=\"670\" height=\"458\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/anki_data.jpg 670w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/anki_data-300x205.jpg 300w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/anki_data-624x427.jpg 624w\" sizes=\"auto, (max-width: 670px) 100vw, 670px\" \/><\/p>\n<p><b>JSON<\/b><\/p>\n<div class=\"codecolorer-container java blackboard\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"java codecolorer\"><span class=\"br0\">&#123;<\/span><span class=\"st0\">'location'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">17<\/span>, <span class=\"st0\">'piece'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">36<\/span>, <span class=\"st0\">'offset'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">67.5<\/span>, <span class=\"st0\">'speed'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">390<\/span>, <span class=\"st0\">'self_speed'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">400<\/span>, <span class=\"st0\">'clockwise'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">7<\/span>, <span class=\"st0\">'notification_time'<\/span><span class=\"sy0\">:<\/span> datetime.<span class=\"me1\">datetime<\/span><span class=\"br0\">&#40;<\/span><span class=\"nu0\">2018<\/span>, <span class=\"nu0\">8<\/span>, <span class=\"nu0\">25<\/span>, <span class=\"nu0\">21<\/span>, <span class=\"nu0\">9<\/span>, <span class=\"nu0\">33<\/span>, <span class=\"nu0\">359248<\/span><span class=\"br0\">&#41;<\/span>, <span class=\"st0\">'is_clockwise'<\/span><span class=\"sy0\">:<\/span> <span class=\"kw2\">False<\/span><span class=\"br0\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<div class=\"codecolorer-container java blackboard\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"java codecolorer\">&nbsp;<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<div class=\"codecolorer-container java blackboard\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"java codecolorer\"><span class=\"br0\">&#123;<\/span><span class=\"st0\">'location'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">23<\/span>, <span class=\"st0\">'piece'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">57<\/span>, <span class=\"st0\">'offset'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">67.5<\/span>, <span class=\"st0\">'speed'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">422<\/span>, <span class=\"st0\">'self_speed'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">400<\/span>, <span class=\"st0\">'clockwise'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">71<\/span>, <span class=\"st0\">'notification_time'<\/span><span class=\"sy0\">:<\/span> datetime.<span class=\"me1\">datetime<\/span><span class=\"br0\">&#40;<\/span><span class=\"nu0\">2018<\/span>, <span class=\"nu0\">8<\/span>, <span class=\"nu0\">25<\/span>, <span class=\"nu0\">21<\/span>, <span class=\"nu0\">9<\/span>, <span class=\"nu0\">32<\/span>, <span class=\"nu0\">229689<\/span><span class=\"br0\">&#41;<\/span>, <span class=\"st0\">'is_clockwise'<\/span><span class=\"sy0\">:<\/span> <span class=\"kw2\">True<\/span><span class=\"br0\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Piece uniquely identify the type of road piece (curve, start, stop, intersection, straight), speed is the speed recorded by the vehicle, self_speed is the \u201ctheoretical\u201d speed as set by our command, offset identifies the \u201clane\u201d (see a visual explanation below), and the location is an incremental integer (see a visual explanation below).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/offset.jpg\" alt=\"\" class=\"alignnone size-full wp-image-1027\" width=\"273\" height=\"316\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/offset.jpg 273w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/offset-259x300.jpg 259w\" sizes=\"auto, (max-width: 273px) 100vw, 273px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/start_lanes.jpg\" alt=\"\" class=\"alignnone size-full wp-image-1028\" width=\"275\" height=\"283\"><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/track-1024x468.png\" alt=\"\" class=\"alignnone size-large wp-image-1029\" width=\"625\" height=\"286\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/track-1024x468.png 1024w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/track-300x137.png 300w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/track-768x351.png 768w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/track-624x285.png 624w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/track.png 1389w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<h2>Idea<\/h2>\n<p>A simple Raspberry PI demo where I can get the Anki Car data in real-time and send it to Kafka. I can explore the data after with some graphics or some data analyses.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/dIz7iWXGLeU\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\" width=\"560\" height=\"315\" frameborder=\"0\"><\/iframe><\/p>\n<p>You can check the \u201ccreate_track_image.py\u201d and create your track map.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/track-segments.png\" alt=\"\" class=\"alignnone size-full wp-image-1030\" width=\"450\" height=\"270\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/track-segments.png 450w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/track-segments-300x180.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/circuit01.jpeg\" alt=\"\" class=\"alignnone size-full wp-image-1031\" width=\"960\" height=\"540\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/circuit01.jpeg 960w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/circuit01-300x169.jpeg 300w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/circuit01-768x432.jpeg 768w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/circuit01-624x351.jpeg 624w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/p>\n<p>With the map you can start thinking in some analyses, E.g, can I make the car go faster? I can do some analyses in my track and determine where the car can speed up and where should slow down,<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/circuit02.jpeg\" alt=\"\" class=\"alignnone size-full wp-image-1032\" width=\"960\" height=\"540\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/circuit02.jpeg 960w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/circuit02-300x169.jpeg 300w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/circuit02-768x432.jpeg 768w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/circuit02-624x351.jpeg 624w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/p>\n<p>You can buy an extra Anki Collision Kit, which includes an intersection and try to create a Collision Prevention Algorithm.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/anki_x-1024x950.jpg\" alt=\"\" class=\"alignnone size-large wp-image-1033\" width=\"625\" height=\"580\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/anki_x-1024x950.jpg 1024w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/anki_x-300x278.jpg 300w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/anki_x-768x712.jpg 768w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/anki_x-624x579.jpg 624w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/anki_x.jpg 1500w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>Now we have a basic, but functional setup to run experiments and collect data from our small cars, but there are indeed a lot of interesting data questions we could try to answer.<\/p>\n<ul>\n<li>\nhow can a vehicle learn the best \u201cdriving policy\u201d given a track configuration?<\/li>\n<li>\nWhat will change when we introduce other vehicles? We could, for example, have them compete against each other, or we could use the second vehicle to learn cooperative behavior (e.g. avoid collision).<\/li>\n<li>\nCan we add Traffic Light. Unfortunately I don&#8217;t have this <a href=\"https:\/\/thepihut.com\/collections\/raspberry-pi-led-hats\/products\/pi-stop-educational-traffic-light-for-raspberry-pi\" rel=\"noopener\" target=\"_blank\">hat<\/a>.<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/traffic_light.jpg\" alt=\"\" class=\"alignnone size-full wp-image-1035\" width=\"397\" height=\"416\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/traffic_light.jpg 397w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2021\/03\/traffic_light-286x300.jpg 286w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/p>\n<li>\nCan we condition the learning process on variables other than the track configuration?<\/li>\n<li>\nHow smart can the vehicle be with the current sensors? As we saw already with position, sensors are pretty basic and won\u2019t allow a fine-grained control: what can we do to be smarter with what we have (e.g. interpolate position?) and what can we easily add to give us more dimensions to play with (e.g. webcam with object recognition)?<\/li>\n<li>\nAnki Overdrive has the Supertrucks as well. What can we do differently with the truck?<\/li>\n<\/ul>\n<p>And many more, this is not an exhaustive list.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/zmsRCsTw6Js\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\" width=\"560\" height=\"315\" frameborder=\"0\"><\/iframe><\/p>\n<h2>Similar ideas<\/h2>\n<p><a href=\"https:\/\/github.com\/AnkInnovator\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/AnkInnovator<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/IBM\/object-detection-anki-overdrive-cars\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/IBM\/object-detection-anki-overdrive-cars<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/opcau\/opcau.github.io\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/opcau\/opcau.github.io<\/a><\/p>\n<h2>Link<\/h2>\n<p><a href=\"https:\/\/site.ieee.org\/connected-vehicles\/ieee-connected-vechicles\/connected-vehicles\/\" rel=\"noopener\" target=\"_blank\">https:\/\/site.ieee.org\/connected-vehicles\/ieee-connected-vechicles\/connected-vehicles\/<\/a><\/p>\n<p><a href=\"https:\/\/www.digi.com\/blog\/post\/what-is-connected-vehicle-technology-and-use-cases\" rel=\"noopener\" target=\"_blank\">https:\/\/www.digi.com\/blog\/post\/what-is-connected-vehicle-technology-and-use-cases<\/a><\/p>\n<p><a href=\"https:\/\/www.synopsys.com\/automotive\/what-is-autonomous-car.html\" rel=\"noopener\" target=\"_blank\">https:\/\/www.synopsys.com\/automotive\/what-is-autonomous-car.html<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/anki\/drive-sdk\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/anki\/drive-sdk<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/jacopotagliabue\/anki-drive-python-sdk\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/jacopotagliabue\/anki-drive-python-sdk<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How\u2019s the form? 2021\/03\/08 The term connected vehicles refer to applications, services, and technologies that connect a vehicle to its surroundings. A connected vehicle includes the different communication devices (embedded or portable) present in the vehicle, that enable in-car connectivity&hellip; <a href=\"http:\/\/www.igfasouza.com\/blog\/connected-vehicles-self-driving-cars-with-kafka\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1024,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,24],"tags":[7,13],"class_list":["post-1022","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kafka","category-raspberry-pi","tag-kafka","tag-raspberry-pi"],"_links":{"self":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts\/1022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/comments?post=1022"}],"version-history":[{"count":6,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts\/1022\/revisions"}],"predecessor-version":[{"id":1113,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts\/1022\/revisions\/1113"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/media\/1024"}],"wp:attachment":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/media?parent=1022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/categories?post=1022"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/tags?post=1022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}