# ros2_SimRealRobotControl
**Repository Path**: haoge-lib/ros2_SimRealRobotControl
## Basic Information
- **Project Name**: ros2_SimRealRobotControl
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: foxy
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-12-10
- **Last Updated**: 2023-12-10
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
ROS 2: Sim-to-Real Robot Control
IFRA (Intelligent Flexible Robotics and Assembly) Group
Centre for Robotics and Assembly
Cranfield University
Table of Contents
-
About
-
Installation
- Supported Robots
-
ROS2 Packages
- Contributing
- License
- Cite our work
- Contact
- Acknowledgments
## About
### Intelligent Flexible Robotics and Assembly Group
The IFRA (Intelligent Flexible Robotics and Assembly) Group is part of the Centre for Robotics and Assembly at Cranfield University.
IFRA Group pushes technical boundaries. At IFRA we provide high tech automation & assembly solutions, and we support smart manufacturing with Smart Industry technologies and solutions. Flexible Manufacturing Systems (FMS) are a clear example. They can improve overall operations and throughput quality by adapting to real-time changes and situations, supporting and pushing the transition towards flexible, intelligent and responsive automation, which we continuously seek and support.
The IFRA Group undertakes innovative research to design, create and improve Intelligent, Responsive and Flexible automation & assembly solutions, and this series of GitHub repositories provide background information and resources of how these developments are supported.
__SOCIAL MEDIA__:
IFRA-Cranfield:
- YouTube: https://www.youtube.com/@IFRACranfield
- LinkedIn: https://www.linkedin.com/in/ifra-cranfield/
Centre for Robotics and Assembly:
- Instagram: https://www.instagram.com/cranfieldrobotics/
- Facebook: https://www.facebook.com/cranfieldunirobotics/
- YouTube: https://www.youtube.com/@CranfieldRobotics
- LinkedIn: https://www.linkedin.com/company/cranfieldrobotics/
- Website: https://www.cranfield.ac.uk/centres/centre-for-robotics-and-assembly
### ros2_SimRealRobotControl Repository
The ros2_SimRealRobotControl repository is a collection of ROS 2 packages that are designed to facilitate robot manipulation tasks. The packages include Gazebo Simulation, MoveIt!2, and Robot Bringup, all of which can be used to simulate and control robot manipulators.
The Gazebo Simulation package provides a simulation environment for robot manipulators, allowing users to test and develop control algorithms in a virtual environment before deploying them on a physical robot. MoveIt!2 is a motion planning framework that allows users to plan and execute robot manipulator trajectories, while the Robot Bringup package provides the interface for controlling the physical robot.
By combining these packages, the repository offers a comprehensive solution for developing and testing robot manipulator applications using ROS2. This can be particularly useful for researchers and engineers who are working on robotics projects, as it can significantly reduce the time and resources required for development and testing.
__Improvements: ros2_RobotSimulation -> ros2_SimRealRobotControl:__
On October 2022, IFRA-Cranfield released [ros2_RobotSimulation](https://github.com/IFRA-Cranfield/ros2_RobotSimulation), a GitHub repository containing "ready-to-use" ROS2 Industrial Robot Simulation packages, that consist of Gazebo (simulation) + MoveIt!2 (control) package combinations for some supported Industrial/Collaborative Robots (or Robot + Gripper combinations), and follows a common standard for a better understanding and further development.
This ros2_SimRealRobotControl repository is based on ros2_RobotSimulation, and contains some improvements and advanced features:
- Robot Bringup packages, that enable the control of REAL ROBOTS through ROS 2.
- The Pilz Industrial Motion Planner, which replaces the OMPL planner (MoveIt!2 default) used in ros2_RobotSimulation and allows for advanced motion control and features, such as cartesian speed control.
__NOTE__: Pilz Industrial Motion Planner is not included in ROS2 Foxy. Thus, OMPL planner has been used instead for the ROS2 Foxy version of ros2_SimRealRobotControl.
- In ros2_RobotSimulation, Robot Movements are triggered as individual ROS 2 Actions, each of them contained in a ROS 2 node. When executing Robot Programs (sequences) using ros2_execution, Robot Movements (execution steps) are executed by calling ROS 2 actions one by one. This introduces a small delay between steps. For ros2_SimRealRobotControl, all Robot Movements are contained in a single ROS 2 Action (therefore, a single ROS 2 node), and sequences are executed by calling a single ROS 2 Action from a python script. Thus, the delay introduced by ROS 2 Action calls is avoided, and the delay between movements now only depends on MoveIt!2's processing (plan+execute) time. Quicker and smoother results are obtained, closing the performance gap between ROS2-controlled robots and Industrial Manipulators.
- Improved simulation of object grasping: The new [IFRA_LinkAttacher](https://github.com/IFRA-Cranfield/IFRA_LinkAttacher) ROS2-Gazebo plugin developed by IFRA-Cranfield is used in ros2_SimRealRobotControl. This new plugin is more precise and works better than ros2_grasping in ros2_RobotSimulation.
In a nutshell, ros2_RobotSimulation is a great tool if you are new to ROS 2 and you wish to use it for Robot Simulation and Control, and ros2_SimRealRobotControl is appropriate for anyone willing to design, develop and test their own Robot applications using the ROS 2 packages (Gazebo+MoveIt!2+Bringup) provided.
__VIDEO: Simulation and Control of an ABB-IRB120 using ROS2__
[](https://www.youtube.com/watch?v=qaowbdYvG2M)
__VIDEO: Simulation and Control of a Universal Robots - UR3 using ROS2__
[](https://www.youtube.com/watch?v=grhYzt0wf8c)
(back to top)
## Installation
All packages in this repository have been developed, executed and tested in a Ubuntu 20.04 machine with ROS 2 Foxy. Please find below all the required steps to set-up a ROS 2 Foxy environment in Ubuntu and install the ROS 2-based Robot Simulation and Control packages.
1. __Set-up the Ubuntu+ROS2 PC for the Robot Simulation and Control__: The steps below need to be followed in order to set-up a proper ROS2 (Foxy) workspace for Robot Simulation and Control, and to be able to use ros2_SimRealRobotControl:
(1.1) Install Ubuntu 20.04: https://ubuntu.com/desktop
(1.2) Install Git:
```sh
# In the terminal shell:
sudo apt install git
# Git account configuration:
git config --global user.name YourUsername
git config --global user.email YourEmail
git config --global color.ui true
git config --global core.editor code --wait # Visual Studio Code is recommended.
git config --global credential.helper store
```
(1.3) Install ROS2 Foxy:
- Follow instructions in: [ROS2 Foxy Tutorials - Installation](https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html).
- Source the ROS2.0 Foxy installation in the .bashrc file (hidden file in /home):
```sh
source opt/ros/foxy/setup.bash
```
(1.4) Install MoveIt!2 for ROS2 Foxy ([REF: MoveIt!2 Website](https://moveit.ros.org/)):
```sh
# Command for BINARY INSTALL (recommended):
sudo apt install ros-foxy-moveit
```
A small improvement of the move_group_interface.h file has been developed in order to execute the Robot/Gripper triggers in this repository. Both the upgraded file and the instructions of how to implement it can be found here: [move_group_interface_improved.h](https://github.com/IFRA-Cranfield/ros2_SimRealRobotControl/tree/foxy/include)
(1.5) Create and configure the ROS2.0 Foxy ~/dev_ws environment/workspace:
- Follow instructions in: [ROS2 Foxy Tutorials - Create a ROS2 Workspace](https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace.html).
- Source the ~/dev_ws workspace in .bashrc file:
```sh
source ~/dev_ws/install/local_setup.bash
```
(1.6) Install ROS2 packages, which are required for ROS2-based Robot Simulation and Control:
```sh
# ROS2 Control + ROS2 Controllers:
sudo apt install ros-foxy-ros2-control
sudo apt install ros-foxy-ros2-controllers
sudo apt install ros-foxy-gripper-controllers
# Gazebo for ROS2 Foxy:
sudo apt install gazebo11
sudo apt install ros-foxy-gazebo-ros2-control
sudo apt install ros-foxy-gazebo-ros-pkgs
# xacro:
sudo apt install ros-foxy-xacro
```
2. __ABB DRIVER for ROS 2__: The installation of the [abb_ros2](https://github.com/PickNikRobotics/abb_ros2) driver is required for the control of any real ABB robot using ROS 2.
```sh
mkdir -p ~/dev_ws/src/ABBDriver
cd ~/dev_ws/src/ABBDriver
git clone https://github.com/PickNikRobotics/abb_ros2.git -b foxy
sudo rosdep init
rosdep update
vcs import < abb_ros2/abb.repos
rosdep install -r --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y
cd ~/dev_ws
colcon build
```
3. __Universal Robots ROS2 Driver__: The installation of the [ur-robot-driver](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver) driver is required for the control of any real UR robot using ROS 2. Binary install, for ROS2 Foxy:
```sh
sudo apt-get install ros-foxy-ur-robot-driver
```
4. __Import and install IFRA_LinkAttacher__:
```sh
cd ~/dev_ws/src
git clone https://github.com/IFRA-Cranfield/IFRA_LinkAttacher.git
cd ~/dev_ws
colcon build
```
5. __Import and install ros2_SimRealRobotControl__:
```sh
cd ~/dev_ws/src
git clone https://github.com/IFRA-Cranfield/ros2_SimRealRobotControl -b foxy
cd ~/dev_ws
colcon build
```
(back to top)
## Supported Robots
The Simulation & Control packages of the following Robots are currently available:
- [ABB IRB-120 Robot](https://github.com/IFRA-Cranfield/ros2_SimRealRobotControl/tree/foxy/irb120)
- [Universal Robots - UR3](https://github.com/IFRA-Cranfield/ros2_SimRealRobotControl/tree/foxy/ur3)
(back to top)
## ROS2 Packages
### ros2srrc_data
This package contains the data structures for the ROS 2 Actions and Messages that are used for the robot movements and sequence executions:
- __Move Action__: ROS 2 Action that executes the specific Robot Movement (MoveJ, MoveR, MoveL...).
- __Sequence Action__: ROS 2 Action that contains the whole sequence of "Move.action" actions.
- __MSG folder__: Custom ROS 2 Messages are kept in this folder. These are used to define specific ROS 2 Actions, which do have a different format according to the type of movement they refer to.
For further detail about the data structures, please click [here](https://github.com/IFRA-Cranfield/ros2_SimRealRobotControl/tree/foxy/ros2srrc_data).
### ros2srrc_execution
The ros2srrc_execution package contains the source code that executes both individual Robot movements and complete sequences or programs:
- __move.cpp__: ROS 2 Action Server -> Executes an individual Robot Motion, requested by calling "move.action".
- __sequence.cpp__: ROS 2 Action Server -> Executes a sequence, requested by calling "sequence.action".
- __sequence.py__: Python script that reads the program (sequence) from a ".txt" file, transforms it into the "sequence.action" format and executes it by triggering the ROS 2 Action Server defined in sequence.cpp.
For further detail about how Robot Movements and sequences are executed, please click [here](https://github.com/IFRA-Cranfield/ros2_SimRealRobotControl/tree/foxy/ros2srrc_execution).
### Robot Simulation and Control packages
For the ROS 2-based Robot Simulation and Control to be successfully achieved, 3 different ROS 2 packages are necessary (for each Robot/Application):
- __Gazebo package__: The Gazebo/Simulation package contains all the information related to the Gazebo Simulation of the Robot Cell/Environment. CAD and mesh files containing visual data and [.urdf]+[.xacro] files containing Robot (ROS-format) data are combined with ROS 2 control and simulation components, and a simple simulation of the Robot (without any motion control) is obtained in Gazebo.
- __MoveIt!2 package__: For the Robot to be moved and controlled, a ROS 2 MoveIt!2 package is required. This package contains all the information related to the ROS 2 - MoveGroup (moveit2) node that controls the robot and its behaviour.
- __Bringup package__: The Bringup package acts as the main connection point between ROS 2 and the Real Robot. It contains all the information about the robot controllers, and establishes the connection between moveit2 and the Real Robot. For the connection between ROS 2 and a Real Robot to be established, a ROS 2 Driver is required, which translates the ROS 2-based commands to the Robot Controller. This ROS 2 Driver is usually developed by the Robot vendor or a recognised ROS2-development company.
### IFRA_LinkAttacher
At IFRA-Cranfield we have developed a ROS2-Gazebo Plugin which enables the attachment of 2 different entity links in Gazebo. The plugin has been designed with the main purpose of simulating object pick and place tasks using Robot Manipulators. The link attachment/detachment feature is available through a ROS2 Service Server, which creates a temporary fixed joint between two links for the "ATTACH" request, and removes the previously generated joint for the "DETACH" service. Thanks to this functionality, objects can be easily attached to any end-effector and pick/place tasks can be simulated in Gazebo-ROS2.
For further detail about the link ATTACHER/DETACHER plugin, please click [here](https://github.com/IFRA-Cranfield/IFRA_LinkAttacher).
(back to top)
## Contributing
This repo contains only a few number of robots, end-effectors and simulation environments (layouts). Please do let us know if you wish to include a specific robot/end-effector or application into ros2_SimRealRobotControl!
The exact same thing for the ROS2 Robot Actions/Triggers: A few number of robot movements have been implemented, therefore please do let us know if you have any ideas of a potential Robot motions for our repo!
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. If you have a suggestion that would make this better, or you find a solution to any of the issues/improvements presented above, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks you very much!
(back to top)
## License
Intelligent Flexible Robotics and Assembly Group
Created on behalf of the IFRA Group at Cranfield University, United Kingdom
E-mail: IFRA@cranfield.ac.uk
Licensed under the Apache-2.0 License.
You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
Cranfield University
School of Aerospace, Transport and Manufacturing (SATM)
Centre for Robotics and Assembly
College Road, Cranfield
MK43 0AL, Bedfordshire, UK
(back to top)
## Cite our work
You can cite our work with the following statement:
IFRA-Cranfield (2023) ROS 2 Sim-to-Real Robot Control. URL: https://github.com/IFRA-Cranfield/ros2_SimRealRobotControl.
(back to top)
## Contact
Mikel Bueno Viso - Research Assistant in Intelligent Automation at Cranfield University
E-mail: Mikel.Bueno-Viso@cranfield.ac.uk
LinkedIn: https://www.linkedin.com/in/mikel-bueno-viso/
Profile: https://www.cranfield.ac.uk/people/mikel-bueno-viso-32884399
Dr. Seemal Asif - Lecturer in Artificial Intelligence and Robotics at Cranfield University
E-mail: s.asif@cranfield.ac.uk
LinkedIn: https://www.linkedin.com/in/dr-seemal-asif-ceng-fhea-miet-9370515a/
Profile: https://www.cranfield.ac.uk/people/dr-seemal-asif-695915
Professor Phil Webb - Professor of Aero-Structure Design and Assembly at Cranfield University
E-mail: p.f.webb@cranfield.ac.uk
LinkedIn: https://www.linkedin.com/in/phil-webb-64283223/
Profile: https://www.cranfield.ac.uk/people/professor-phil-webb-746415
(back to top)
## Acknowledgments
* [README.md template - Othneil Drew](https://github.com/othneildrew/Best-README-Template).
* [ROS 2 Documentation - Foxy](https://docs.ros.org/en/foxy/index.html).
* [PicNik Robotics - MoveIt!2 Documentation](https://moveit.picknik.ai/foxy/index.html).
* [ABB - ROS Repositories](http://wiki.ros.org/abb).
* [ABB - ROS 2 Driver (PickNik Robotics)](https://github.com/PickNikRobotics/abb_ros2).
* [Universal Robots - ROS 2 Driver](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver).
(back to top)