This project provides a MATLAB-based framework to control a Universal Robots UR5 using ROS 2, inverse kinematics, and external perception inputs (camera or cage tracking).
- Real-time robot state publishing
- ROS2-based communication
- IK-based motion planning
- Debug/manual control mode
- Camera or cage-driven target execution
- Tool output control (gripper)
In a terminal of your PC, you MUST first run:
source /opt/ros/humble/setup.bash
ros2 launch ur_robot_driver ur_control.launch.py \
ur_type:=ur5 \
robot_ip:=147.250.35.40 \
launch_rviz:=false
This step must be done before MATLAB scripts.
It starts the UR driver and enables robot communication.
publisher.m
- Publishes robot pose (TransformStamped) in /robot_pose
main2.m
- Subscribes to:
- /instruction_cage (cage tracking)
- OR /object_positions (camera tracking)
- Receives target positions
- Computes inverse kinematics (IK)
- Sends joint commands to UR5 robot
- Open terminal → start UR driver (see above)
- Open MATLAB #1 → run publisher.m
- Open MATLAB #2 → run main2.m
- Wait for incoming target point (camera or cage)
When a point is received:
- Press ENTER → robot moves to target
- Stop execution anytime with CTRL + C
- Robot only moves after user confirmation (ENTER)
- Incoming points are throttled (prevents spam commands)
- Robot is locked during execution (prevents collisions)
ur5_script.m
This script:
- Loads UR5 robot model
- Computes IK for a given position
- Sends robot using computed joint angles (qSol)
- Returns robot to home before execution
- Robot is placed or measured at a known pose
- IK is computed for a target position
- Robot is optionally returned to home configuration
- User manually sends joint configuration:
sendJointConfiguration(ur, qSol, 'EndTime', 5);
This mode is used for:
- IK debugging
- Reachability testing
- Calibration validation
- Motion planning verification
- No camera or cage input
- No ROS2 topic subscription
- Fully manual and deterministic