AGRIBOT’s path planning is waypoint-based: the robot drives toward a GPS goal using a PD controller that computes linear and angular velocity commands from the heading error and distance to goal. There are no global maps or obstacle-avoidance planners involved — the assumption is that farm rows are clear corridors and the only task is accurate heading tracking over the distance to each waypoint. For multi-waypoint missions, theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Dhruv2012/Autonomous-Farm-Robot/llms.txt
Use this file to discover all available pages before exploring further.
AutonomusDriveAction.py node wraps ROS move_base to cycle through a list of goal poses indefinitely.
PD Controller (GPSAlgoV1)
The core control algorithm lives inautonomus_drive.py inside the GPSAlgoV1() function. It is called every time a new angle or distance message arrives, so the control loop runs at the rate of whichever topic arrives most frequently.
|error| ≥ 2°— The robot applies the full PD correction toz_angularand moves forward slowly at 0.2 m/s simultaneously, so it is always making progress toward the goal even while correcting its heading.|error| > 10°— The error is large enough that forward motion would take the robot significantly off course. Linear velocity drops to zero and the robot rotates in place until the heading error falls below 10°.|error| < 2°— The heading is considered aligned. Angular velocity drops to zero and the robot accelerates to full forward speed (0.4 m/s) to cover ground efficiently.distance ≤ 1.0 m— The robot enters its approach zone. All motion stops anddestination_flagis set to1regardless of heading error, preventing overshoot.distance ≤ 0.5 m— A second hard stop threshold that catches any case where the 1 m approach zone was not triggered, e.g. due to message timing.- Angular velocity clamping — After the PD formula is evaluated,
z_angularis clamped to ±0.5 rad/s to prevent violent spinning that could destabilize the robot or saturate the motor drivers.
Tuning the Controller
The table below documents every adjustable parameter inGPSAlgoV1() along with its current value and its effect on robot behaviour.
| Parameter | Value | Effect |
|---|---|---|
kp | 0.01 | Proportional gain on orientation error — increase to respond faster, decrease to reduce overshoot |
kd | 0.5 | Derivative gain — dampens oscillation; too high causes jitter on noisy angle signals |
| Goal threshold | 0.5 m | Distance at which the robot declares arrival and stops permanently |
| Approach zone | 1.0 m | Distance at which all motion ceases early if heading is still being corrected |
| Max angular vel | 0.5 rad/s | Hard clamp on z_angular output to protect drivetrain and prevent spinning |
| Straight speed | 0.4 m/s | Linear speed when heading error is below 2° |
| Turn speed | 0.2 m/s | Linear speed during a correction turn (error between 2° and 10°) |
| In-place rotation threshold | 10° | Angle above which the robot halts forward motion and rotates on the spot |
The PD controller was tuned for Gazebo simulation conditions with the default Hector GPS plugin noise parameters. For real hardware deployment, re-tune
kp and kd based on actual robot inertia, drivetrain response, and GPS update latency. Starting with kp an order of magnitude smaller than your expected maximum error and kd roughly 10–50× kp is a reasonable first approximation.Waypoint Patrol Mode
For missions that require the robot to visit multiple GPS waypoints in sequence — such as navigating to the end of each crop row and turning —AutonomusDriveAction.py provides a patrol loop built on top of the ROS move_base action server.
Waypoints are defined as a Python list of [(position_xyz, orientation_xyzw)] tuples. Each entry specifies a target position in the map frame together with a goal orientation as a quaternion:
move_base via a SimpleActionClient, waits for the result, then advances to the next waypoint. When the end of the list is reached it wraps back to the beginning, giving the robot an indefinite patrol behaviour suitable for repeated row coverage:
[(x, y, z), (qx, qy, qz, qw)] entries to the waypoints list. Orientation quaternions can be generated from Euler angles using tf.transformations.quaternion_from_euler(roll, pitch, yaw).
Run the patrol node after move_base is active: