This repository contains the software stack for a KUKA LBR3R760iisy robot designed to play chess. The project combines the power of ROS 2's control system with a Webots simulation environment to create a chess-playing robot.
Chess-Playing KUKA Robot is a ROS 2 project that demonstrates the capabilities of the ros2_control framework for robot control. It combines the control software with a Webots simulation environment to simulate and play chess.
Key components of this project:
- board_manager ros2 package The project has a board_manager package that listens via a REST api for moves. All the moves are validated via the
chess
pip package and then sent towards the motion planner. A move is finished after the robot actually places it on the target position. It also comes with a basic frontend that usespygame
. - motion_planner ros2 package: The project uses the
moveit2
framework to calculate the inverse kinematics and the trajectories for the movement of the robot for chess piece manipulation. - controller ros2 package: The project uses the
ros2_control
framework to define the robot's hardware interfaces and controllers. - Webots Simulation: The KUKA robot is simulated in the Webots environment, allowing it to interact with the chessboard and chess pieces.
Before you begin, ensure you have the following prerequisites:
-
ROS 2: Install ROS 2 Humble according to your system's requirements.
-
Webots: Download and install Webots, as it's the simulation environment used for the project. The project uses Webots R2023b.
-
Move It! 2: Download and install Move It! 2, an open-source motion planning framework for ROS2, which this project uses.
-
All the packages defined in install_apt_dependencies. If you run Ubuntu 22.04, run
sudo ./dependencies/install_apt_dependencies.sh
. If you have a different Linux distribution or package manager, make sure to download the neccessary packages manually. -
Python3.10+ with the required pip packages defined in pip_requirements.txt. To install all of them, run
pip3 install -r dependencies/pip_requirements.txt
. -
A system with the necessary hardware requirements to run the simulation.
To install and run the chess-playing robot, follow these steps:
- Clone this repository:
git clone https://github.com/PetoAdam/chessbot.git cd chessbot
- Build the ros2 workspace:
TODO: might need mixin for moveit
cd ROS2 colcon build --symlink-install source install/setup.bash
To run the chess-playing robot, use the following commands in seperate terminals from the repository's root directory:
# Start the Webots simulation
cd Webots
python3 webots_launch.py default.wbt LBR3R760iisy
# Start ROS 2 control
cd ROS2
# make sure to have the ROS2 workspace built
source install/setup.bash
ros2 launch chessbot lbr3r760iisy_controller.launch.py
# Start inverse kinematics solver (MoveIt)
cd ROS2
# make sure to have the ROS2 workspace built
source install/setup.bash
ros2 launch moveit_chess_bot moveit_chess_bot.launch.py
# Start the board_manager service
cd ROS2
# make sure to have the ROS2 workspace built
source install/setup.bash
ros2 run board_manager board_manager_service
# for a custom map: edit board_manager/config/board_custom.yaml rebuild and run ros2 run: board_manager board_manager_service board_custom.yaml
# Start the frontend for chess
cd ROS2
python3 src/board_manager/board_manager/chess_gui.py
Note: Webots also has a streaming viewer option, which can be accessed on port 1234 of the machine running it. For example in the case of localhost: http://localhost:1234/index.html. If the computer running the simulation has no dedicated GPU, turning off rendering can drastically improve performance. To see what the robot does in the simulation, you can use the streaming feature from a different computer.
The repository allows for manual testing of the services of the project separately.
The simulator has a streaming viewer that lets users manually move the robot. Make sure the ros2_control package is not running. After starting the Webots simulation, open a browser and go to: http://localhost:1234/index.html Then connect to the simulation. After you have successfully connected to the simulation, follow the tutorial on the picture below: The positions of the joints can be adjusted by dragging the circles.
To test the ros2_control, both the simulation and the ros2_control has to be running. To test the arm movement, you can run this script from the ROS2/src/controller directory:
./trajectory.sh
It tests if your setup was successful and makes the robot move slightly right and left
To test the gripper movement:
ros2 topic pub /gripper_controller/gripper_command std_msgs/msg/Float64 "{data: 0.5}"
This should close the gripper.
It can only be tested together with the simulaton and the ros2_control component.
The board manager and the frontend can be tested completely separately from the other services, as there is a dummy motion planner, which simulates successful robot motion. To test it, run these scripts in separate terminals from the ROS2 directory (make sure that the ROS2 workspace is built, and sourced in every terminal):
ros2 run board_manager dummy_motion_planner
ros2 run board_manager board_manager_service
python3 src/board_manager/board_manager/chess_gui.py
When all the processes are started, you should be able to play chess on the frontend.
We welcome contributions to this project. If you find any issues or have suggestions for improvements, please create a GitHub issue or submit a pull request. We value your input!
Enjoy your chess-playing KUKA robot powered by ROS 2 and Webots! If you have any questions or need assistance, please don't hesitate to reach out to us.