GPS - Creating a Fence
Creating the GPS Fence Using the Mower with GPS:
To create a fence we need to place the mower in the fence point position and save the GPS coordinates to the serial monitor. Once all the GPS coordinates have been saved, the serial print out will be copied to the Arduino code to create the GPS fence. In this manner almost unlimited GPS fences can be created.
Step by Step Guide
1. Ensure that your laptop is connected via USB to the ESP32 board and the serial monitor is open and set to 115200 baud.
2. Wait 20mins for the GPS coordinates to settle so that a strong GPS position is calculated by the GPS system.
3. Navigate using the TFT display on the mower to:
Setup> Nav> GPS>
Press New Fence to start the process.
4. Position the Mower with the GPS module in the location of the first fence point and save the coordinates to the Serial Monitor by pressing Save GPS. The GPS Lat and Long position is then printed to the serial monitor. Other data such as the GPS strength and satellites in view is also captured.
5. Working Clockwise, add the GPS positions to the serial monitor by placing the mower in the next position and saving the coordinate.
6. Repeat this until all GPS positions have been saved. (The final "line" between the last GPS coordinate and the starting GPS coordinate is calculated by the software automatically)
7.Highlight and copy the serial text from the serial monitor and paste it into the Arduino code on the ESP32 board.
8. Add a fence number to the code which is not in use and update the GPSMAX number based on the number of fence positions saved.
9. Add start simulation coordinates (Lat & Long) to the code which are known to be inside the fence
11. Re-compile the code to the ESP32 board and activate the fence number using the TFT screen.
12. Start the WIFI and Simulation tool to ensure your fence is setup correctly.
13. Make any adjustments to the boundary conditions if neccessary
14. upload any chnages to the ESP32 board.
15. Once you are happy that the fence is correct, activate the fence using the TFT menu. (Ensure that GPS is enabled so that the mower will use the GPS feature).
Create a Fence using Map DataAlthough the method with the mower is more accurate, It is possible to define the GEO fence using the Latitude and Longitude coordinates of the terrain from a map browser such as google maps. These coordinates are then inputted into the Arduino sketch so the software can calculate the GEO fence. This is done on the GPS_Fence_Data tab.
Please follow thse simple rules for entering the coordinates.
1. Always work clockwise when inputting the coordinates.
2. For each new GPS fence coordinate a new array number is required.
3. Be careful when entering the coordinates. Use a point to separate the numbers and not a comma.
4. Remove any additional lines from the array which are not used.
5, Set the GPSMAX and Define the Array size according to the amount of array points used. GPSMAX should the same number as the last array point entered. The GPS_Array value should be at least +1 to the GPSMAX value.
Lines of code to define GPSMAX and Array Size. In this example we have a GPSMAX value of 85. Therefore the minimum GPS_Array value is 86. (The GPS_Array value could also be 100 if you have defined more than one fence with a higher GPSMAX value)
The amount of GPS points the software can track is limited only by the memory and speed of the ESP32 board. In the below example the software is tracking a GEO fence with 86 points on it. Point 39 is now being entered using the map dataIn the map browser first switch the view to satellite, which allows more accurate placement of the GPS fence points. Clicking on the map gives us a latitude and longitude GPS coordinate which needs to be copied/inputted to the Arduino Software. Take enough points that a good fence border is formed,
Negative points of this method
1. The GPS data in google maps typically shows the GPS point to 6 decimal places. the RTK compass takes position data to 8 decimal places.
2. The positioning accuracy is dependent on the map view and how accurately you can click on the point required.
The software allows more than one GEO fence to be defined (you can input coordinates for various terrains you would need to GEO Fence.
Each new GEO fence should be copied into the code and the next "Fence = X" number used. In the settings the Fence number can be selected with the Fence = X setting.
Although many GEO fences can be defined and the GPSMAX value stored in the fence data, the GPS_Array value needs to be updated manually depending on which fence you are using.