Gps Guided Rover

Hi i have one question I got a robot car project that found the way with a gps its final project .Everything is ok but the car does not go where it needs to go and it keeps frozen around the county is so feminine and I can not find a tour where I made the mistake of what I have to do the code is .Please help mee.
I use L298N motor driver

sonar_sensor_ptixiaki_denemesi.ino (9.98 KB)

 return duration / 29 / 2;


Not helpful.

To start with, [u]none of the following[/u] is correct, so this code has no chance of working properly:

 dist_calc = sqrt((((flon1) - (x2lon)) * ((flon1) - (x2lon))) + (((x2lat - flat1) * (x2lat - flat1))));
  dist_calc *= 110567 ; //μετατροπη σε μετρο
  angle_calc = atan2((x2lon - flon1), (x2lat - flat1));


At the very least, you need to print out results and make sure that your calculations are sensible, before you can expect the robot to make sense of them.

It appears that you are [u]not checking to see if the GPS has valid data[/u] before using the results.

I checked everything.The car does not go straight to the right track.It keeps frozen around.Gps data is true magsensor work good when i use classe forward backward left rigth all work good i cant understand where is the problem.Can someone fix the code I can not find a tour resort on 7 days i have presentations i cant sleep please help mee.I want is to go to the coordinates and escaped from the obstacle 20 meter only please brothers

benim_programim.ino (8.38 KB)

benim_programim.ino (8.38 KB)

No one will help

Hello brothers i have problem i want build gps guided rover i have compass gps but i cant find the what i doing wrong the rover does cant lead the waypoint can help me

deneme_mayis_18.ino (10 KB)

There are so many problems, it’s hard to make a suggestion. You are trying to do too many things together. You should learn how to do each thing first, by itself: GPS, compass, obstacle detection and driving. Then start combining them, one piece at a time.

Here’s the list for your One Big Program:

* Don’t use SoftwareSerial. You have a Mega, so hook the GPS to Serial1, on pins 18 & 19.

* Indent your code properly. Just press control-T in the IDE editor and it will auto-format it for you.

* Use good variable names. Instead of “ss” for the GPS serial port, call it “gpsPort”. Since you need to use Serial1, you can do this:

    #define gpsPort Serial1 // an "alias"

* Why are you calling getDistance all the time? You usually don’t use the result for anything. Most of the code in loop happens very quickly, less than 1 millisecond. Just call it when you need to, in the “take action” section.

* Printing too much slows your program waaaaaaaay doooooooown.

* Break your loop into subroutines. It’s too long to understand.

* Don’t use delay in loop. It makes your program slow, and it will lose GPS characters.

* Find out how to use your compass. You are not using x,y,z to determine the current orientation. That orientation should be compared to the bearing to the waypoint. When they’re different (subtracted), you’ll know which way to drive.

* Don’t use an int for heading angle. Radians can be less than 1, so it will truncate 0.35 radians to 0.

* Don’t set the GPS update to 200ms (5Hz). Start with 1000ms (1 update per second) so you can see what’s happening.

* Use NeoGPS, and you won’t have to call myDelay and feedgps all over the place. It’s more advanced, but it is smaller, faster and more accurate than all other libraries. It can do the correct distance and angle calculations.

I attached a version your sketch with all those suggestions. If you want to try it, NeoGPS is available from the Arduino IDE Library Manager, under the menu Sketch → Include Library → Manage Libraries. Even if you don’t try it, be sure to read the Troubleshooting page for other tips for GPS sketches.

But I strongly suggest you work on the individual programs first, before trying to debug the OBP.


sustakas.ino (7.68 KB)

Ty brother so so much you are the king im so very happy for helping me this code work?