- Ava Zahedi
- Marthinius Nel
- Ritika Ghosh
- Hanyin Yuan
The HockeyBot package allows a Franka robot to play air hockey. We use a realsense camera and computer vision to detect where the puck is on the air hockey table. Our TrajCalc node predicts the trajectory of the puck and sends those positions to our SimpleMove API, which tells the Franka to move to meet the puck. All of these tasks are integrated in our Main node, which completes our workflow and allows the robot to play repeatedly.
HockeyBotDescription.mp4
- Make sure ROS packages are most recent and up-to-date
sudo apt update
sudo apt upgrade
-
Install moveit:
sudo apt install ros-humble-moveit
-
Make a new ROS2 workspace and enter it
mkdir -p nuws/src
cd nuws
-
Install dependencies
rosdep install --from-paths src -r -y
-
Add the numsr colcon mixin
colcon mixin add numsr_patches file://$(pwd)/src/numsr_patches/index.yaml
colcon mixin update numsr_patches
-
Build the workspace
colcon build --mixin numsr
-
Install the udev rules
sudo cp src/librealsense/config/99-realsense-libusb.rules /etc/udev/rules.d
-
Source the environment
source /opt/ros/humble/setup.bash
-
Git clone
git@github.com:ME495-EmbeddedSystems/hw3group-HockeyBot.git
into the /src directory of the customer workspace. This file will install the ros dependencies required to run this project. -
Additionally, users will need to install Ubuntu install by using
sudo apt-get install python3-opencv
All code for this package was developed and tested in Python 3.
This project requires the following hardware components:
- RealSense Camera: realsense-ros can be installed with
apt install ros-humble-realsense2-camera
- Franka Emika Panda Robot (Panda Robot)
- Air-Hockey Table (include puck, puddle)
- To connect to the robot, plug in the ethernet from the robots workstation PC into the ethernet port on the users computer.
- The hardware must be set up by connecting the RealSense camera via USB cable.
Packages:
- Follow the steps on website (Turn on Franka) to start the Frank Robot.
- Connecting the RealSense camera (via USB cable) and the Franka Emika Panda arm (via Ethernet cable) to the user's computer.
- Launch the hockeybot package using the command
ros2 launch hockeybot main.launch.py robot:=false
.
The process loop of the robot is as follows:
hockeybot_startup.mp4
- Upon startup, the robot follows a start-up sequence to reach its home position. The robot follows a series of waypoints to reach the home x- and y-coordinates with an offset in the z. It then reaches down to grasp the paddle (with an adapter) and moves back up slightly. This slight increase in height allows the robot flexibility while moving, so that if it pushes down during movement, it will not apply a force into the table while still keeping the paddle level with the table.
ComputerVision.mp4
- Intel RealSense D435i is used at 480x270x90 allowing the puck to be tracked at 90 fps. As soon as the streaming has been enabled, this node detects the center of the table in pixel coordinates. Then with the help of the depth camera, the deproject function is used to convert pixel coordinates into real world coordinates with respect to the camera. Since the distance between the air hockey table and the Franka robot is known, points from the camera's frame of reference can be transformed to the robot's frame of reference. Next, with the help of OpenCV's HughCircles function the center of the puck is tracked in real time. For the calculation of the trajectory, the puck is only tracked when going towards the robot and up to the center of the table. In order to get rid of noise, before publishing the puck's position it is checked whether the point is close (with a prefixed tolerance) to the best fit line of the previous positions obtained. Note: The output video shows the tracked puck encircled with a black border, regardless of whether all these points are published (in other words, the video shows the contour for every direction of movement of the puck).
Traj_rviz_hockeybot.mp4
Calculates the predicted trajectory of the puck and the play waypoints for the robot by using two puck coordinates from computer vision. The node handles collisions by reflecting the impact angle about the normal line. The waypoints for the robot to hit the puck are constrained by the robot's workspace on the air hockey table. The most optimal waypoints are selected by considering all four sides of the robot's workspace. The robot will then move to the first waypoint that is on the predicted trajectory line of the puck and then move along the line to the second waypoint and hit the puck. A plot is dynamically generated and updated each time a new trajectory is calculated. The robot blocks if the trajectory is out of the workspace and unreachable.
HittingaPuck.mp4
- After receiving waypoint and goal positions, the robot receives service calls to move to those points, thereby meeting the puck along its trajectory and hitting it. If there is an edge case where the robot cannot successfully meet the puck given its trajectory, the robot will block instead.
- As the robot is moving to hit the puck, it also plans a path from where it hits the puck back to the home position. Once the robot detects that its end-effector has reached the goal, it begins executing the path back home. This process also resets all internal variables and restarts the loop so that the robot can continue playing.
- To launch the Franka along with the simple_move node
ros2 launch franka_moveit_config moveit.launch.py robot_ip:=dont-care use_fake_hardware:=true
. - Run the simple_move node with
ros2 run moveit_helper simple_move
. (Optional) Provide a starting configuration for planning withros2 service call /initial_service moveit_interface/srv/Initial "{x: 0.5, y: 0.0, z: 0.0, roll: 1.0, pitch: 0.04, yaw: 0.0}"
. - Call the service to plan path to specifies goal pose
ros2 service call /goal_service moveit_interface/srv/Goal "{x: 0.5, y: 0.0, z: 0.0, roll: 1.0, pitch: 0.04, yaw: 0.0}"
. - To execute the plan, use
ros2 service call /execute_service moveit_interface/srv/Execute "exec_bool: True"
. a. If you wish to cancel your plan without executing, pass exec_bool: False instead of True. - To add a box in the planning scene, use
ros2 service call /add_obj moveit_interface/srv/Addobj "{id: 1, x: 0.3, y: 0.6, z: 0.5, dim_x: 0.2, dim_y: 0.2, dim_z: 0.2}"
.