ROS Turtle Pong

This video shows the first version of the Pong arcade video game for the Robot Operating System (ROS 1 Noetic) using turtlesim. The post will explain how the turtle_pong package for ROS’ turtlesim was created.

This project is part of the Robocademy Robot Operating System Learning Path by Lentin Joseph.

The source code is hosted on GitHub.

Create Empty ROS Package

The first step is to create an empty ROS package and specify the required dependencies. Note, that it is possible to add missing dependencies later on. Inside a ros workspace use the catkin create command from catkin-tools to creat the empty turtle_pong package:

catkin_ws/src$ catkin create pkg turtle_pong \
    -a "Franz Pucher" "ros@fjp.at" \
    -m "Franz Pucher" "ros@fjp.at" \
    -l "MIT" \
    -d "Pong game for ROS turtlesim." \
    --catkin-deps roscpp

Class Architecture

The game is made up of three nodes:

  • ball a turtle that acts as the ball and contains logic to bounce off walls.
  • key the turtles representing the paddles which are controlled with the keyboard to move them up and down.
  • pong node that spawns the three turtles and keeps track of the game state.
ROS Computation Graph.

The ball class subscribes to three poses, the ball itself and the two players.

Note: To use class methods as callbacks see the wiki page Tutorials/UsingClassMethodsAsCallbacks.

ROS Computation Graph.

References

Leave a comment