DEV Community

Gonzalo Mier
Gonzalo Mier

Posted on

How to Install Fields2Cover on Linux for Coverage Path Planning on Agriculture

Fields2Cover logo

Installing Fields2Cover (https://github.com/Fields2Cover/Fields2Cover) on your Linux system is a fantastic way to improve the efficiency and productivity of your agricultural operations!

Screenshot of a path generated with Fields2Cover and ROS

Fields2Cover is a state-of-the-art coverage path planning library that is perfect for precision agriculture. With Fields2Cover, you can easily determine the optimal paths for your agricultural machinery to follow in order to cover a field while minimizing overlap and maximizing coverage. This will help you to save resources such as fuel and water, and it will also increase your yields and reduce your costs.

Prerequisites

To get started with Fields2Cover, you will first need to have some packages installed on your system. You can do this by using the following commands in a terminal:

sudo apt-get -y update
sudo apt-get install -y --no-install-recommends software-properties-common
sudo add-apt-repository -y ppa:ubuntugis/ppa
sudo apt-get -y update
sudo apt-get install -y --no-install-recommends build-essential ca-certificates cmake \
     doxygen g++ git libeigen3-dev libgdal-dev libpython3-dev python3 python3-pip \
     python3-matplotlib python3-tk lcov libgtest-dev libtbb-dev swig
python3 -m pip install gcovr
Enter fullscreen mode Exit fullscreen mode

Installing C++ Fields2Cover library

After installing the necessary packages, you can clone the Fields2Cover repository and compile it using the following commands:

git clone https://github.com/Fields2Cover/Fields2Cover
cd Fields2Cover
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)
sudo make install
Enter fullscreen mode Exit fullscreen mode

Once Fields2Cover is installed, you can use it in your own projects by adding the following lines to your CMakeLists.txt file:

find_package(Fields2Cover REQUIRED)
target_link_libraries(<<<your_package>>> Fields2Cover)
Enter fullscreen mode Exit fullscreen mode

Installing Fields2Cover with Python interface

In addition to the C++ interface, Fields2Cover also provides a python interface that you can use in your python scripts. To use the python interface, you will need to install some additional packages and compile the project with the python interface enabled. You can do this by using the following commands:

sudo apt install swig python3-pytest
cd build
cmake -DBUILD_PYTHON=ON ..
make -j$(nproc)
sudo make install
Enter fullscreen mode Exit fullscreen mode

To test if the python interface was successfully compiled and installed, you can run the following commands:

python3
import fields2cover
Enter fullscreen mode Exit fullscreen mode

If no errors are thrown, the python interface was successfully installed. You can also run the test suite by running the following command from the main Fields2Cover directory:

pytest-3 tests/python/
Enter fullscreen mode Exit fullscreen mode

Adding ROS support

Fields2Cover also provides a ROS interface that allows you to visualize your fields and the paths generated by the algorithm. To use the ROS interface, you will need to clone the Fields2Cover and fields2cover_ros repositories and build them with ROS. To do so, you can use the following commands:

cd catkin_ws/
git clone https://github.com/Fields2Cover/fields2cover_ros src/fields2cover_ros
rosdep install -r --ignore-src -y --from-paths .
catkin_make_isolated
Enter fullscreen mode Exit fullscreen mode

Once the ROS interface is built, you should be able to use Fields2Cover in your ROS projects and enjoy the benefits of precision agriculture! With Fields2Cover, you can easily determine the optimal paths for your agricultural machinery to follow, which will save you resources and increase your yields. So why not give Fields2Cover a try today and take your agricultural operations to the next level?

Top comments (0)