The complete methodology, mathematical modeling, and engineering design for this project are detailed in the university report (in Danish): Gruppe 5 Rapport - Computerized Alcoholism
This repository contains the software stack for an industrial robotics project utilizing a UR5 series robotic arm equipped with a Weiss WSG-50 gripper and an industrial camera (Basler pylon) to accurately throw a ping-pong ball into a target cup.
The software integrates computer vision, coordinate frame transformations, trajectory planning via Jacobian matrix calculations, database management, and real-time robot control via ur_rtde.
-
Machine Vision (
machinevision.cpp): Utilizes Basler pylon and OpenCV to capture images, remove optical lens distortion using intrinsic camera matrices and distortion coefficients, and compute homography perspectives (cv::getPerspectiveTransform) to map pixel coordinates to real-world table coordinates. Employs Hough Circle Transforms (cv::HoughCircles) to locate the ball and cup dynamically. -
Robot-to-Table Calibration (
calib.cpp): Implements the Kabsch algorithm using Singular Value Decomposition (SVD) and Eigen matrices to compute precise 3D rotation and translation vectors between the camera/table frame and the robot's TCP (Tool Center Point) frame. -
Projectile Motion Modeling (
projectilemotion.cpp): Computes the kinematic equations for projectile motion given a target cup position and flight duration. Translates Cartesian velocity vectors into joint velocities (QDot) and accelerations using the robot's Jacobian matrix. -
Robot Control Interface (
robotcontroller.cpp): Built on top of theur_rtdeC++ library andWeissWsg50gripper driver. Handles precise Cartesian and joint-space movements, vacuum/gripper sequencing, throw initialization, and emergency stopping. -
Database Engine (
database.cpp): Interfaces with an SQLite local database (project_db.db) using Qt SQL drivers to store and retrieve cell parameters, camera intrinsics, distortion coefficients, spatial homography translations/rotations, and experimental throw outcomes to track overall system accuracy.
Code/main.cpp: Main entry point handling system initialization, cell selection, state machine sequencing, and the throw execution loop.Code/machinevision.cpp/machinevision.h: Basler camera interfacing, undistortion routines, and circle/object detection for balls and cups.Code/calib.cpp/calib.h: SVD-based spatial calibration routine between robot coordinates and world vision frames.Code/projectilemotion.cpp/projectilemotion.h: Physics modeling for the throw trajectory and Jacobian inverse kinematics mapping.Code/robotcontroller.cpp/robotcontroller.h: UR5 RTDE control wrapper and Weiss gripper orchestration.Code/database.cpp/database.h: SQLite database management layer for configuration persistence and hit statistics.
- Operating System: Ubuntu 20.04 LTS (or compatible Linux environment for real-time control / URSim simulation)
- Libraries & Frameworks:
- C++11 or higher
- OpenCV 4.x with contrib modules
- Qt 5 (with SQLite support)
ur_rtde(UR Real-Time Data Exchange library)- Basler pylon Camera Software Suite
- Eigen3 math library
-
Clone the Repository:
git clone https://github.com/Therkelsen/Computerized_Alcoholism.git cd Computerized_Alcoholism -
Install Dependencies (Ubuntu 20.04 reference):
- Follow the detailed instructions inside the README installation subsections for setting up RTDE, OpenCV, and URSim (Java 8 + UR Offline Simulator).
-
Build the Project:
- Open the project in Qt Creator or configure via CMake:
mkdir build && cd build cmake .. make
- Open the project in Qt Creator or configure via CMake:
- Start your UR5 robot controller or launch the local URSim instance:
sudo ./start-ursim.sh
- Run the compiled application binary:
./Computerized_Alcoholism
- Follow the console prompt to select your active robot cell (1-4) or simulator (Cell 5). The program will load calibration data, move to the starting position, locate the ball and cup, execute the modeled throwing trajectory, release the ball at the calculated timestamp, and record performance metrics into the SQLite database.