ENPM662 - Introduction to Robot Modeling Project 2: Agricultural Robot model and simulation for picking apples
The following project made use of the CAD software Solidworks and software framework ROS and additional tools like Gazebo/RVizto simulate the task of a vehicle attached with a robot arm specialized in picking apples from trees.
Ubuntu 20.04
- Python >= 3.8
- sympy
- ROS2 galatic
- Gazebo (consider migration for 2025 to Gazebo Garden)
- RVIZ2
Jonathan -CAD models of the environment as the trees& apples plus set stable URDF assembling with vehicle done in (https://github.com/Jomaxdrill/ROS_vehicle) . Keep track of progress and testing/debug of every step of the project. Helped fix integrity issues of the model. Created & organized github repository.
Kent- CAD model of the Robot Arm, DH table, forward kinematics validation and report of the project.
Robens- Built upon initial ros package by adding Lidar Sensor,IMU and vacuum gripper plugins & controllers. Debugging of interactions between objects. coding of teleop script and autonomous mode.
Hamsa - Inverse kinematics validation, workspace study , testing of trajectories execution for robot arm. Help in controller scripts.
-Verify you have ROS2 galatic distribution installed and also CMAKE necessary installations. Refer to: https://docs.ros.org/en/galactic/Installation/Ubuntu-Install-Debians.html On command line run:
echo $ROS_DISTRO
-Install previously the following packages and any additional in your linux distribution running on the terminal the command:
sudo apt install python3-colcon-common-extensions
-Install all necessary dependencies and libraries with pip for insrtance. Recommended to run in your own python environment.
In case of missing libraries you can use pip to install them:
pip install NAME_OF_LIBRARY
pip install
pip install numpy
pip install matplotlib
Create a folder in your system and locate the src pkg
mkdir -p ~/test_ws/src
cd ~/test_ws/src
Clone the repository package inside this folder
git clone https://github.com/Jomaxdrill/fruit_mobile_robot.git
You should get a folder called fruit_vehicle_arm with the content of the repository inside. It should be like the following example:
Downlod all the dependencies before runnning a build.
rosdep install -i --from-path src --rosdistro galactic -y
Run this command to be at root of your workspace (~/test_ws) and build your workspace
cd ../
colcon build
In case you got an error while building regarding an include folder not found run this command while being in the workspace folder
mkdir -p ~/src/fruit_vehicle_arm/include/fruit_vehicle_arm
And run again the build command
colcon build --packages-select fruit_vehicle_arm
Source ROS (Package will be identified) However you can do make this default when opening the terminal by modifying the .bashrc file. Don't forget your user password to give permissions
sudo nano ~/.bashrc
source /opt/ros/galactic/setup.bash
Source package to be identified. Do this for every new terminal you open locating the Workspace folder:
source install/setup.bash
Before launch also run the following commands to install the controller dependencies:
sudo apt install ros-galactic-ros2-control ros-galactic-ros2-controllers ros-galactic-gazebo-ros2-control
sudo apt-get install ros-galactic-controller-manager
Odometry package is needed to track robot position and orientation as it contains plugin features. Vacuum gripper package is also necessary to be able to catch apples in gazebo.
To add it go to the folder additionals inside the package folder fruit_vehicle_arm and copy the folder odometry to the src folder of your workspace. Final result should look like this
You could confirm it was sucessfully done by running a general command colcon build and giving no errors .
colcon build
To run the world successfully custom objects of tree and apples need to be downloaded.
To add it go to the folder additionals inside the package folder fruit_vehicle_arm and copy the folders app_body and tree_body to the location of your gazebo Result should look like this:
Run the following command at the root of your workspace once you source it
ros2 launch fruit_vehicle_arm gazebo.launch.py
This will display the robot in the world with apples and trees ready to run after the autonomous mode script. Sometimes at first could not due to bugs with controller manager. Open a new terminal , locate the workspace folder and run again the command.
To launch rviz open a new terminal, source the package and run:
ros2 launch fruit_vehicle_arm display.launch.py
Use the joint state publisher provided to try some poses for the arm for example
To visualize lidar scanner run before in other terminal the gazebo simulation and after launch RVIZ again and use the Add button and look for select the laser scanner plugin
After check for the scan topic and it should be visible the lidar.
As an extra step be sure inside the topic opetions, the Reliability Policy is set as Best Effort
Inside the src folder of the package, these are the following scripts you can execute:
Locate the folder where the scripts are is:
cd ~\src\fruit_vehicle_arm\src
Run the corresponding script:
python3 forward_position_kinematics_validation.py
This script will ask for the user to provide joint angles to give a final end effector matrix. This applies only for the robot arm.
Aditionally there is a matlab script (test_robot.m) using peter corke robotics toolbox for visualize the robot and interact with it.
python3 Inverse_kinematics_and_validation.py
This script simulates the end effector of the robot drawing a circle f radius 2 inches. The plotted circle on the YZ - plane.
Be sure to open the gazebo by following the previous steps to open it.
Open a new terminal,source the package and run:
ros2 run fruit_vehicle_arm truck_and_arm_autonomous_control.py
The agricultural robot will spawn from position [0.0, 0.25, 0.05] and move from its origin near the trees to catch the apples attached to them with its robot arm.
Close any previously running gazebo terminals then
Build and source fruit_vehicle_arm then launch gazebo with the command:
colcon build --packages-select fruit_vehicle_arm
ros2 launch fruit_vehicle_arm gazebo.launch.py
Open a new terminal and run:
ros2 run fruit_vehicle_arm teleop.py
Robot can now be controlled with W, A, S, D with W and S increasing and decreasing velocity respectively and A and D turning the wheel left and right respectively.
For moving the arm using numbers key combinations of
- Keys arm1: 1,5
- Keys arm2: 2,6
- Keys arm3: 3,7
- Keys arm4: 4,8
Open a new terminal,source package and run:
ros2 run fruit_vehicle_arm odom_subscriber.py
This will give information of the current position of the robot
If odometry was settled correctly you can visualize it via the topic /odom, using programs as rqt_plot or plotjugger. For more information refer to the following useful link tutorial. All credits to the author https://www.youtube.com/watch?v=MnMGjvYxlUk You can also run if installed
ros2 run rqt_plot rqt_plot
https://drive.google.com/file/d/1bWp0tc4YbuVi7mIBvuK-GSt5amngVuD6/view?usp=sharing
https://drive.google.com/file/d/17SFGPVSB7CHLmiUaYZs7CN_LTJuTty-l/view?usp=sharing
https://drive.google.com/file/d/1abLG8P37SsgXIo9mUsSpZqwMaZRfMZdK/view?usp=sharing