Running the System - miloboyd/chess-robot GitHub Wiki
This guide will walk you through how to execute the program.
In order to execute the program to play chess, you must have ensured that the workspace has been set up effectively. Please refer to the Physical Setup instructions for more details on configuring the chess pieces, as well as configuring the ur3e robot and teach pendant.
ros2 launch realsense2_camera rs_launch.py
Step 1: Setup robot workspace for physical testing
- see lab instructor for help
Step 2: Build UR Workspace
# Build the workspace
cd ~/{workspace}
colcon build --symlink-install --packages-select rs2
# Source the workspace
source install/setup.bash
Step 3: Start robot
ros2 launch ur_onrobot_control start_robot.launch.py ur_type:=ur3e onrobot_type:=rg2 robot_ip:=<robot_ip> launch_rviz:=false
if you wish to test on a simulated robot:
ros2 launch ur_onrobot_control start_robot.launch.py ur_type:=ur3e onrobot_type:=rg2 robot_ip:=<robot_ip> launch_rviz:=false use_fake_hardware:=true
Common arguments:
-
use_fake_hardware
(default:false
): Use mock hardware interface for testing -
launch_rviz
(default:true
): Launch RViz with the robot model -
tf_prefix
(default:""
): Prefix for all TF frames
Replace <robot_IP> with your robot's actual IP address.
Step 4: run the UR3e pendant ur_driver (as in the hardware setup instructions)
Step 5: Launch MoveIt
In a new terminal:
ros2 launch ur_onrobot_moveit_config ur_onrobot_moveit.launch.py ur_type:=ur3e onrobot_type:=rg2
Step 6: Execute the run file
In two separate terminals:
ros2 run rs2 chess_core.py
ros2 run rs2 chess_robot
You should see a GUI pop up along with terminal commands expecting a start service signal. Click the start button in the bottom right corner to commence the program.
A new pop up should appear, which is the interface to input chess movements. For the first time, simply click finish without inputting a movement.
Back on the GUI interface, select human turn. The chess interface will reappear. input your chess movement. Green represents empty, and white and black the piece colours respectively. Once you select finish, the robot will take its turn, and you will input the move that the robot made. When you submit the robots turn, the chess piece window will reappear, requesting the players move. Then, the process will repeat.
ros2 run rs2 chess_core.py
this will launch the game, initialise the board and start the game with the player being white. it is currently configured in sim mode which doesn't use camera inputs for piece detection, insead the user must manually enter the piece positions using a gui. click the squares to toggle between white, black and empty.
If not using robot yet the code will wait for a response from the robot indicating that it has completed its move, if you don't have the robot working then send this command to a terminal window and the code will progress.
ros2 topic pub --once /move_complete std_msgs/Bool '{data: true}'
You will then need to manually enter the new piece position as entered by the ai in the CLI as camera is disabled.
The program will then loop until game is finished.
If you wish to test the current code for robot arm manipulation, see the following instructions:
Step 1: Setup robot workspace for physical testing
- see lab instructor for help
Step 2: Build UR Workspace
# Build the workspace
cd ~/ur_ws
colcon build --symlink-install --packages-select rs2
# Source the workspace
source install/setup.bash
Step 3: Start robot
ros2 launch ur_onrobot_control start_robot.launch.py ur_type:=ur3e onrobot_type:=rg2 robot_ip:=<robot_ip> launch_rviz:=false
if you wish to test on a simulated robot:
ros2 launch ur_onrobot_control start_robot.launch.py ur_type:=ur3e onrobot_type:=rg2 robot_ip:=<robot_ip> launch_rviz:=false use_fake_hardware:=true
Common arguments:
-
use_fake_hardware
(default:false
): Use mock hardware interface for testing -
launch_rviz
(default:true
): Launch RViz with the robot model -
tf_prefix
(default:""
): Prefix for all TF frames
Replace <robot_IP> with your robot's actual IP address.
Step 4: Launch MoveIt
In a new terminal:
ros2 launch ur_onrobot_moveit_config ur_onrobot_moveit.launch.py ur_type:=ur3e onrobot_type:=rg2
Step 5: Execute the run file
In another terminal:
ros2 run rs2 chess_robot
Note: the GUI can be started by itself, however when running the whole project you should start the other subsystems as noted above as well as the GUI before operating the GUI.
Step 1: run console commands
ros2 run rs2 chess_robot
This will start up the gui. As soon as the gui is open, the topic and service publishers are ready to go.