📘 For the Spanish version, see README_es.md
Simulates a 3-DOF planar robot that extracts the contours of an image and generates a trajectory to animate the drawing process.
Includes smooth transitions between segments (pen-up/pen-down) and an analytical inverse kinematics model.
Class project (UDLAP). Originally implemented in MATLAB and later migrated to Python for potential integration with a real robot.
Tested on Ubuntu 20.04 using Python 3.11.
- Tested on Ubuntu 20.04 + Python 3.11.
- Includes example images (
/data) and screenshots (/docs). - Suggested assignment: extend the code to export CSV/G-code or implement cubic-spline interpolation.
- Python 3.11
- Ubuntu 20.04 (tested)
- See dependencies in
requirements.txt:roboticstoolbox-python(>= 1.1.1)spatialmath-python(>= 0.10.0)numpy(>= 1.26.4)opencv-python(>= 4.11.0.86)matplotlib(>= 3.7.4)
# clone
git clone https://github.com/Baladier/robot-planar-dibujante.git
cd robot-planar-dibujante
# (optional) virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
pip install -r requirements.txtPlace an image inside the data/ folder and edit the path in the script if necessary:
python src/RobotPlanarDibujante.pyThe robot will detect image contours using the Canny method and compute the trajectory to simulate the drawing process.
src/ → main code (kinematics, planning, animation)
data/ → input images (examples: gato1.jpg, gato2.jpg…)
docs/ → screenshots or generated animations
The code can be adapted for a physical 3-DOF arm or SCARA-type manipulators. Suggestions:
-
Replace simulation functions (
plot,jtraj) with actual motion commands (e.g.,MoveJ,MoveLin URScript or G-code for CNC systems). -
Implement a communication layer:
- UART / USB serial (Arduino, STM32, or ESP32) to transmit
(x, y, θ)coordinates. - Ethernet / TCP for industrial arms (e.g., UR5, Dobot, myCobot).
- UART / USB serial (Arduino, STM32, or ESP32) to transmit
-
Use the inverse kinematics results from this script as reference targets for PID or LQR controllers on real axes.
-
Add a velocity-planning or acceleration-smoothing module (s-curve, quintic splines).
- Arduino Due / Mega with A4988 or TMC2209 drivers (for servos or steppers).
- Raspberry Pi / Jetson Nano to combine image processing and motion control.
- STM32 Nucleo / ESP32 for low-cost systems with high serial speed.
- UR5 (Universal Robots) or similar arms for direct connection via
roboticstoolboxorRTDE.
- Implement a cubic-spline interpolation module for smoother paths.
- Add support for variable stroke thickness or intensity based on image gradients.
- Include an export mode to CSV or G-code, allowing real robots to execute the trajectory offline.
- Integrate a 3D visualization mode using
matplotlib.animationorpyvista.
Python (this code)
│
├─ Generates (x, y, θ) points
│
└─ Sends via Serial → Arduino / ESP32
↓
Converts to PWM / step signals
↓
Moves axes (X, Y, θ)
Author: Alan Beltrán Based on the collaborative work of the planar-robotics team (UDLAP). License: MIT
For questions or comments about the code:
You may also open issues or suggestions directly in this repository.
