<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Steven Daniluk on Medium]]></title>
        <description><![CDATA[Stories by Steven Daniluk on Medium]]></description>
        <link>https://medium.com/@stevendaniluk?source=rss-424bfd69478b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MTmOoXIXNbnMnNmS-AQ-gg.jpeg</url>
            <title>Stories by Steven Daniluk on Medium</title>
            <link>https://medium.com/@stevendaniluk?source=rss-424bfd69478b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 21:11:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stevendaniluk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Ghost IV — Sensor Fusion: Encoders + IMU]]></title>
            <link>https://medium.com/hackernoon/ghost-iv-sensor-fusion-encoders-imu-c099dd40a7b?source=rss-424bfd69478b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c099dd40a7b</guid>
            <category><![CDATA[autonomous-cars]]></category>
            <category><![CDATA[self-driving-cars]]></category>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[racing]]></category>
            <category><![CDATA[arduino]]></category>
            <dc:creator><![CDATA[Steven Daniluk]]></dc:creator>
            <pubDate>Sun, 12 Mar 2017 14:34:40 GMT</pubDate>
            <atom:updated>2019-05-18T03:37:59.874Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rNBbVCqXfG8h0cyNzjaRRA.jpeg" /></figure><p>This is the fourth story in a series <a href="https://hackernoon.com/tagged/documenting">documenting</a> my plan to make an autonomous RC race car. The first three stories can be found here:</p><p><a href="https://medium.com/@stevendaniluk/ghost-my-plan-to-race-an-autonomous-rc-car-46a4b7f093cd">Ghost — My Plan To Race An Autonomous RC Car</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-ii-controlling-an-rc-car-with-a-computer-b1d1849d9e43">Ghost II — Controlling An RC Car With A Computer</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-iii-dead-reckoning-navigation-ffd6fd4de1cf">Ghost III — Dead Reckoning Navigation</a></p><p>The last story introduced the idea of sensor fusion in state estimation. Where you have some state that you want to estimate, such as the position of a car in the world, and you have a number of sensors providing partial information about your state that you want to fuse together into a single, more accurate estimate. I had made the analogy to how humans move by using a combination of vision, our vestibular system, and muscle memory, which all contribute to a single accurate estimation of where we are. Below is the wonderful illustration I made for each of these components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*qFZrM7q36zEfCk4wtWgKnQ.jpeg" /></figure><p>Why is sensor fusion necessary? It is partly due to the fact that typically no single sensor provides everything that we want to know (or at least not very well). But, it is also due to different sensors having different characteristics, some of which are more desirable than others. A GPS can give an absolute position, but it will have a low update rate, and is subject to discrete jumps. On the other hand, an inertial measurement unit (IMU) can update extremely quickly, but when you try to integrate acceleration over time to obtain position, the errors in doing so grow without bounds over time. What we want is the best of both worlds, hence sensor fusion.</p><p>For this project, I’ll be implementing sensor fusion to improve the odometry estimation with encoders from the last story, by combining it with data from an IMU. But first, I’ll take a moment to provide some details on how this actually works. There are a few different approaches to sensor fusion, such as a probabilistic method, or fuzzy logic. I’ll explain how the probabilistic approach works since that is what I am using, and I feel it is the most intuitive.</p><p>First off, you need to think in terms of probability distributions. When you consider your own location right now, your true position may be at coordinates X and Y. But, that true position is not generally known. So instead, we consider a distribution of probability values for each position in the world, where the probabilities of the positions near your true positions should be high. Below is an example, where the X-axis could be your position in some direction, and the Y-axis the probabiity of being in that position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*grsOi-FHXfFYio-P9I-qUA.jpeg" /><figcaption>What a probability distribution might look like for position (X axis) [Source: Probabilistic Robotics — Dieter Fox, Sebastian Thrun, and Wolfram Burgard]</figcaption></figure><p>The same applies to how you move, and the observations you make. Each observation (i.e. sensor reading) will be of the form of a probability distribution, and so will each motion you make. We combine these probabilities together to try and form a more accurate estimate. Exactly like basing your opinion off of multiple sources.</p><p>Probability distributions are very useful, because instead of just a single measurement value, they can also contain the uncertainty associated with that measurement. For things like sensor measurements, or predicted motion, we don’t always know exactly what that probability distribution will look like, as it is typically quite complex. But, we can make some assumptions and form a model of what we think it should be like. Take a look at the picture below. This is a depiction of a potential model for the probability distribution of a distance measurement with a laser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*8XHRm311BJ_IbZHZw-Fn5Q.jpeg" /><figcaption>Example of a probability distribution for distance measurements from a laser range, where z-t represents the expected measurement, and z-max represents the maximum range [Source: Probabilistic Robotics — Dieter Fox, Sebastian Thrun, and Wolfram Burgard]</figcaption></figure><p>Starting from the left you have some probability attributed to really short readings, such as when something obstructs the laser’s path. Then you have the peak representing what you expect the measurement to actually be. At the far right end you have some probability allotted to the laser returning the maximum range. In addition, all of this is supplemented with a little bit of probability spread over every possible reading to account for pure random measurements. Seems like a fairly reasonable model for what you would expect from a measurement with a laser. The same would be done for any other sensors or information you want to incorporate into your estimate.</p><p>Now that we have some understanding of probability distributions and their importance, let’s get back to the problem. In english, the question that we are trying to solve is: what is the probability that I am here, given that I performed all these motions, and made all of these observations? In mathematical terms this idea can be expressed by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*h37CrRYKCdThHtUzc2fYdg.jpeg" /></figure><p>Which translates to the probability of the current state, conditioned on all the previous observations, and all the previous controls. The above probability distribution can be estimated with a Bayes Filter, which is represented by the equations below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*DZgMN3Kk52UBfoPIPemmoA.jpeg" /></figure><p>I’m not going to go deep into the Bayes filter, there are enough textbooks on that (an excellent one being <em>Probabilistic Robots</em> by Dieter Fox, Sebastian Thrun, and Wolfram Burgard, specifically Chapter 2 for the Bayes filter). I’m merely showing this formulation to illustrate that it is conveniently composed of three parts: the estimated distribution from the previous time step, the control update, and the measurement update. The previous distribution is where we thought we were one time step ago, the control update is where we think we are now based only on how we moved, and the measurement update is the likelihood of receiving the measurements we did, given where we think we are. This means that we have a recursive formulation for updating the current state, which depends on the state from the previous time step, the control that was executed, and the measurements that were observed.</p><p>Below is an example of how probability distributions for an initial state estimate and a measurement can be combined. The measurement differs slightly from the initial state, but it is much more concentrated about one point. The result is that the post measurement update more closely resembles the actual measurement, because it had more certainty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*VG797L4pN5vQL0nevm-MRw.jpeg" /></figure><p>The next obvious question is how do we actually obtain each of those probability distributions needed for the Bayes filter? Well, since the true distributions are likely to be very complex, as an engineer you would do what engineers to best: make some assumptions to develop an approximation. In the laser example I showed one possible set of approximations. A different set of approximations you could make are that every prediction (state, control, and measurement) are subject to white (purely random) noise, and that each distribution can be modelled as a Gaussian distribution. The Gaussian distribution is the Bell Curve that most people are familiar with. When you make these assumptions the math becomes very nice, and you are left with something called a Kalman filter.</p><p>The Kalman filter is one of the most popular state estimation <a href="https://hackernoon.com/tagged/tools">tools</a>, and you’ll see it applied in GPS receivers, aircraft, and even the navigation computer for the Apollo missions, which spawned its development. There are of course variations of the Kalman Filter, such as the Extended Kalman Filter, the Unscented Kalman, and the information filter, as well as whole other sets of approximations that could have been made instead which would lead to different methods like the particle filter. Each variation makes different assumptions, and is suitable for different applications. This could go on forever, but the point is that there are a lot of different approaches to this problem. Anyways, back to the actual purpose of presenting all of this information: to combine the odometry data with IMU data.</p><p>So, the end goal is to predict the car’s position and orientation, as well as the linear and angular velocities. First, the car needs an IMU. I’ve got a <em>Phidgets</em> IMU, which I’ve mounted on the very front of the car. The IMU also has a magnetometer, but the car’s electric motor will produce an electric field that causes distortion, so I want it as far away as possible. I also made some new mounts to for the Arduino and the onboard computer, so I’ll go ahead and show those off as well. The car is basically a brick of batteries and electronics at this point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KoVLZNpO70GIIcAZMey6NQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hDEdyBmCEqy-fvwe8_wU-Q.jpeg" /></figure><p>From the wheel encoder measurements I can measure the linear and angular velocities. The IMU that I am using provides linear acceleration, angular velocity, and magnetic heading. To fuse these measurements together I’ll be using an Extended Kalman filter, which differs from the standard Kalman filter in the assumptions made about the control update.</p><p>The most difficult part about implementing a Kalman filter is tuning it. Remember how I said the Kalman filter comes from assuming all the distributions are Gaussian distributions (the Bell curve)? Well, two parameters define that curve: the mean and the variance. The mean indicates the centre of the curve, for measurements this would simply be the reported value. The variance is an indication of how spread out the values typically are, and for a sensor it can often be obtained from the data sheet. The Kalman filter has many of these parameters called covariance values, which govern the measurement and control updates. Properly tuning the covariances is crucial to the filter’s performance, and it can be a bit tricky to do so. If I were to set all the covariance values for the IMU to be very large, and all the covariance values for the encoder measurements to be very small, this would indicate that the IMU data is not trustworthy (very spread out from the true value), while the encoder measurements are trustworthy (all very close to the true value). The result would be that the filter would ignore the IMU, and listen almost exclusively to the encoder measurements. If the encoder measurements actually are more accurate than the IMU, then this is alright. But if it is the opposite, then the estimate of the filter will be inaccurate, because it is biasing it’s predictions with the wrong data. The point I am trying to make is that these parameters are important, and need to be tuned properly. Because you are essentially deciding how much you want to trust each step measurement and each step of the update.</p><p>Last story I ended with showing the path of the car estimated only from the encoder measurements, and the estimate became very inaccurate when I drove quickly. So, I decided to repeat that test with the IMU data fused in as well. Check out the video below to watch the car’s estimated position as it moves. This is the same path as the last test, which was about 100m long, and the car is moving at 3–5 m/s (11–18km/h) on smooth tile floor. The video is in real time, I didn’t speed it up at all. The green line is the fused position estimate, while the red line is the position estimate from only the encoders.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgxrPhmSzbsA%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgxrPhmSzbsA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FgxrPhmSzbsA%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6704d54df328c22504a77ae40400f48e/href">https://medium.com/media/6704d54df328c22504a77ae40400f48e/href</a></iframe><p>Looks much better! This time the position error at the end of the 100 m long lap was just 0.23 m, compared to 10.91 m when only encoder measurements were used. What this means is that when the car is moving quickly, and the wheels are likely sliding a small amount on the smooth floor, the filter is able to use the IMU data to keep the state estimate from diverging.</p><p>An important point to make is that the current state estimate is entirely relative. There is no absolute measurements being incorporated, such as a reference to some feature in the world, or a GPS signal. As a result the errors will grow without bounds over time, just like trying to walk with your eyes closed. So, I need some form of global referenced. A camera will be mounted to the car to achieve exactly that, and next story I’ll explain how I do it.</p><p>If you are interested in the code, checkout the <a href="https://github.com/stevendaniluk/ghost">Github repo here</a>. Or for the previous stories, you can find them below.</p><p><a href="https://medium.com/@stevendaniluk/ghost-my-plan-to-race-an-autonomous-rc-car-46a4b7f093cd">Ghost — My Plan To Race An Autonomous RC Car</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-ii-controlling-an-rc-car-with-a-computer-b1d1849d9e43">Ghost II — Controlling An RC Car With A Computer</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-iii-dead-reckoning-navigation-ffd6fd4de1cf">Ghost III — Dead Reckoning Navigation</a></p><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c099dd40a7b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/ghost-iv-sensor-fusion-encoders-imu-c099dd40a7b">Ghost IV — Sensor Fusion: Encoders + IMU</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ghost III — Dead Reckoning Navigation]]></title>
            <link>https://medium.com/hackernoon/ghost-iii-dead-reckoning-navigation-ffd6fd4de1cf?source=rss-424bfd69478b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffd6fd4de1cf</guid>
            <category><![CDATA[autonomous-cars]]></category>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[racing]]></category>
            <category><![CDATA[self-driving-cars]]></category>
            <category><![CDATA[robotics]]></category>
            <dc:creator><![CDATA[Steven Daniluk]]></dc:creator>
            <pubDate>Thu, 23 Feb 2017 15:18:18 GMT</pubDate>
            <atom:updated>2019-05-18T03:38:01.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OQaHFtxq-6yHHFnKSC72aw.jpeg" /></figure><p>This is the third story in a series documenting the development of an autonomous RC race car. You can find out the earlier stories here:</p><p><a href="https://medium.com/@stevendaniluk/ghost-my-plan-to-race-an-autonomous-rc-car-46a4b7f093cd">Ghost — My Plan To Race An Autonomous RC Car</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-ii-controlling-an-rc-car-with-a-computer-b1d1849d9e43">Ghost II — Controlling An RC Car With A Computer</a></p><p>With an autonomous <a href="https://hackernoon.com/tagged/race">race</a> car, there are two main problems you need solve: “<em>Where am I?</em>” and “<em>What should I do?</em>”. The “<em>What should I do?</em>” deals with the control of the car, and can only be answered once you know something about where the car is, so that will come later. The “<em>Where am I?</em>” is what I’ll be diving into today.</p><p>You might think this is a trivial problem. Your smartphone knows where you are all the time by using GPS, so how is this any different? Well, I’ll expand a bit on what this question entails. For a system, such as an autonomous car, or even an airplane, we typically describe it by something called a state, comprised of state variables. For this car, the state variables would be the position coordinates in some reference frame, X and Y, the orientation in that frame (yaw angle), the velocities in each direction, and rate of change of the orientation (yaw rate). You could of course include other information such as roll, pitch, or acceleration if they are relevant to the application, but for this project those six variables will suffice to describe the car.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*y3MBOP0RikUpacGC25_PUA.jpeg" /></figure><p>Generally, no single sensor provides all the information required to completely define your state (at least not very well). To overcome this, we do something called sensor fusion, which fuses together sensory data from multiple sources to form a single estimate.</p><p>The way we perceive and control our bodies is a great example of sensor fusion at work, and provides the perfect analogy for how I’ll be solving the “<em>Where am I?</em>” question. There is of course a lot happening when we perceive and control our bodies, so this will obviously be a simplification, but there are three central components that I’ll bring up. The first is sight: through our eyes we perceive our surroundings, both through appearance and spatially. The second is our vestibular system: the sensory system located in our ears that can detect linear acceleration and rotational movements. The third is what we commonly call muscle memory: the ability to consistently perform bodily motions with a high level of accuracy.</p><p>If you were to try to answer the “<em>Where you are</em>?” question using only one of these, it likely wouldn’t work very well. Your sight would perform the best, but even that can be deceived at times. Think of looking out the window of a stationary car and seeing the car beside pull away in the opposite direction. I’m sure we’ve all had momentary lapses where we thought it was us moving when it really wasn’t. The vestibular system detecting linear and angular acceleration wouldn’t do very well on its own either. Imagine closing your eyes while someone carries you away, and try to keep track of your position. You may be accurate in the short term, but over time the error will continuously accumulate, and pretty soon your estimate will be way off. Finally, our muscle memory would also perform poorly. Consider closing your eyes and trying to walk to a specific spot 100 meters away. Although you can perform walking motions with great accuracy from a lifetime of practice, you will still make small deviations from your predicted motion, and those errors accumulate over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*qFZrM7q36zEfCk4wtWgKnQ.jpeg" /></figure><p>Yet when we combine our sight, vestibular system, and muscle memory, we can coordinate our bodily motion very well. Our muscle memory predicts how a motion will move our body, which then gets updated with our vestibular system and sight to form a more accurate prediction. That can then can be used to more accurately update our motion, which will again get updated with our vestibular system and sight, and so on.</p><p>A car can operate in a similar fashion. Sight can be emulated with a camera, detecting features and geometry from the surroundings to be compared with a map or previous observations. The vestibular system is essentially an Inertial Measurement Unit (IMU), which is a combination of accelerometers for measuring acceleration and gyroscopes for measuring angular rotation. The muscle memory can be emulated with a mathematical model of how the vehicle moves for a specific steering angle and number of wheel rotations.</p><p>How you combine information from each of these sources is actually very interesting, but I’ll cover that in a <a href="https://hackernoon.com/tagged/future">future</a> post once I’ve presented how I’m actually getting at least two of these sources of information.</p><p>The first one I’ll talk about is the muscle memory case, which is called odometry estimation in the robotics world. The general idea is that if you can count how many times each wheel rotates, and if you know some geometry about your vehicle, you can calculate how the vehicle will move.</p><p>You start by making a few assumptions: that the vehicle moves along an arc of constant radius and at constant speed, and that there is no slip at the wheels (i.e. no spinning). If you measure wheel rotation at a high enough frequency then the constant speed and radius assumption will be valid for the brief period between measurements when you perform this calculation. The no slip assumption however does not hold as well. The faster the car goes, the more invalid that assumption will be. But remember, this is only one estimate that is going to be fused with others. You can quickly go down a rabbit hole trying to account for everything, so it is best to keep it simple until additional complexity is necessary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*KpzP7jFPR7NuXnx6F6QTJw.jpeg" /></figure><p>With a bit of math (which doesn’t belong here) applied to the graphic above, you can figure out the vehicle velocity and yaw rate based on the wheel rotations and steering angle. From there you simply integrate that change over time between updates to determine the change in position and orientation.</p><p>An important point to make is that the error with this method is unbounded. Meaning, each prediction made will contain some error, which will get added to the error of the next prediction, and the next one after that. This is called drift, and it’s exactly what happens when you close your eyes and walk. Unless you have some global reference to update your estimate with, that error continuously accumulates. That is why odometry is often referred to as dead-reckoning, and needs to be fused with other estimates to be accurate.</p><p>Wheel rotations can be measured with a sensor called an encoder. There are a variety of types available, but I’ll be using one of the simpler types: an optical encode. Basically you have an infrared emitter and detector facing each other, and a disc with a pattern of holes rotating in between them. The path between the emitter and detector gets interrupted as the disc rotates, so you can track the disc rotations by monitoring the output signal of the detector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ki3QM99-k5xblz5k50YE4Q.jpeg" /></figure><p>I’ve 3D printed my own encoder discs to mount on the drive cups of the front and rear differentials, as well as mounts to hold the encoders in place. With this setup I’m able to detect 1/24th of a wheel rotation, which corresponds to ~8mm of movement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uzy7ueUielnMPUzmjPgiqw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ZC74bFrtAx6f8pbiRuFJA.jpeg" /></figure><p>Steering angle will come from mapping the executed control published by the onboard Arduino to the physical angle of the wheel. Cars have something called Ackermann steering geometry, which positions the wheels at slightly different angles to account for the fact that the inside wheel travels less distance than the outside wheel. Instead of accounting for these slight angle differences, I simply assume the steering angle is the average of the inner and outer wheel. There is some error in this assumption, but it is negligible unless you are making a very tight turn.</p><p>The equations that govern this process rely on two measurements from the vehicle: the wheel diameter, and the track width. I can of course measure these, but they won’t be accurate. Tires compress by a small amount, and wheel camber angle (when the wheel leans inwards or outward from the car) will alter the track width.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*NElYEXWSXDV8txdYSMUORQ.jpeg" /><figcaption>(Left) The effective wheel radius as a result of tire compression, (Right) A depiction of Ackermann steering geometry [Wikipedia Commons]</figcaption></figure><p>This means that those measurements need to be calibrated from actual data. Every car or mobile robot will have to do this for odometry estimation. The simplest way to calibrate these measurements is to perform two maneuvers: a purely straight motion, and purely rotational motion. The math works out so that the wheel diameter only influences the purely straight motion, allowing you to solve for the effective wheel diameter by counting the number of wheel rotations over a measured distance. The rotational motion depends on both wheel diameter and track width. But once you’ve calibrated the wheel diameter, you can calibrate the track width by drive in circles a fixed number of times and counting the wheel revolutions.</p><p>After repeating a 7.62m (25 ft) straight line test 5 times, and driving in three CW and three CCW circles, my measured wheel diameter had to be increase by 3.2%, while the track width had to be decreased by 8.3%. Over a long distance it is quite clear that a small error in those measurements could result in very different predictions.</p><p>To test everything I drove the car around a building at my university, going around a few hallways to make a big “T” shaped lap ending at the same position as the beginning of the lap. The path from odometry estimation is shown below. The total distance was ~100 meters and involved ~ 720 degrees of rotation. To my pleasant surprise the error between the start and end points was only 0.27 meters, with an orientation error of 9 degrees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*qUCQ16LlhXiVLK3I_1tqwg.png" /><figcaption>Estimated path from dead reckoning while driving slowly</figcaption></figure><p>That’s not too bad for just dead reckoning. However, this was all done with the car moving quite slowly. Remember how earlier I mention that assumption about ignoring wheel slip becomes less valid as speed increases? Well, below is what happens when you drive the same route, but much more aggressively. I was averaging about 3–5 m/s (11–18km/h) on smooth tile floors, and as you can see the odometry estimate is way off. This is basically like trying to run on ice with your eyes closed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*ujfjTRN68h_ghUk3PlUk4Q.png" /><figcaption>Dead reckoning while driving quickly</figcaption></figure><p>How can that error be corrected? Well, that will be the subject of the next story. I’ll add an IMU to the car, and discuss method of sensor fusion to produce a single more accurate estimate that should (hopefully) make the high speed estimation as accurate as the low speed estimation.</p><p>You can find the Github repo for this project <a href="https://github.com/stevendaniluk/ghost">here</a>, and the rest of the stories in this series below.</p><p><a href="https://medium.com/@stevendaniluk/ghost-my-plan-to-race-an-autonomous-rc-car-46a4b7f093cd">Ghost — My Plan To Race An Autonomous RC Car</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-ii-controlling-an-rc-car-with-a-computer-b1d1849d9e43">Ghost II — Controlling An RC Car With A Computer</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-iv-sensor-fusion-encoders-imu-c099dd40a7b">Ghost IV — Sensor Fusion: Encoders + IMU</a></p><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffd6fd4de1cf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/ghost-iii-dead-reckoning-navigation-ffd6fd4de1cf">Ghost III — Dead Reckoning Navigation</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ghost II — Controlling An RC Car With A Computer]]></title>
            <link>https://medium.com/hackernoon/ghost-ii-controlling-an-rc-car-with-a-computer-b1d1849d9e43?source=rss-424bfd69478b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1d1849d9e43</guid>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[racing]]></category>
            <category><![CDATA[autonomous-cars]]></category>
            <category><![CDATA[self-driving-cars]]></category>
            <category><![CDATA[robotics]]></category>
            <dc:creator><![CDATA[Steven Daniluk]]></dc:creator>
            <pubDate>Sat, 28 Jan 2017 18:53:08 GMT</pubDate>
            <atom:updated>2019-05-18T03:38:01.285Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b51SxAd7Vyh9bYjhyVufew.jpeg" /></figure><p>This is the second story in a series documenting my project to <a href="https://hackernoon.com/tagged/autonomously">autonomously</a> <a href="https://hackernoon.com/tagged/race">race</a> an RC car. The first story gave a brief<strong> </strong>introduction and outline for this project, which you can read <a href="https://medium.com/@stevendaniluk/ghost-my-plan-to-race-an-autonomous-rc-car-46a4b7f093cd#.pliizrev6">here</a>.</p><p>If you’re going to build an autonomous car, an obvious requirement is that you need to be able to control the onboard computer (OBC), and the OBC handling all the autonomy has to actually be able to control the car. That’s what I’ll be talking about today.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8yBeTA6riDf-Sb_ylqHVEw.jpeg" /><figcaption>The laptop, the car, and the OBC</figcaption></figure><p>The goals of this stage are as follows:</p><ol><li>Communication between the OBC and a laptop</li><li>Send commands from the OBC to the steering servo and motor ESC</li><li>Ability to override OBC commands with the remote control at any time</li><li>Monitor the executed servo and ESC commands with the OBC for data recording purposes</li></ol><p>Before diving in, a quick note about software. Both the OBC, and the laptop are running Ubuntu 14.04, and have ROS Indigo installed. <a href="http://www.ros.org/about-ros/">ROS</a> stands for Robot Operating System, and<strong> </strong>is a framework for developing robotic systems that provides tools and conventions for many of the common elements of a robotic system. If you’re not familiar with ROS, don’t worry. But a quick explanation about a few terms I’ll be using throughout these stories will help:</p><p><strong>Nodes</strong>: Each computation process happening on a computer is called a node, and there will be many of these.</p><p><strong>Topics</strong>: Communication between nodes is done through topics, which provide the name for what the data is, as well as a message containing the data itself.</p><p><strong>Publishers and Subscribers</strong>: For a topic containing data to exist, a node needs to be publishing it, and in order for a node to receive information on a topic, they need to subscribe to it.</p><p>Onto the first goal: Communication between the OBC and the laptop. Although all the processing will be happening on the OBC, I’ll still need to be able to monitor what is happening from the laptop, and I’ll need to do so wirelessly. This means setting up an ad hoc network (think wifi, but instead of everything going through a router, two or more computers connect directly to each other). Fortunately ad hoc networks are fairly straightforward to setup, so not much to report here. To make things more convenient, I’ve added a script on the OBC to execute on startup that will automatically create the network. On the laptop I simply select the newly created ad hoc network like I would any other wifi network. Also, as a back up, I’ve setup an ethernet network, so that I can always login to the OBC with my laptop and an ethernet cable.</p><p>Goals 2–4 involve sending commands to the car’s steering servo and ESC, as well as monitoring the commands from the transmitter. The way an RC car works is on the transmitter you have a throttle trigger, steering wheel, and buttons, and the transmitter sends those controls to a receiver on the car. For a car, there will 2 or 3 channels of data being transmitted: one for steering, one for throttle, and an optional third channel sometimes used to activate reverse or some other function. The receiver converts the controls it receives to pulse width modulation (PWM) signals, which are then sent to the steering servo and the motor ESC. A PWM signal is essentially a series of on and off pulses. The position of a servo (or the percent of throttle for an ESC) is determined by the width (i.e. the duration) of the pulse received.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*JJeAXp1nAbbrxHxNq8FEYg.jpeg" /><figcaption>How the transmitter controls get to the servo and ESC</figcaption></figure><p>Therefore, two things need to be accomplished: the first is that I need to be able to send those PWM signals to the steering servo and ESC, and the second is that I need to be able to monitor the commands from the transmitter. On my transmitter, I’ve set a push button to act as the third channel for activating control override. So, in addition to monitoring the steering and throttle commands, I’ll also need to detect when that button is pressed.</p><p>An easy way to send and detect those PWM signals is with a microcontroller, such as the Arduino Nano that I’ll be using. How this will look is shown below. The transmitter will send commands to the receiver, which will be connected to the microcontroller so that it can monitor the incoming commands. When the microcontroller detects that override is active (i.e. that the third channel button has been pressed), the transmitter commands will be forwarded to the steering servo and ESC. When override is not active, the microcontroller will generate the PWM signals for the commands it receives from the OBC. With this setup the transmitter will always have priority over the OBC. Even if the OBC crashes, as long as the microcontroller has power, the transmitter will be able to control the car. Safety first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*zoAOJVc9jEYUOYXZ7rRlTA.jpeg" /><figcaption>Flow of controls to the servo and ESC</figcaption></figure><p>Arduino has a nice servo library available, where you give it an integer between 0–255, and it generates the appropriate PWM signal. To measure PWM signals, interrupts on the microcontroller can be used, which detect when a signal going into one of its pins changes between high and low. Timing the length of that pulse will then identify what the command is. Also, ROS has a protocol for serial communication as well as libraries to support ROS functionality on Arduino devices called <a href="http://wiki.ros.org/rosserial_arduino"><em>rosserial_arduino</em></a><em>.</em> All of which means the servo, ESC, Arduino, and the OBC, should play nice together.</p><p>The first step is to connect the microcontroller, steering servo, ESC, and receiver together. I’ve put some pin headers on a prototype board to provide connections for everything, and wired it underneath to connect to the microcontroller. For the pins, from right to left we have: 3 pins for ESC out (Vss, ground, and signal), 3 pins for steering out (Vss, ground, and signal), override signal from the receiver, throttle signal from the receiver, steering signal from the receiver, then the final two are the supply voltage and ground to the receiver. You may notice there is one extra pin, and also a transistor underneath the prototype board. The purpose of those will be discussed in the next story.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vgOOxujXrOhAivA4AKBpeQ.jpeg" /><figcaption>Servo and ESC connections for the Arduino Nano</figcaption></figure><p>As mentioned above, there are ROS libraries and serial communication for Arduino devices. However, there is a considerable amount of overhead when using these libraries and sending/receiving messages via topics over serial. Furthermore, a small board like the Nano does not have much memory or processing power. This means that any processing the microcontroller does, and any serial communication, should be limited as much as possible.</p><p>With this in mind, I’ve divided the controls processing as follows:</p><ul><li>Any node wishing to control the car must publish messages on the <em>cmd_car</em> topic with steering and throttle values in the range [-1, 1]</li><li>The <em>car_command_converter</em> node will run on the OBC, converting <em>cmd_car</em> messages to/from <em>cmd_arduino</em> messages in the range [0, 255] which the arduino servo library expects, as well as handling any fallback behaviour</li><li>The <em>arduino_controller</em> node will use the <em>cmd_arduino</em> messages to generate the PWM signals for the steering servo and ESC, monitor the commands from the receiver, and publish the executed commands on the <em>cmd_arduino_executed</em> topic</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*aO0q0gS2WW2yfGp5NWycpQ.jpeg" /><figcaption>Node structure, and on what hardware each node is operating</figcaption></figure><p>With this configuration, the arduino has a minimal amount of processing and data to transfer. Messages being exchanged with the arduino are small, only two 8-bit integers for the throttle and steering values, and one boolean value for the override flag. The <em>car_command_converter</em> node is then responsible for publishing and subscribing to the larger messages with floating point values, and attaching time stamps to these messages.</p><p>I won’t walk through any of the code for these nodes, otherwise this would turn into a novel. But, if you are interested you can view the full code for these nodes (and everything else completed thus far) on <a href="https://github.com/stevendaniluk/ghost">GitHub</a>.</p><p>After testing to verify all the nodes are operating properly, all the hardware can be mounted on the car. An old 4s lipo battery to power the OBC and a piece of acrylic to serve as a platform is all that’s needed for the car to be mobile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vjqOrykXCgTsy_Vj67puJA.jpeg" /></figure><p>Later on once I have the IMU and camera integrated I’ll invest the time to package everything nicely. But for now, everything works!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fp_bDEOr7JYk%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dp_bDEOr7JYk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fp_bDEOr7JYk%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/092f09f9c35f653881e19b69238010f8/href">https://medium.com/media/092f09f9c35f653881e19b69238010f8/href</a></iframe><p>Now that the preliminary work to setup the controls is out of the way, the next phase will begin the autonomy work. A big part of being autonomous is knowing where you are, and figuring that out will be the subject of the next story. I’ll give some background on the localization problem in robotics, and explain (one of the ways) I’ll be using to estimate the car’s position.</p><p>If you are interested in the code, checkout the <a href="https://github.com/stevendaniluk/ghost">Github repo</a>. Or for the previous stories, you can find them here:</p><p><a href="https://medium.com/@stevendaniluk/ghost-my-plan-to-race-an-autonomous-rc-car-46a4b7f093cd">Ghost — My Plan To Race An Autonomous RC Car</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-iii-dead-reckoning-navigation-ffd6fd4de1cf">Ghost III — Dead Reckoning Navigation</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-iv-sensor-fusion-encoders-imu-c099dd40a7b">Ghost IV — Sensor Fusion: Encoders + IMU</a></p><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1d1849d9e43" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/ghost-ii-controlling-an-rc-car-with-a-computer-b1d1849d9e43">Ghost II — Controlling An RC Car With A Computer</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ghost — My Plan To Race An Autonomous RC Car]]></title>
            <link>https://medium.com/hackernoon/ghost-my-plan-to-race-an-autonomous-rc-car-46a4b7f093cd?source=rss-424bfd69478b------2</link>
            <guid isPermaLink="false">https://medium.com/p/46a4b7f093cd</guid>
            <category><![CDATA[autonomous-cars]]></category>
            <category><![CDATA[racing]]></category>
            <category><![CDATA[self-driving-cars]]></category>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[projects]]></category>
            <dc:creator><![CDATA[Steven Daniluk]]></dc:creator>
            <pubDate>Sun, 15 Jan 2017 02:49:11 GMT</pubDate>
            <atom:updated>2019-05-18T03:38:01.703Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yy7HjK6nmlY0lTNtSwdiyw.jpeg" /><figcaption><a href="http://roborace.com/">RoboRace</a> DevBot (The autonomous race car that my RC car aspires to be)</figcaption></figure><p>I’ve decided to make an RC car race autonomously.</p><p>The general idea is that I’m going to take an RC car (e.g. below left), attach a small computer and some sensors to it, and enable it to drive around a track (e.g. below right) without any human controls. Should be pretty straightforward…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*SWxzKnWl-Sj4G468i7omYg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*KCCI5vpHiP1xSJB9g6XpyA.jpeg" /></figure><p>The goal here isn’t just to make the car move around the track slowly either. The challenge that I am more interested in is to push the limits of my autonomy knowledge to see how fast I can make it drive, and eventually start working on <a href="https://hackernoon.com/tagged/racing">racing</a> lines and improving lap times. When an autonomous car, or robot, is moving quickly, the task of <a href="https://hackernoon.com/tagged/determining">determining</a> where you are, planning where to go, and controlling the car in real time is quite challenging. But that’s what makes this so interesting!</p><p>I suppose an important question would be: why am I doing this? Firstly, most of my life has revolved around RC cars, racing, and robotics, which makes this project the perfect combination of all my hobbies. Secondly, projects are one of the best ways to learn new skills and expand your knowledge. You can spend all the time in the world studying how to do something, but it will never be as rewarding as actually bringing it to life.</p><p>I should mention that this project is very much inspired by the activity from <a href="http://roborace.com/">RoboRace</a>, the <a href="http://selfracingcars.com/">Self Racing Cars</a> group in the U.S., the <a href="http://selfdrivingtrackdays.com/">Self Driving Track Days</a> group in Europe, and the <a href="http://f1tenth.org/">F1/10 Autonomous Racing Competition</a>. The racing and robotics world are both full of talented and passionate people, and it’s very exciting that they are finally mixing! I’m currently doing my master’s in aerospace engineering, and afterwards my goal is to be working on something like what RoboRace is doing. So, I’m essentially creating my own scaled down version of that, which I hope will act as a stepping stone towards working on the real thing.</p><p>Also, I’ve named this little project <em>Ghost</em>. When I initially thought of making one of my RC’s autonomous, I basically wanted to make something that I could follow on the track, just like the “ghost” feature in most racing video games. The name stuck, so that’s what it will be called.</p><p>The stories that I will be posting here are intended for tech-savy people who would like a behind-the-scenes look on how autonomy works, as well as hobbyists who would like to read a <em>somewhat</em>-step-by-step guide. I will divide the stories into sub tasks of the project, such determining the car’s position on the track, and always start off with a bit of the (high level) theory before diving into the details. I have actually already been working on some portions of this project, but am only now starting to write about it. That being said, some posts will come together quicker than others, however I will aim for a new post every ~2 weeks.</p><p>Now, onto the plan.</p><p><strong>Project Outline</strong></p><p>Before beginning, there were a few assumptions and restrictions I made. This project is ambitious enough to begin with, so I need to choose my battles carefully.</p><p>The first assumption is that there will be no other cars or obstacles in the way. Attempting to understand other cars and their intentions to overtake them, while minimizing time lost, could easily turn into a PhD thesis (or a few). It is best to go one step at a time. The second assumption is that a map of the track is available before hand. There are cool techniques such as Simultaneous Localization and Mapping (SLAM) to create a map while you move around. However, I can’t justify spending too much time on something that will only need to be done once per track. Especially something that can easily be replicated by a human (in potentially less time when you factor in any post-processing necessary).</p><p>The one restriction that I have placed on the design is that vision (i.e. cameras) must be used for external perception about the environment, as opposed to lidar (or any other means). The tracks this car would drive on may not always have the track boundaries defined by walls of some form, they may simply be markings on the ground. In which case lidar be of little use. Plus, the lidar sensors that I would need are simply too expensive for me (over $1,000). There are inexpensive units such as <a href="http://www.slamtec.com/en/lidar">RPLidar</a> (which I have used and quite liked), but it only generates scans of the surroundings at 5–10 Hz. A 10 Hz update when moving at 10 m/s (36 km/h) results in one reading per meter of movement, which is quite large considering the track is only 2–3 meters wide. Alternatively, cameras can provide 30–100 frames per second for a few hundred dollars quite easily.</p><p>With any autonomous system, it is good to start with an architecture in mind. An architecture is essentially how you decompose the system into smaller subsystems, and how those subsystems relate to each other. Below is a fairly standard architecture for an autonomous robot, but it helps illustrate how the task will be divided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*ZAZ7FH6MbwGZgx-tDNLeBA.jpeg" /><figcaption>Architecture for how the RC car will drive itself</figcaption></figure><p>The Trajectory Generator is responsible to creating a racing line around the track given the layout of the track. External Perception determines some geometry about the world from a sensor, such as a camera or lidar unit, while Odometry Estimation predicts how the car is moving (e.g. counting wheel rotations). Data from External Perception and Odometry Estimation will then get fused together (a future post will discuss what data fusion is and how it is done) and compared against the track map in the Localization module to estimate where the car is on the track. Finally, Path Tracking Controller will look at the car’s position and issue the appropriate throttle and steering commands that will make the car follow the desired line.</p><p>There you have it, that’s the basic idea for how the RC car will drive itself. Next, a few words about implementation.</p><p><strong>Hardware</strong></p><p>The car that I’ll be using is a Kyosho TF-5 Stallion 1/10 scale on-road car. I spent many years racing RC’s, a few of which I got to drive for Kyosho America. This is a car I used for practice during the winter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*3jMJD0HCCXOosm50pG8yVA.png" /></figure><p>In terms of sensory and computational hardware, I’ll be using the following:</p><ul><li>Intel NUC Computer</li><li>Arduino Nano Microcontroller</li><li>Phidgets Spatial 3/3/3 IMU</li><li>PointGrey Blackfly Camera</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F7qYkupYMO31Rlp-CXsSJw.jpeg" /><figcaption>Clockwise from top left: Intel NUC, Arduino micro controller, IMU, and the PointGrey camera</figcaption></figure><p>Alternative hardware can of course be used, but I already had most of these items from previous projects. I may even end up changing components, or adding more as I go. All of the sensors, as well as the car’s servo and motor ESC (Electronic Speed Control), will be connected to the NUC where all the processing will be done. In future posts, when each piece of hardware is introduced I’ll go into more detail about it, the setup, etc.</p><p><strong>Software</strong></p><p>I will be developing this entirely in ROS, as well as using OpenCV, and potentially even TensorFlow later on (I’ve been itching to play with that some more). Those of you who would like to look at the code or follow along can do so at my GitHub account: <a href="https://github.com/stevendaniluk/ghost">stevendaniluk/ghost</a>.</p><p>This wraps up the introduction. Stay posted for the next update where I will get the computer talking to the car to send controls. Then we’ll me moving onto the really interesting stuff…</p><p>You can find the rest of the stories in this series here:</p><p><a href="https://medium.com/@stevendaniluk/ghost-ii-controlling-an-rc-car-with-a-computer-b1d1849d9e43">Ghost II — Controlling An RC Car With A Computer</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-iii-dead-reckoning-navigation-ffd6fd4de1cf">Ghost III — Dead Reckoning Navigation</a></p><p><a href="https://medium.com/@stevendaniluk/ghost-iv-sensor-fusion-encoders-imu-c099dd40a7b">Ghost IV — Sensor Fusion: Encoders + IMU</a></p><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46a4b7f093cd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/ghost-my-plan-to-race-an-autonomous-rc-car-46a4b7f093cd">Ghost — My Plan To Race An Autonomous RC Car</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>