This repository contains MATLAB scripts (and optional Python helpers) to enable the MyCobot Pro 600 robotic arm to follow a curved path detected from an image.
It integrates computer vision, coordinate mapping, and kinematic control with optional Simulink models for simulation.
| File | Description |
|---|---|
| cobotLineFollower.m | Main function mycobot_ik(image_path) — extracts a curve from an image, samples waypoints, maps them to robot coordinates, and computes joint angles via IK. Includes local helpers for skeleton-path finding and interpolation. |
| imageee.m | Script version of the image ➜ path ➜ waypoint pipeline (exploratory/notebook-style). |
| angle.m | Utility that formats and displays jointAngles_all over a simple time vector. |
| robott.m | Loads tocheck.urdf, sets a configuration, and visualizes the robot in MATLAB. |
| Rigiftreedof.m | Builds a multi‑DOF rigidBodyTree (supporting simulation/IK). |
| Forward.slx, inverse.slx, rigidtree.slx | Simulink models for FK/IK and rigid-body structure (optional). |
| tocheck.urdf | Robot model (URDF) used by robott.m. |
| Forward.py | (Optional) Companion Python script, if you prefer prototyping parts of the pipeline in Python. |
- MATLAB R2023a or later
- Image Processing Toolbox
- Robotics System Toolbox
- Simscape Multibody Toolbox (for Simulink models)
- Place an input image (black curve on white background) at, for example:
images/s11.jpeg. - From MATLAB, run:
jointAngles_all = mycobot_ik('images/s11.jpeg'); % in cobotLineFollower.m
- (Optional) Visualize or simulate:
robott % visualize the URDF model open('Forward.slx'); % or open('inverse.slx');
Output: jointAngles_all (N×6) containing joint solutions for sampled waypoints along the curve.
- Image ➜ Path: Thresholding → morphology → largest component crop → skeletonization → endpoints → BFS to trace a single path.
- Sampling: Evenly samples points along the traced skeleton length.
- Mapping: Converts pixels to millimeters using a scale factor and remaps to the robot frame.
- IK: Builds a
rigidBodyTree(modified DH, MDH transforms) and solves for each waypoint usinginverseKinematicswith a fixed pose orientation.
Call the pipeline and inspect angles:
jointAngles_all = mycobot_ik('images/s11.jpeg');
disp(jointAngles_all);Use the visualization helper:
robottSimulink (optional):
open('rigidtree.slx'); % structure
open('Forward.slx'); % forward kinematics
open('inverse.slx'); % inverse kinematics- “Fewer than 2 endpoints found”: Adjust
thresholdValueor lighting/contrast in the input image. - “No path found between endpoints”: Ensure a single continuous dark curve; reduce noise with larger morphology (
strel('disk', …)). - Unstable IK: Tweak initial guess in
cobotLineFollower.mor reduce waypoint spacing.
This repository is intended for educational and research use.