TicTacToe-Robot
Table of Contents
Introduction
Bored of playing alone?! Play Tic-Tac-Toe with a robot!
A combination of open software platform (ROS2) with safety sensors to handle stategic and safety related tasks by a cobot. Using a fixed usb camera, a safety light curtain integrated to the robot hardware and a piece of magic from ROS2, this project allows you to play the game of Tic-Tac-Toe with a UR3. The aim of the project is to showcase the possibility of using an open software platform like ROS2 along with a low cost cobot for undertaking factory floor operations for lower cost.
Package Setup
Clone the repository by using the following code:
$ git clone https://git.fh-aachen.de/lab-wollert/model-factory/cobot_gaming.git
Code Execution
Run the following command to install all ROS dependencies:
$ cd <your_workspace_name>
$ rosdep install --from-paths src --ignore-src -y
Inside the "thesis_launch.py" in the ur_bringup package, change the workspace name for the params extension of "usb_cam" package, into the name of your workspace.
Build and source your Workspace
$ cd <your_workspace_name>
$ colcon build
$ source install/setup.bash
Run the following master command to run all the necessary node:
$ ros2 launch ur_bringup thesis_launch.py
Additional Information
At the end of game or when a keyboard interrupt is triggered in the "Game_Screen", the "Object_Detection" terminal screens will also be shutdown. This leaves the UR3-ROS2 Driver, UR3-ROS2 Moveit , MovetoPos terminal ,and the USB camera still to be shut down manually.
Camera Identification
To detect the camera index/"video_device" id of the required usb camera, run:
$ /bin/python3 /home/<user_name>/<your_workspace_name>/src/usb_cam/launch/Support/camera_detection_script.py
Then change the "video_device" id in the file "params.yaml" found under the location:
/home/<user_name>/<your_workspace_name>/src/usb_cam/config
Individual commands
UR3 ROS2 Driver:
$ ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur3 robot_ip:=192.168.1.102 launch_rviz:=false use_fake_hardware:=false
UR3 ROS2 MoveIt:
$ ros2 launch ur_moveit_config ur_moveit.launch.py ur_type:=ur3 launch_rviz:=true
ROS2 node to execute robot motion:
$ ros2 launch ur_bringup movetopos_launch.py
USB camera in ROS2 :
$ ros2 run usb_cam usb_cam_node_exe --ros-args --params-file /home/user/<your_workspace_name>/src/usb_cam/config/params.yaml
ROS2 node to execute object detection:
$ ros2 run detection_pkg object_detection_node
ROS2 node to run Game Algorithm
$ ros2 run algorithm_pkg algorithm_node
How To: Start up the Demonstrator
Initial
-
Plug in the Robot and the laptop to power, make sure, that the emergency stop button on the HandPanel is disengaged.
-
Connect the robot to the laptop with the ethernet cable.
-
Connect the camera to the laptop.

Boot
-
Turn on the laptop.
-
user: , pwd: spacebar (not typed out)
-
Turn on the Robot via the "On" button on the HandPanel!
-
After the robot has booted, click "Go to initialization screen" on the HandPanel.

- Press "on" to enable the robot.

- When the robot shows "idle", press "start"

- If the state is shown "normal", press "ok" in the bottom right corner.

Positioning
-
Place all the dots on the game board on the white playing sheet. These borders mark, where the robot will try and grab a dot.
-
The Robot requires a certain starting position for optimal path planning.
-
Holding the brake release button on the back of the HandPanel disables the brakes. Hold this button and move the Robot to the position as seen in the following image! Realease the button on the HandPanel once you're done!


Launch file
-
On the Laptop, open a terminal, and type the following command:
$ ros2 launch ur_bringup thesis_launch.py -
This will automatically launch all the needed ROS Nodes!
-
Wait until the program RVIZ opens up on the laptop.
-
On the robot HandPanel, press the "play" symbol on the bottom of the screen.


- You will now most likely see the variables on the right side of the HandPanel's screen that are incoming from the laptop.

- The status on the HandPanel of the robot should show "Running" and "ExternalCntrl..."
- Check in RViz, if the position of the robot in the visualisation matches the position of the real robot!
- If this is not the case. The launch script might need to be restarted again. But before, all the terminal tabs that opened, need to be closed with "Ctrl+C" in every terminal window.
Start Playing
- In the Terminal Tab "Game_Screen" you can interact with the robot.
- The first player always plays with the RED dots!
- Choose if you or the robot should start!
After a game
-
If a game is over, please remove all the dots from the field before starting another round!
Troubleshooting
Light
- In RViz, check the camera feed. The image need to be clearly visible, light will have a big impact on the object detection algorithm!
Visualisation not the same
- The initial pose of the robot was not detected by Rvis and the corresponding node. Please stop all nodes, and restart the launch file.
Long Path Planning
- Some positions require a lot of path planning. You can check in RViz, to see if the "violet" robot shadow is performing any movement. This is the path planner checking paths.
- If this is the case, give the planner a little bit of time!
- If not, try closing the nodes again and restarting the launch file.
- The robot might need a different initial starting position, or some dots on the board are placed too close together or not on the white part of the board.