ArduRover Python Scripting via Raspberry Pi



Hello!
I am developing an ArduPilot/Rover-based UGV to navigate between crop rows for crop monitoring. The UGV is equipped with a Pixhawk 1, a Raspberry Pi 4B, and an RTK-GPS receiver amongst other necessary components. The Raspberry Pi 4B is properly wired to the Pixhawk and the communication between both seems to be good as I have been using this method to geotag my robot data collected from the field. Given that this UGV needs to precisely navigate between crop rows, it is not possible to specify the crop row path directly on Mission Planner, hence, I decided to use a Python script (using dronekit) running on Raspberry Pi to send commands to the Pixhawk. This script has the exact coordinates of the crop rows as seen in the image (plot) attached. Before deploying the Python script on the UGV, I did a simulation test to test the performance of the script in SITL, and it did pretty well as seen in the image attached (with the simulated path). However, when I eventually deployed the script on the UGV, as soon as I started the script, the UGV went off course and never followed the predefined path (as seen in the attached image with the actual navigation path). Shortly after, the UGV stopped and the output of the script read “All waypoints completed and last waypoint reached” (as configured) even when it never completed the predefined waypoints and never got to the last waypoint (I know I took control of the UGV using my transmitter when it was misbehaving, but I am not sure that would be the reason it said last waypoint reached). I was surprised at this behaviour, then I decided to test the UGV navigation by directly creating a mission on Mission Planner on an open field (not the crop rows this time) and uploading to the UGV to see if it would follow the waypoints and to my greatest surprise, it did follow the waypoints accurately as seen in the image attached. The problem here is that the UGV follows the waypoints created and uploaded via Mission Planner, but fails to follow the waypoints specified via Python scripting. Why is this so? What am I doing wrong? Do I need to set anything specific in the parameter list before using Python script? Could the rover heading due to compass error be a problem here?How can I proceed further to achieve my goal of precise waypoint following within crop rows using custom Python script? I have not done any advanced setting on ArduRover via Mission Planner before using Python scripting as I am not sure if there is anything specific I need to do before that. I would appreciate any insight on this and help to enable me proceed with my work. Thank you in advance. Please let me know if I have to send my Python script and how I can send it across for debugging. I forgot to mention, the firmware version of ArduRover I am using is 4.6.2.