AGRIBOT follows a modular design philosophy that cleanly separates concerns across four distinct layers: the Gazebo simulation environment (which hosts the robot and virtual farm world), the URDF robot model (defined via Xacro macros and exported from SolidWorks meshes), the ROS navigation stack (GPS-guided waypoint following implemented in 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.
autonomous_drive package), and the CNN classification pipeline (a standalone Python module for training and real-time inference). Each layer communicates through well-defined ROS topics, making it straightforward to swap out individual components — for example, replacing the simulated GPS plugin with a real NEO-M8N receiver requires only a change of topic source, not a rewrite of the navigation logic.
Repository Structure
The repository is organized into two top-level sections: theCrop_Weed_ Classification directory for all deep learning work, and the agribot_ws Catkin workspace for all ROS-based robot software.
AGRIBOT targets ROS Kinetic on Ubuntu 16.04 and ROS Melodic on Ubuntu 18.04. The
autonomous_drive package depends only on rospy, making it easy to port to newer ROS distributions. Gazebo simulation has been validated on Gazebo 7 (Kinetic) and Gazebo 9 (Melodic).ROS Package Breakdown
Each package inagribot_ws/src/ has a focused responsibility. Understanding what each one does makes it easier to extend or debug the system.
agribot_description
This package contains everything needed to describe the robot in ROS and Gazebo:
- URDF/Xacro files —
agribot_body.urdf.xacrodefines the base chassis, four wheels (using theagribot_partmacro fromagribot_parts.urdf.xacro), and all sensor link frames (IMU, GPS, magnetometer, camera).agribot_sensors.urdf.xacroattaches Gazebo plugins to those links. - Meshes — SolidWorks-exported STL files for
base_link.STLandwheel_1.STL, referenced by all visual and collision geometries. - Gazebo worlds — simulation environments representing farm rows with cylindrical crop models.
- Launch files — bring up the robot in Gazebo, spawn the URDF, and start
robot_state_publisher.
dummy_link is fixed to the ground plane, and base_link (the physical chassis, mass 3.4672 kg) is attached 0.26 m above it. This satisfies the physics engine requirement that the root link have no inertia.
agribot_control
Manages all four wheel joints using ROS Control effort controllers with PID tuning:
hardware_interface/EffortJointInterface with a mechanical reduction of 10:1 via transmission_interface/SimpleTransmission. At the Gazebo level, the skid-steer drive plugin (libgazebo_ros_skid_steer_drive.so) takes over locomotion by subscribing to /agribot/cmd_vel and publishing odometry on /odom.
autonomous_drive
The navigation package, written in Python (rospy), contains five key scripts located in agribot_ws/src/autonomous_drive/scripts/:
GPS_data_conversion.py— thegps_converternode. Subscribes to/agribot/fix(NavSatFix) and converts GPS coordinates to local XY using an Alvin Mercator projection (ll2xy). Publishes distance to goal on/distance, current local pose on/currentPose, and bearing to goal onangleOG.data_manipulation.py— thedata_manipulationnode. Subscribes to/magnetic(Vector3Stamped) and applies a Moving Median filter followed by a single-dimension Kalman filter to produce a clean heading angle, published on/angle(Float64).autonomus_drive.py— the main drive node. Combines bearing (angleOG) and filtered heading (/angle) to compute a heading error, then publishesTwistcommands on/agribot/cmd_vel.AutonomusDriveAction.py— action-server wrapper for sequencing multi-waypoint navigation.plot.py— logs and plots heading and distance data for post-run analysis.
imudata
Contains imudata.ino, the Arduino sketch that reads raw accelerometer and gyroscope data from the MPU-9265 over I²C and publishes it as a ROS std_msgs/String message on the imu topic at 10 Hz. In Gazebo simulation, this is replaced by the libhector_gazebo_ros_imu.so plugin. See the Hardware page for a full code walkthrough.
gps_umd, mapviz, teleop_tools, marti_messages
These are supporting packages: gps_umd provides the real-hardware GPS ROS driver, mapviz (with mapviz_plugins, tile_map, and multires_image) provides a tile-map visualization tool where the robot’s traced trajectory (blue line) and goal waypoints (green dots) are rendered, teleop_tools enables manual joystick or keyboard control for testing, and marti_messages provides custom ROS message definitions used by mapviz.
ROS Node Communication Graph
The following describes the complete data flow from sensors through navigation to actuation, as implemented in the source code.GPS Data Ingestion
The Gazebo GPS plugin (
libhector_gazebo_ros_gps.so) publishes sensor_msgs/NavSatFix on /agribot/fix at 5 Hz. In hardware mode, the gps_umd driver publishes the same message from the NEO-M8N module.Coordinate Conversion (gps_converter node)
GPS_data_conversion.py subscribes to /agribot/fix and converts the WGS84 latitude/longitude pair into a local Cartesian frame relative to the starting-point origin (lat: 21.1613331649, lon: 72.7870533933) using the Alvin Mercator ll2xy projection. It publishes:/distance(Float64) — Euclidean distance to the goal waypoint/currentPose(Pose) — local XY positionangleOG(Float64) — bearing angle from current position to goal, computed asatan2(dy, dx)
Heading Computation (data_manipulation node)
data_manipulation.py subscribes to /magnetic (geometry_msgs/Vector3Stamped) published by the Gazebo magnetometer plugin at 5 Hz. It applies a Moving Median filter and a single-dimension Kalman filter to reduce sensor noise, then publishes the filtered heading on /angle (Float64).Autonomous Drive Decision (autonomousdrive node)
autonomus_drive.py subscribes to both angleOG (desired bearing) and /angle (actual heading), computes the angular error, and publishes corrective geometry_msgs/Twist velocity commands on /agribot/cmd_vel.Skid-Steer Actuation
The Gazebo
libgazebo_ros_skid_steer_drive.so plugin subscribes to /agribot/cmd_vel and drives all four wheels accordingly. Odometry is published on /odom at 100 Hz.Subsystem Navigation
Navigation Overview
Deep dive into the GPS-to-XY coordinate conversion, Kalman filtering, heading error control loop, and multi-waypoint field traversal strategy.
Classification Overview
UNet vs. Bonnet architecture comparison, training setup on CWFID and Bonn datasets, inference pipeline, and model performance metrics.
ROS Packages
API reference for all custom ROS nodes, topics, services, and parameters in the
autonomous_drive and agribot_control packages.Simulation
How to launch the Gazebo farm world, tune sensor noise parameters, visualize the robot trajectory in Mapviz, and record ROS bags for offline analysis.
CNN Classification Pipeline
TheCrop_Weed_ Classification/ directory is a self-contained Python module independent of ROS, structured for both offline training and online deployment.