DFRobotshop Rover - GPS guided project spinning in circles

Good afternoon everyone,

I've got some experience in C++ coding and small arduino builds, but this is my first one that's a bit more practical. Unfortunately, it's a pretty big bear to tackle. Here's my issue:

I am building a gps guided rover. I want to give it my way points and reach the targets. For now, ignore object avoidance. I want to print data to the OLED screen on board but it keeps getting stuck at the "booting up..." line and will not clear. Furthermore, when power is applied to the motors, this baby just spins for days. It may be locked in the "turndirection == moveLeft" operation. The basis of this build is a DFRobotshop Rover V2 with an onboard arduino. Below are the parts currently attached, as well as the sketch file since the code is far too large to paste in the post.

Hopefully someone can help me sort this issue out! Cheers!

DFRobotshop Rover v2 w/ arduino
Adafruit Ultimate GPS Breakout
Adafruit HMC5883L Magnetometer
Adafruit OLED Breakout 128x64 I2C

RoverArduinoForums.ino (13.5 KB)

SoftwareSerial mySerial(3, 2); // digital pins 7 & 8

What is the point of having a brain-dead comment like that?

Can you post a picture of the mySerial that is connected to the Arduino?

 Serial.begin(9600);
 Serial.begin(115200);        // we need this speed for the GPS

Then WTF is the attempt to set the speed to 9600 for?

What pins does the display object actually use?

Issues with the screen resolved. Yes the code is a bit sloppy, it's still a work in progress.

snmavridis:
Issues with the screen resolved. Yes the code is a bit sloppy, it's still a work in progress.

So, do you still have a problem? If so, what is it?

it keeps getting stuck...

You're very low on RAM. You will probably have to switch to the u8x8 library, which does not use RAM in the Arduino. It sends text drawing commands immediately to the display.

Also, SoftwareSerial is very inefficient and will interfere with other libraries. I would suggest using AltSoftSerial with the GPS on pins 8 & 9, if you can move the GPS. If not, use NeoSWSerial on your current pins. I maintain that library.

You could save a bunch of RAM by using a faster and smaller library that I wrote, NeoGPS. It can be configured to only process the GPS information you really use (location in your case). I have attached a NeoGPS version of your sketch and two config files that disable everything but the location from an RMC sentence. I can't compare sizes because you did not include the waypoint.h file, but the NeoGPS version uses 23524 bytes of program space and 1868 bytes of RAM. It might run.

NeoGPS is more accurate than other libraries, retaining all the accuracy of your GPS device. It also calculates distances more accurately, down to millimeters for small distances (useful in your case).

The NeoGPS version also has the correct loop structure for adding the sonar. In your original program, you were calling processGPS twice, and when you start using ping, it will interfere with the GPS (see comments in attached). Also, the attached sketch makes sure it has a valid location before trying to move or display target distance and heading.

If you decide to try NeoGPS, be sure to follow the installation instructions. The NeoGPS files are copied to your sketch directory, not a Libraries subdirectory. There is also some good information on the Troubleshooting page that can help you understand the GPS timing and loop structure.

Cheers,
/dev

GPSfix_cfg.h (974 Bytes)

NMEAGPS_cfg.h (10.9 KB)

snmavridis.ino (8.63 KB)

Fantastic! I will give that a try thank you for your help! As this is a time sensitive project (the robot itself is a "lets see it in practice") I'll continue trying my hand with the code I have, and I'll look into your ram saving ideas if I have time! I know it'll be a problem in the future though...