Skip to content

A project on a small autonomous vehicle guided by GPS and compass which can avoid small simple objects

Notifications You must be signed in to change notification settings

jibjab1337/gps_guided_autonomous_vehicle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gps_guided_autonomous_vehicle

An Arduino project on a small autonomous vehicle guided by GPS and compass which can avoid small simple objects

Input one or multiple destinations manually through a text menu on a Bluetooth terminal and the vehicle will move to its destination
Comes with basic obstacle avoidance maneuver

This is the final design of the vehicle
alt text
Please note the placement of each component, especially the digital magnetometer. The digital magnetometer must be placed at least 15 cm away from the other components due to it being very sensitive to electrical components such as the motor driver and power supply - hence why it is on a makeshift small cardboard tower.

How it works

  1. Turn on the vehicle and connect to the Bluetooth on your smartphone. You will know you are connected if you see the text menu appear
  2. Enter character commands in the Bluetooth app as well as your GPS coordinates (up to 6 decimal places)
  3. Once you've entered your coordinates, you will be taken to another text menu with options to move the vehicle and automation. You must test the turns of your vehicle and change the millisecond inputs to ALL the turns since all turns and movements have hardcoded millisecond inputs.
  4. If you're satisfied with the turns and movements of your own vehicle, proceed to the automation option
  5. The vehicle should then begin turning towards its destination
  6. If the vehicle is not facing within 10 degrees of its destination, it will correct itself. Please note that these turn corrections must be short, quick turns and thus it is up to you to hardcode the specific millisecond inputs - if your turns are too wide or too short, the vehicle will take longer to move to its destination
  7. If the vehicle detects a small simple object in front of its sensors, it will proceed to turn on an LED connected to pin 2 and do a short turn. After the turn, it will correct its bearing and proceed again towards its destination
  8. Once the vehicle detects that it's within 3 meters of its destination (this distance is chosen because it is fairly common with GPS to have a small radius of inaccuracy) it will stop and tell you through text that you have arrived. It will then print out its final GPS coordinates.

Important notes

  1. This project only works on a large, flat open area outdoors. I would try this vehicle project in a large open parking lot with smooth pavement. You could in theory use a higher-end RC car model and rig it to the specifications outlined in this project but I used a very cheap 20 dollar generic DIY RC car model.
  2. You must stay 10-20 feet or 3-6 meters of the vehicle in order to constantly see the stream of data through Bluetooth. You might occassionally disconnect from Bluetooth but I would always connect back quickly and still receive data
  3. Obstacle avoidance is very basic - the vehicle can avoid small flat object in front of its sensors. Only use small flat objects as obstacles so that the ultrasonic sensors can receive the sound wave bounces properly.
  4. Calibrate the compass. It is very important that the digital magnetometer is calibrated correctly. Please use the code from the specific arduino library I linked as it contains calibration code. If you're using the Arduino IDE, calibration code can be found in "File > Examples > Arduino-HMC5883L-master > HMC5883L_calibrate"
  5. Digital magnetometer must be placed 15 cm away from any electrical component of the vehicle. I chose to put it on a makeshift 20 cm tall tower. If you don't do this, you will not get proper angles from the compass. Also, the model I bought is very sensitive to its environment; I would test out the compass in different areas of my college campus and would find that the compass just did not work in specific areas. All angles in this project range from 0.00 to 359.99 degrees with 0 degrees being north, 90 degrees being east, 180 degrees being south, 270 degrees being west and 359.99 degrees being north again. To test if you calibrated your compass correctly, pick up the vehicle and have it face the general direction of true north, south, east, west and see if the angle bearing values closely match the numbers I outlined.

Example of the text menu ran through the Bluetooth App on Android
alt text

Version 1 - Added functionality through text menu to allow multiple destinations (up to 4)

Text menu is through Serial monitor which on the vehicle goes to Serial port 2 through the HM-10 Bluetooth module

Note: The turns must be calibrated by changing the inputs into the delay() functions of the movements. This is up to your own discretion depending on your environment and wheels





Libraries used:

TinyGPS++
Arduino-HMC5883L-master Version: 1.1.0 (c) 2014 Korneliusz Jarzebski: https://github.com/jarzebski/Arduino-HMC5883L/blob/master/HMC5883L.h
SoftwareSerial.h
Wire.h
math.h





Materials/Equipment used in this project:

Arduino Mega
Small RC Car chassis/body with four DC motor wheels - Geared Motor DC 6V / 200 RPM (Any universal 6V DC motor from a generic RC car will do)
L298N Motor Driver
12 V Battery Supply - Used two battery holder cases in series, four AA 1.5 V batteries each, eight total. Feel free to substitute your own 12 V power supply
Bluetooth: HM-10 BLE Bluetooth 4.0
Compass: GY-271 QMC5883L or HMC5883L - Model was the HMC - this is important because the models use two different I2C addresses and the following code uses HMC
GPS: NEO 6M V2 + small ceramic antenna - Bought mine on Amazon
Ultrasonic sensors: HC-SR04 (Three total)
Green LED light - Any generic LED will do, it doesn't have to be green
300 Ohm resistor
Breadboard jumper wires and a breadboard -feel free to solder the cables

You need a smartphone or a virtual machine on your computer for Android in order to wirelessly communicate with the vehicle
Smartphone Application used with Bluetooth: "Serial Bluetooth Terminal" by Kai Morich on Google Play Store
I use Android and this application works well. If you're on Apple, you're going to have to find another Bluetooth app





Wiring


Arduino Mega GND is connected to Negative end of 12 V Power Supply of batteries

4 DC Motors -> L298N Motor Driver

Two left wheels: Positive wires are connected together. Negative wires connected together
MOTOR A side
Positive wire --> OUT1 on L298N motor driver
Negative wire --> OUT2 on L298N motor driver

MOTOR B side
Two right wheels: Positive wires are connected together. Negative wires connected together
Positive wire --> OUT3 on L298N motor driver
Negative wire --> OUT4 on L298N motor driver

L298N Motor Driver
OUT1,2 --> Two left wheels (MOTOR A)
OUT3,4 --> Two right wheels (MOTOR B)
12V --> Connected to Positive end of 12 V Power Supply of batteries
GND --> Connected to Arduino Mega GND

ENA --> Digital Pin 11
IN1 --> Digital Pin 10
IN2 --> Digital Pin 9
IN3 --> Digital Pin 8
IN4 --> Digital Pin 13
ENB --> Digital Pin 12

Ultrasonic sensors (A1,2,3,4,5 are analog pins)
All of them
VCC - 5 V on Arduino Mega
GND - Arduino Mega GND

Ultrasonic front
TRIG --> A4
ECHO --> A5

Ultrasonic left
TRIG --> A2
ECHO --> A3

Ultrasonic right
TRIG --> A0
ECHO --> A1

Interrupt Pin 2
Digital Pin 2 --> 300 Ohm resistor --> (Anode +) Green LED (Cathode -) --> Arduino Mega GND

GPS
VCC --> 3.3 V on Arduino Mega
GND --> Arduino Mega GND
TX --> Digital Pin 15
RX --> Digital Pin 14

Bluetooth
VCC --> 3.3 V on Arduino Mega
GND --> Arduino Mega GND
TX --> Digital Pin 17
RX --> Digital Pin 16

Compass
VCC --> 3.3 V on Arduino Mega
GND --> Arduino Mega GND
SCL --> Digital Pin 21
SCA --> Digital Pin 20

About

A project on a small autonomous vehicle guided by GPS and compass which can avoid small simple objects

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages