Android Controlled, Path Following Vehicle

Introduction: Android Controlled, Path Following Vehicle

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.

3 People Made This Project!

Recommendations

  • Furniture Contest

    Furniture Contest
  • Make it Real Student Design Challenge #3

    Make it Real Student Design Challenge #3
  • Explore Science Challenge

    Explore Science Challenge

77 Comments

0
krupal2651
krupal2651

Question 10 months ago

While connecting the robot with the android app it comes an error with "Path car keeps stopping"
Kindly reply me what to do with this !!!

Capture.PNG
0
Dimitris Platis
Dimitris Platis

Answer 10 months ago

It could be many things. You should try to read the code, understand it and then debug it.

0
krupal2651
krupal2651

Question 10 months ago

I am connecting 1.5A 12V power supply to motor shield and when I connect all the things together bluetooth is not getting powered up.

Kindly share what can I do ?

0
Dimitris Platis
Dimitris Platis

Answer 10 months ago

I am not quite sure. Does it power up if you power everything up via the USB?

0
darshit.ambasana104847
darshit.ambasana104847

Question 10 months ago

Can you tell the library or file specifically where changes have to be made to use MPU6050 instead of L3g4200D ??

0
darshit.ambasana104847
darshit.ambasana104847

Reply 10 months ago

But I could not exactly find where the library of L3G4200D is placed so I can replace it with Mpu6050 library and edit further. I looked in Smartcar_sensor.h and Gyroscope.cpp.

0
Dimitris Platis
Dimitris Platis

Reply 10 months ago

All code for the gyroscope (L3G4200D) is in the Gyroscope.cpp file.

0
krupal2651
krupal2651

11 months ago

Can we use MPU6050 instead of L3g4200D ??

0
Dimitris Platis
Dimitris Platis

Reply 11 months ago

Sure, why not? You will of course have to make the necessary changes in the code.

0
kotnimahesh144
kotnimahesh144

1 year ago

Can we implement this project using raspberry pi

1
Dimitris Platis
Dimitris Platis

Reply 1 year ago

How would you use the Raspberry Pi in this case? As a WiFi gateway instead of the Bluetooth connection or would it replace the Arduino?

0
kotnimahesh144
kotnimahesh144

Reply 1 year ago

I am a beginer. I want to know cant we replace arduino with raspberry pi?
Thanks in advance

0
Dimitris Platis
Dimitris Platis

Reply 1 year ago

You theoretically can, but if you are a beginner you probably should not.

0
raajnihaal
raajnihaal

Question 1 year ago

Hi,
Is there a way to record the path? So that i can get the outline of the area i am working on.

0
saibalaram6712
saibalaram6712

1 year ago

which code should we use for autonomous path drawn and the robot follows the path

0
ayoub aglaou
ayoub aglaou

Question 1 year ago on Step 4

thanks for all this i hav some problems with code give erreur in serial.println2 was not declared in scoop ?

0
Dimitris Platis
Dimitris Platis

Answer 1 year ago

Do you mean `Serial2.println`?
If so, then you need to set the board to `Arduino Mega`.

0
ayoub aglaou
ayoub aglaou

Reply 1 year ago

thanks i found problème with serial2.println. But i have onother probléme withe application android when i chek button connect application turn off

0
Dimitris Platis
Dimitris Platis

Reply 1 year ago

This doesn't tell me much I am afraid. You will need to understand the Android app code and figure out where it crashes.