loading

This Instructable will guide you through the building of Alice, the path following vehicle.

It consists of an Android application and an inexpensive miniature vehicle, that you can build using common parts found online or at your local electronics shop.

Alice, was built during the DIT524 course in the University of Gothenburg by the first year students Kai Salmon, Martina Freiholtz, Tobias Lindell, Rachele Mello and Linhang Nie. I was supervising them and provided them with the hardware platform and two Arduino libraries ([1], [2]), which enabled them to easily work with it.

They built a system, that allows the user to draw a path directly on the phone's screen and then the vehicle to follow it. Their product, is a proof of concept, which could be utilized to dynamically draw a path over a predetermined area, in a user friendly way, for a robot or a vehicle to follow the sketched route and possibly execute some tasks. Some real life cases where this could be used, include a factory floor or a warehouse, where a robot should move to a specific location, pick something and move it to another spot. Alternatively, another use case could involve the system in an emergency situation, where a robot would be tasked to visit specific locations and deliver supplies or provide assistance.

Before moving on to the specifics, check this demo video out.

Step 1: Building the Car - Hardware

In order to build, or rather assemble, the car you will need the following components:

  1. Car chassis (you can find the ones displayed here, on Ebay or AliExpress, by searching for "smart robot car")
  2. Two (or four) DC motors
  3. Wheels (for easiness, buy a kit that contains all the above)
  4. Arduino Mega
  5. L293D motor shield (used to be made by Adafruit, but now you can find them sold by Chinese resellers)
  6. L3G4200D Gyroscope (used in order to rotate the car at specific degrees)
  7. Speed encoders (this or this will suit the car kit I suggested above)
  8. HC-SR04 ultrasonic sensor (used in order to detect obstacles in the front of the vehicle)
  9. HC-06 Bluetooth module (used to communicate with the Android phone)
  10. Battery pack (we use a 12 Volt one, with 8 AA batteries)

Of course you do not have to use these specific components. I am just mentioning the ones found on "Alice" and with which, the software referenced here should work mostly out of the box. The cost of "Alice" is approximately 40$ if everything is bought from China.

Refer to the schema in order to understand how the various connections are made.

In brief, the motors get attached to the motor shield as does the battery pack. The gyroscope gets connected to the I2C bus and don't forget to connect the SD0 pin to the 5V. Connect the wheel encoder to pin 19 (or any other pin that supports external interrupt) and the Bluetooth module to a Serial port (RX to TX and TX to RX). Finally, connect the ultrasonic sensor to any two input pins.

Step 2: Building the Car - Software - Arduino

The Arduino Mega, found on the path following vehicle, runs the Arduino sketch found here. After the user draws a path, it receives all the necessary commands and stores them in a custom made buffer, where each command is executed sequentially.

If an obstacle is found, then the vehicle stops and sends back to the Android phone, the index of the command that was being executed, while the obstacle was met. Therefore, the application can determine and visualize, where on the path the obstacle was encountered.

In order to run this sketch, you have to download and install two Arduino libraries. The Smartcar Core and the Smartcar Sensors. If you do not know how to do this, check this out.
Also, take a look in the Wikis of the two libraries. You will find extensive information regarding their usage and especially how to apply them in different settings, i.e. if you are not using exactly the same components as we did.

Ultimately, you should be able to make the car rotate clockwise by 90 degrees, by typing alice.rotateClockwise(90) or instruct it to travel 100 centimeters to the front with alice.goForward(100).

Step 3: Building the Car - Software - Android

The Android application used to draw the path and send the instructions to the vehicle, via Bluetooth, can be found here.

You can download the already built APK that I have attached below. However since you generally should NOT install APK's from unknown sources over the internet, I strongly advise you to download the source, review it, then build it yourselves and install it.

You can do that by cloning the repository, or just downloading it as a .zip file. Then, import it in Android Studio or whatever IDE you are using. The application has just one dependency, the appcompat library, which you might have if you are already working with Android. Don't worry about this anyway, if you are missing it, you can easily install it through the IDE after being notified of its absence.

The Android application is composed of three screens.

  1. The path drawer, which is the application's backbone, where the user is able to draw the path on the screen, connect to the vehicle, send the instructions, drive it manually or access the settings menu. You will get notified if the vehicle has met an obstacle, so you can either change the course, order it to continue if the "threat" is not valid or even drive it manually to avoid the obstruction.
  2. The settings menu, where the user can define various parameters such as the sensitivity of how the path is drawn or the size of the actual area where the robot should drive. Moreover, you can choose to add a picture to draw the path over. In this case, this picture could be the blueprints of a floor, or a map of an area in which you want to navigate your vehicle.
  3. The manual control window, where the user can steer the car manually, using a joystick.

