Arduino USV Robot with GPS and Compass

rover_thumbThe goal of this project was to create a robot that would be able to reach a goal geolocation from any starting position while avoiding obstacles. Performing this operation with multiple goal locations, the robot is able to travel a predefined path. Robot operation is based on two modes: Cruise and Wall follow (for obstacle avoidance). Cruise mode uses readings from GPS and Compass while the wall follow mode uses distance information acquired from 5 ultrasonic sensors as well as compass readings. The main operation loop runs at 20Hz.

Cruise mode loop calculates goal heading from current to goal location. Offset between goal heading and current heading is the error that is passed to the cruise PID algorithm that operates the wheel speeds in order to maintain direction.

During cruise mode distance measurements are performed. If an obstacle is detected the main algorithm switches to wall follow mode. Only exception is in case obstacle is detected on the side of the robot and the robot is moving away from it to get to the goal so the obstacle can be ignored.

Wall follow mode is used to avoid obstacles. In order to avoid interference from ultrasonic sensors, measurements are performed in 50ms intervals so each sensor gets to perform 4 readings every second. Adaptive PID algorithm is used to operate the wheel speeds in order to move around obstacles.

The LCD is used to display debug data and the three potentiometers are used to fine tune cruise and wall follow PIDs. One thing to note is that compass has to be very carefully placed on the robot because it is very susceptible to interference from other components, e.g. the LCD was causing problems when it was placed just an inch closer to the compass.

Parts:
1 x Arduino Pro Mini
1 x NEO6MV2 GPS Module
1 x HMC5883L Triple Axis Compass
1 x L298N Motor Driver Controller
2 x 12V 122 RPM Gear Motors + 80mm Wheels
3 x 10k Potentiometer
5 x Ultrasonic HC-SR04 Module
1 x LCD Display Module HD44780 16×2 Character /w I2C interface
6 x AA Rechargeable Batteries + holder case

The code is written in C++ and is hosted on my GitHub repo: https://github.com/lukagabric/LRover

Videos below show test drives with obstacles. Goal location is marked with the bag. Once robot reaches the goal location it stops and turns in place. Tests in the videos are performed in very cloudy weather which did not have impact on GPS readings.

Test drive 1

Test drive 2:

  • Arduino Rover Image 1
  • rover_img2
  • rover_img3
  • rover_img4
  • rover_img5
  • rover_img6

 

References:

Heading and distance calculation: http://www.movable-type.co.uk/scripts/latlong.html
Compass calibration: http://hobbylogs.me.pn/?p=17

 

Parts on Amazon:

 

If you liked this blog post I’d appreciate if you followed me on Twitter

Related Post

Remember to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInEmail this to someone

16 thoughts on “Arduino USV Robot with GPS and Compass

  1. Hi,
    I am working on gps guided robot with kalman filter implementation.

    Could you please mail me the circuit diagram of “Arduino USV Robot with GPS and Compass”

      1. Hello!

        I’ve been trying to replicate your project (which is pretty cool!) but I’m really stuck with the wiring. I have read all your codes but I’m missing some connections (the ultrasonic modules is one of them), can’t find where you declare them at all..
        I know that you have no circuit diagram of your project so I’ve been trying to get these connections looking at the pictures above… well, do you have more pics of the car? Hahaha!

        It’s a concept of a mechanical engineering project, it is in Portuguese, but I can send you a copy if you want.
        Thanks!

  2. how accurate is the robot indoor? how far is it going to stop after reaching the goal?
    finally how do you assign a destination ?

    1. Hi! Since GPS is used, it’s not going to work indoors. The robot stops and spins around once it is inside 1 meter of the goal (destination). For initial testing of the robot I hardcoded the coordinate. For the testing in the video I first put the robot at the goal location (next to the bag) to acquire the coordinate and then moved the robot away to any start location. The robot would move to the goal location and avoid obstacles along the way.

      1. alright one more question, i’d like to know why you used the potentiometers and why use so many ultrasonic sensors.

        on last thing can you put links for where you bought the parts from ? especially the GPS and the compass.

        1. Potentiometers are used to fine tune the PID constants. I got everything off eBay, don’t have the links any more, but it should be very easy to search for those. I used 5 ultrasonic sensors to detect obstacles, the robot is not that small and it would not be that successful in detecting obstacles with less sensors.

  3. Hi, i have a project related to u r project ,please advice me &how you connect the material that you used in your project

  4. 54/5000
    Quizás quisiste decir: excelente trabajo amigo!! me podrias pasar tu codigo
    Excellent job, my friend !! Could you pass me your code

Leave a Reply

Your email address will not be published. Required fields are marked *