Step 4: That's About It!

It wasn't so hard, was it? Now all you have to do is try it out and why not, try to improve things! I believe this concept has the potential to be used in a non hobbyist environment, in order to improve or even save lives.

I did not provide extensive details on how to build the vehicle, since you should not feel confined in using the exact one we did. If you have any questions regarding the assembly or programming, do not hesitate to leave a comment below.

<p>In this project normal bluetooth joystick mode working perfectly.But path drawing part is not working correctly.</p><p>I want to know is it an issue in the android app or is it my fault.Thank you</p>
<p>Its path following features cannot work out of the box, as every car will be different. Can you describe what doesn't work?</p>
<p>hi Dimitris,</p><p>I want to install your app on my phone but after android .apk file installation, it has a problem.</p><p>when I click on connect, the app gives error and exits.</p><p>what's the reason? May I have your path car's app that can be installed on android phone.</p><p>thanks </p>
<p>There can be too many reasons for an error. I'd need more information, such as, is the Bluetooth turned on and has it paired with the device already (outside the app)?</p>
<p>hi Dimitris,</p><p>yes the Bluetooth is turned on outside the app and has paired with the phone.</p>
<p>This is the error pic, no matter the device has paired or not, and Bluetooth </p><p>is turned on or not, anyway when I click on connect in the app,this error message appears.</p>
<p>This error unfortunately does not give much to go on. I would suggest that you try to compile the application yourself and see what is the error exactly!</p>
<p>hello Dimitris, </p><p>really great job!</p><p>I'm trying to make it work by using the new motorshield version (v2.3).</p><p>i get errors when using the new motorshield library. </p><p>So i think i should edit your libraries to make them compatitive.</p><p>Any suggestions / tips ?</p>
<p>Hi Drougni,<br><br>From what I see, the new motorshield from Adafruit works via I2C. You could in theory edit my (old) libraries, but I would suggest that you use Adafruit's library for moving the car.<br><br>For the rest (rotating with the gyroscope and traveling specific distances with the speed encoders) I would suggest my newest library (<a href="https://github.com/platisd/smartcar_shield" rel="nofollow">Smartcar shield</a>), which works in a very similar (and improved) way.</p>
<p>thx u for the reply,</p><p>i will follow your advice!</p>
<p>what is the purpose speed encoder here? can anyone please explain it to me? I am having trouble with this one. </p>
It is used to calculate the distance that is travelled by the vehicle.
<p><strong>Can I complete this project without speed <br>encoder?</strong> In my area it's not available and I am beginner also. Can you <br>tell me what I can do instead using speed encoder please?</p><p><strong>Thanks in Advance</strong></p>
Hmmm, as the speed encoder measures distances it is crucial for the general functionality of the vehicle.<br><br>A work around would be to experimentally determine how much time the car needs to move X centimeters. Therefore when the car needs to move 50 centimeters, instead of using the encoder to get the travelled distance you would move the car for a specified amount of time.
Hi Dimitris,<br>Everything works perfectly now...!!!<br>Thanks a lot<br>I send you a mail via your website about the followings ideas i got about this project.<br>
I maybe found the problem:<br>on the arduino codes comes many time the word &quot;int&quot; in the path following mode (see under)<br>but &quot;int&quot; on the gyroscope is connected nowhere..<br> <br><br>//path following mode <br>void autoMode(){<br> <br> alice.setAutomationRotationSpeed(100);<br> <br> if(Serial2.available() &gt; 0){ <br> <br> //initialize a queue as accommodation<br> int arraylength = Serial2.readStringUntil('!').toInt();<br> String queue[arraylength];<br> int k = 0;<br> <br> //store instructions in array<br> while(k if(Serial2.available() &gt; 0){<br> queue[k] = Serial2.readStringUntil('*');<br> k++;<br> }<br> }<br> <br> //intepret and excute instructions<br> for(index = 0; index <br> //intrpret <br> String instr = &quot;&quot;;<br> String parameter = &quot;&quot;;<br> boolean spaceFound = false;<br> <br> for(int j = 0; j if(queue[index].charAt(j)==' '){<br> spaceFound = true;<br> }else if(spaceFound){<br> parameter += queue[index].charAt(j);<br> }else{<br> instr += queue[index].charAt(j);<br> }<br> }<br> <br> //excute<br> int value = parameter.toInt();<br> <br> if(instr.equals(&quot;goForward&quot;)){<br> goForwardSafe(value);<br> }else if(instr==&quot;rotateClockwise&quot;){<br> alice.rotateClockwise(value);<br> }else if(instr==&quot;rotateCounterClockwise&quot;){<br> alice.rotateCounterClockwise(value);<br> }<br> }<br> }<br>}<br>
<p>I am not sure what you mean. Keep in mind that this is the code that the people who made this projects had, so there aren't any huge or obvious mistakes in the code. In other words, do not try to find mistakes in the code, but instead try to understand and debug it.</p>
man I think i understood:<br>the speed encoder is the odometer and actually an IR sensor:<br>I should place it over by that small black dish at the back of the wheel.<br>How stupid of me...
<p>Oh yes, you should place the encoder disk as well.</p>
Hi Dimitris,<br>Good nieuws, when i was reading the code I saw that the pins for the sonar was not connected as the sketch:<br><br>Sonar sonar;<br>const int trig_pin = 43;<br>const int echo_pin = 42;<br><br>Now the sonar is working on the path mode, <br>what still not working is that: on path mode ,the car goes only straight on and never go left or right. If I understand good, the trouble is the gyroscope right? on the tuto you wrote:<br>The gyroscope gets connected to the I2C bus and don't forget to connect the SD0 pin to the 5V.<br><br>I connect the gyroscope SDA to the mega2560 SDA20<br>I connect the gyroscope SCL to the mega2560 SCL21<br>SD0, and VCC are connected to mega2560 VCC<br>further CS, DR, and INT are not connected.<br><br>is this correct?<br><br><br>
<p>Hi, yes, your connections seem correct. Can you try to have it printing out just the displacement? There is an example sketch for that somewhere, either in the wiki or inside the library (https://github.com/platisd/smartcar_sensors/wiki/Example-sketches#gyroscope) . Also, you might need to change the value here: https://github.com/platisd/smartcar_sensors/blob/master/Smartcar_sensors.h#L67 depending on the offset value of your gyroscope. But try running the sketch before doing that and i will guide you through.</p>
<p>I finally understood what means you mean with print out and and the codes to try. Hereunder the result</p><h3>Sonar</h3><p>When i put my hand by the sensor the<br>numbers goes up</p><p>0</p><p>0</p><p>3</p><p>2</p><h3>Sharp_IR</h3><p>I dont know what i should do</p><p>numbers start at </p><p>28</p><p>29</p><p>and goes until 43 and comes a long list<br>of 43</p><h3>Gyroscope</h3><p>When i move the car </p><p>numners goes up and down</p><p>0</p><p>0</p><p>0</p><p>-5</p><p>-5</p><p>3</p><p>1</p><h3>Odometer</h3><p>I don't have an odometer, so far i know..</p><p>it only does:</p><p>0</p><p>0</p><p>0</p><p>0</p><p>0</p>
<p>Hi,<br><br>The odometer is the wheel encoder and according to your drawing you have one. If it doesn't work, then the behavior you see makes sense. But anyway, let's not spam here more, can you send me a private message with your email address?</p>
here is the link from pastebin:<br><br>http://pastebin.com/R5Cfdz22<br><br>should i use this zipfile for the sensors or that one? <br><br>http://pastebin.com/WKQ29WLq<br><br>
<p>Hi I mean, what is the code you are using or trying to use? In order for everything to work the following components must work and you should verify they do so properly:<br><br>1. Motors<br>2. Gyroscope<br>3. Ultrasonic sensors<br>4. Wheel encoders</p>
<p>The Ultrasonic sensors doesn't work properly. I believe that the Smartcar_sensors library doesn't work. </p>
<p>Hi,</p><p>All the libraries that are mentioned in this article work properly. This project was done using them and not much has been changed since then with them. Being &quot;deprecated&quot; just means that they are not maintained or actively developed at the moment, since they have been replaced by another library.<br><br>Please look over the example sketches here: <a href="https://github.com/platisd/smartcar_sensors/wiki/Example-sketches" rel="nofollow">https://github.com/platisd/smartcar_sensors/wiki/E...</a><br><br>After you have made sure the connections are correct, you should be able to get data both from the Gyroscope and the ultrasonic sensors.</p>
<p>actually following component does not work:</p><p>2. Gyroscope<br>3. Ultrasonic sensors</p><p>both are using the Smartcar_ sensor library.</p>
OK , I suppose I first should better understand that Android Studio<br>I unzip SmartCar-master, I open it with Android studio, I see a lots of maps whose looking like the HTML construction maps of a website. I can found the source (src) under Android/App/Src/Main . but when I look in Android/Android.iml , I can see a lot of linked codes (some kind of menu for the program)<br>Now I believe I should export it as an APK to install it on my phone. Export Settings , the program want to export as a jar and not apk.<br>I suppose I gonna google further now how to learn Android studio. just one question and I let you enjoy life, Which maps are important for the app ? Smartcar-master contain a lot of maps that apparently are not necessary for the app (like handmade sketches that I found between) Is it the Android map who should become the APK? Maybe It's a little difficult for my 1st arduino project. I studied mechanical engineering but i still find electro very interesting. about the serial.print that i found there: https://www.arduino.cc/en/Serial/Print<br>do you mean that I should figure out if the codes that i use are correct with the components that i'm using and post it on the arduino website to figure out if the codes should be written differently? Have a nice evening further and thank you for that great project. One day I will know as well
Hi,<br><br>The &quot;Android&quot; folder of the GitHub repository is the application and whatever is in the &quot;Arduino&quot; folder, is related to the code that runs on the arduino. I would agree that you would need to look more on how the Android Studio works as well as each component of the car. :) <br><br>Finally, there is some more technical documentation on the project here: https://github.com/GallopingSnaiI/SmartCar/wiki
Hi Dimitris,<br>I manage to create an apk with android studio. but the result is the same.<br>Then i realize that the problem is actually that the sensors are not working, that must be the why thew path is not working.<br>So i look in the arduino software, and i found something strange:<br>In the arduino software:<br>&quot;Smartcar_sensors&quot; is written in black in the following text:<br>#include <br><br>but the other library are written in orange:<br>#include <br>#include <br>#include <br><br>I replace this library with a fresh download and change the name :nothing better<br><br>is the following zip download the right one?<br>https://github.com/platisd/smartcar_sensors<br><br>or should i use another one because you notice that:<br><br>This library is deprecated. Please use the Smartcar shield library instead.<br><br>
<p>I am not sure what you mean and the code you are sending is not being formatted correctly, can you put it on pastebin.com and send the link?</p>
<p>The Pathcar with Lego blocks as support</p>
<p>Hi Dimitris,</p><p>After fixing some problems with the battery and my connections, I<br>got now a better result. everything works when I use the manual mode.<br>but not the path mode. when I draw a line and I press &quot;send&quot;,<br>the car go forward without stoping anytime. I need to press on reset<br>on the arduino that it stop. It never detect any obstacle (I try with<br>2 differents ultrasonic sensors HC-SR04) : no reaction </p><p>further the LM393 Beam Photoelectric Sensor got the red light on<br>but if I understood right, it should react to the speed of the car I<br>suppose. but I don't realize any difference. I'm gonna try to<br>&quot;beep&quot; the connections with the multimeter now, but They<br>seems very correct.</p><p>I use the PathCar 1.0.apk application that you attached on <br>this tutorial.</p><p>That should be fine right? I never made a app or use android<br>studio, that's the why, but anyway I download it, as you advice it<br>and run the smartcar master files, but i dont know yet what to do<br>with it.</p><p>you say: </p><p>&quot;1) The car does not receive the appropriate commands</p><p>(1) try printing out through serial the various commands that the<br>car receives and to see if it's&quot;</p><p>How do you print out through serial the various commands ?</p><p>Sorry I'm french, How do you do that?</p><p>Should I check in android studio? I can't export the APK out<br>android studio , I still learning.</p><p>In attachment I draw the hardware scheme, It looks a lot like yours, qua connections, I don't see any difference</p>
<p>Hi,</p><p>Well generally, you should try to compile the app from the source and learn how to make changes there as well. The same goes for the Arduino code. You should try to understand it.</p><p>To print out the various commands you will have to put a Serial.print statement in your Arduino code and on the Android side, parse it and print it out. For the second part, try to instruct the vehicle to move only a specific distance. This could also be a problem.</p>
<p>I made it, but I can't figure out why the APK isn't working. I try the download on this page, I try as well via android studio. If the app is installed on the phone and I press on &quot;connect&quot;, stopt the app immedialtly.</p>
Is there a Bluetooth network to connect to?
Thanks to reply. I really like your project.<br>I fixed the Bluetooth problem (wrong password) :\<br>Now it's working: the app connect to the car but when I press on &quot;send&quot; the car go straight on en never stop. I need to reset the car to stop it. It doesn't follow the path and the manual mode does nothing.<br><br>
<p>Many things could be wrong, it is really hard to tell. The two most probable reasons I can think of are:<br>1) The car does not receive the appropriate commands<br>2) The car cannot execute the &quot;going forward until specific distance command&quot; appropriately.</p><p>To see if it's (1) try printing out through serial the various commands that the car receives and to see if it's (2), try making the car just to move forward for a specific distance.</p>

About This Instructable

2,842views

32favorites

License:

More by Dimitris Platis:A Christmas-tree PCB Ornament My Physical Web Space Marketing with simple IoT devices 
Add instructable to: