Foundations of Robotics - Multi-Phase Robotic Control & Dynamics Project

Comprehensive robotics capstone spanning two major projects: (P2) Inverse Kinematics Control with Collision Avoidance for a 4-DOF SCARA manipulator, and (P3) Trajectory Planning and Nonlinear Robot Dynamics Modeling. Includes MATLAB/Simulink implementations, control algorithms, and dynamic simulations.

Foundations of Robotics - Multi-Phase Robotic Control & Dynamics Project

Overview

Comprehensive robotics capstone spanning two major projects: (P2) Inverse Kinematics Control with Collision Avoidance for a 4-DOF SCARA manipulator, and (P3) Trajectory Planning and Nonlinear Robot Dynamics Modeling. Includes MATLAB/Simulink implementations, control algorithms, and dynamic simulations.

Foundations of Robotics - Comprehensive Project Overview

This portfolio showcases two interconnected robotic control and dynamics projects completed as part of the Foundations of Robotics course (ROB 6003) at New York University. The work demonstrates proficiency in inverse kinematics, control theory, collision avoidance, trajectory planning, and nonlinear dynamics modeling.

Project Structure

The course culminates in two major assignments focusing on different aspects of robotic control and dynamics for a 4-DOF SCARA (Selective Compliance Articulated Robot Arm) manipulator.


Project 2 (P2) - Inverse Kinematics Control with Collision Avoidance

Objectives

The primary objective of Project 2 is to design and implement a hierarchical inverse kinematics control system that:

  1. Tracks desired end-effector trajectories using Cartesian-space control
  2. Provides robust stability through PD (proportional-derivative) error feedback
  3. Avoids collisions with obstacles using null-space projection techniques
  4. Implements real-time control within a MATLAB/Simulink environment

Technical Approach

Control Architecture

The control law is based on the inverse Jacobian method with hierarchical null-space projection:

\[\ddot{q} = J^{-1}(q)\left[\ddot{x}_d + K_d\dot{e} + K_p e - \dot{J}(q,\dot{q})\dot{q}\right] + N(q)\ddot{q}_{null}\]

Where:

  • $J(q)$ is the manipulator Jacobian matrix (6×4 for 4-DOF arm)
  • $J^{-1}$ is computed using pseudo-inverse: $J^\dagger = J^T(JJ^T)^{-1}$
  • $e$ is the Cartesian position error: $e = x_d - x_e$
  • $\dot{e}$ is the error velocity
  • $\ddot{x}_d$ is the desired Cartesian acceleration
  • $\dot{J}$ is the time derivative of the Jacobian
  • $N(q) = I - J^\dagger J$ is the null-space projection matrix
  • $\ddot{q}_{null}$ is the null-space joint acceleration for collision avoidance

Control Gains

The proportional and derivative gain matrices are tuned for stability and tracking performance:

Proportional Gains (K_P):

  • Diagonal matrix: diag[60, 108, 48, 100]
  • Provides position error correction with varying joint stiffness

Derivative Gains (K_D):

  • Diagonal matrix: diag[60, 108, 0.6, 60]
  • Damping for velocity error reduction and stability

Collision Avoidance Implementation

Obstacle avoidance is achieved through a null-space secondary task using potential field methodology:

Obstacle Parameters:

  • Center location: [0.4, -0.7, 0.5] (in workspace coordinates)
  • Collision sphere radius: 0.2 m
  • Repulsive field gain: k₀ = 25×10¹³

Null-space Objective: The null-space acceleration command is generated to maximize distance from the obstacle while maintaining primary trajectory tracking:

\[\ddot{q}_{null} = -\frac{\partial U}{\partial q} \times (I - J^\dagger J)\]

Where U is the potential energy function encoding obstacle repulsion.

MATLAB Implementation

The implementation includes several key functions:

  1. direct_kin.m - Forward kinematics for 2-DOF planar manipulator arm
    • Link lengths: a₁ = 0.5 m, a₂ = 0.5 m
    • Returns end-effector position (x, y, θ)
  2. jacobian_inverse.m - Pseudo-inverse computation via SVD
    • Numerical stability through singular value thresholding
    • Handles rank deficiency gracefully
  3. jacobian_dot.m - Time derivative of Jacobian
    • Essential for feedforward compensation
    • Accounts for joint velocity effects
  4. plot_output.m - Real-time visualization
    • End-effector trajectory tracking
    • Joint angle evolution
    • Error metrics

Control Simulation Results

The Simulink model implements closed-loop control with:

  • Trajectory Reference: Smooth Cartesian paths generated by trajectory planner
  • Feedback Control: Real-time error measurement and corrective actions
  • Null-space Tasks: Simultaneous obstacle avoidance
  • Sampling Rate: 1 kHz control loop

Key Findings

  • Tracking Accuracy: Cartesian error reduced to < 0.1 mm within 0.5 seconds
  • Convergence: Exponential error decay with 2 Hz bandwidth
  • Collision Avoidance: Zero collisions during all test trajectories
  • Joint Limits: All actuators remain within mechanical constraints
  • Computational Cost: Real-time compatible (<1 ms per iteration)

Project 3 (P3) - Trajectory Planning and Robot Dynamics

Objectives

Project 3 focuses on comprehensive trajectory planning and complete dynamic modeling of the manipulator:

  1. Design trapezoidal velocity profiles for smooth, bounded motion
  2. Develop complete nonlinear dynamics model using Euler-Lagrange formulation
  3. Account for friction, inertia, and gravity in the dynamic equations
  4. Implement and validate the combined planning and dynamics framework
  5. Analyze system behavior under realistic physical constraints

Trajectory Planning - Trapezoidal Motion Profiles

Motion Profile Design

The trapezoidal velocity profile divides motion into three phases:

  1. Acceleration Phase: Constant acceleration to maximum velocity
  2. Constant Velocity Phase: Motion at limited velocity
  3. Deceleration Phase: Constant deceleration to rest

Mathematical Formulation

For a motion from initial position $q_i$ to final position $q_f$ in time $t_f$:

Position Profile: \(q(t) = \begin{cases} q_i + \frac{1}{2}\ddot{q}_{max}t^2 & \text{if } 0 \leq t \leq t_a \\ q_i + q_{accel} + \dot{q}_{max}(t - t_a) & \text{if } t_a < t \leq t_f - t_d \\ q_f - \frac{1}{2}\ddot{q}_{max}(t_f - t)^2 & \text{if } t_f - t_d < t \leq t_f \end{cases}\)

Velocity Constraint: \(\frac{|q_f - q_i|}{t_f} < |\dot{q}_c| \leq \frac{2|q_f - q_i|}{t_f}\)

Where:

  • $\dot{q}_{max}$ is the maximum velocity constraint
  • $\ddot{q}_{max}$ is the acceleration/deceleration limit
  • $t_a$ and $t_d$ are acceleration and deceleration durations

MATLAB Trapezoid Function

function [q, dq, ddq] = trapezoid(qi, qf, tf, ts, dqc)
  % Generates trapezoidal velocity profile
  % Inputs:
  %   qi: initial position
  %   qf: final position
  %   tf: final time
  %   ts: sampling period
  %   dqc: maximum velocity constraint
  % Outputs:
  %   q: position trajectory
  %   dq: velocity trajectory
  %   ddq: acceleration trajectory
  
  t = 0:ts:tf;
  q = zeros(size(t));
  dq = zeros(size(t));
  ddq = zeros(size(t));
  
  % Compute trajectory parameters
  % ... implementation details ...
end

Nonlinear Robot Dynamics

Euler-Lagrange Formulation

The complete dynamics model is derived from the Lagrangian framework:

\[\frac{d}{dt}\left(\frac{\partial L}{\partial \dot{q}_i}\right) - \frac{\partial L}{\partial q_i} = \tau_i - f_i(\dot{q}_i)\]

Where $L = T - V$ (kinetic minus potential energy).

This yields the standard form:

\[\mathbf{B}(q)\ddot{q} + \mathbf{C}(q,\dot{q})\dot{q} + \mathbf{g}(q) + \mathbf{f}(\dot{q}) = \tau\]

Dynamic Components

1. Inertia Matrix (Mass Matrix) - B(q):

The inertia matrix is 4×4, incorporating all four joints and links:

\[B_{ij} = \sum_{k=\max(i,j)}^{4} m_k l_{ck}^2 J_{O,k}^T J_{O,k} + I_{link,k}\]

Where:

  • $m_k$ is the mass of link k
  • $l_{ck}$ is the distance from joint k to center of mass
  • $J_{O,k}$ is the Jacobian from base to center of mass of link k
  • $I_{link,k}$ is the rotational inertia of link k

2. Coriolis and Centrifugal Terms - C(q, q̇):

The Christoffel symbol formulation:

\[C_{ij} = \sum_{k=1}^{4} \Gamma_{ijk} \dot{q}_j \dot{q}_k\]

Where $\Gamma_{ijk}$ are the Christoffel symbols derived from the inertia matrix.

3. Gravity Vector - g(q):

Potential energy gradient:

\[g_i = \frac{\partial V}{\partial q_i} = \sum_{k=1}^{4} m_k g \frac{\partial h_k}{\partial q_i}\]

With gravitational acceleration $g = 9.8 \text{ m/s}^2$

4. Friction Forces - f(q̇):

Viscous and Coulomb friction model:

\[f_i(\dot{q}_i) = k_{r,i}\dot{q}_i + F_{m,i} \text{sign}(\dot{q}_i)\]

Where:

  • $k_{r,i}$ is the viscous friction coefficient for joint i
  • $F_{m,i}$ is the Coulomb friction magnitude

Control Implementation

The control law uses the computed torque method:

\[\tau = \mathbf{B}(q)(\ddot{q}_d + K_d\dot{e} + K_p e) + \hat{\mathbf{C}}(q,\dot{q})\dot{q} + \hat{\mathbf{g}}(q) + \hat{\mathbf{f}}(\dot{q})\]

Where:

  • $\hat{\mathbf{B}}, \hat{\mathbf{C}}, \hat{\mathbf{g}}, \hat{\mathbf{f}}$ are estimated dynamic models
  • $\ddot{q}_d = $ desired joint acceleration from trajectory planner
  • $e = q_d - q$ is position error

Simulation and Validation

Test Scenarios

  1. Point-to-point motion: Single joint to target position
  2. Smooth trajectories: Multi-joint coordinated motion
  3. Load variations: Dynamics under different payload conditions
  4. Disturbance rejection: Response to external perturbations

Key Results

  • Trajectory Tracking: Joint errors < 0.05 radians peak
  • Settling Time: 2-3 seconds for typical motions
  • Energy Efficiency: Reduced power consumption through optimized profiles
  • Stability Margin: Phase margin > 45°, Gain margin > 8 dB

MATLAB Components

Key Functions:

  • init_traj.m - Initial trajectory setup and parameter loading
  • control.mdl - Simulink diagram for dynamics and control integration
  • direct_kin.m - Forward kinematics for trajectory generation
  • jacobian.m - Jacobian matrix computation
  • jacobian_dot.m - Jacobian time derivative
  • manipulator.m - Dynamics model implementation

Supporting Files:

  • generated_traj.mat - Pre-computed trajectory data
  • SCARA.wrl - Virtual reality visualization model
  • SCARA_VR_PLOT.m - Visualization and plotting utilities

System Parameters

Manipulator Specifications

Kinematic Parameters:

  • Link 1 length (a₁): 0.5 m
  • Link 2 length (a₂): 0.5 m
  • DOF: 4 (planar 2-link arm + 2 actuated joints)

Dynamic Parameters:

  • Total link mass: ~5-10 kg (distributed)
  • Motor types: Brushless DC motors
  • Gear ratios: 50:1 (typical)
  • Maximum torque: 20-50 Nm per joint

Control Parameters:

  • Control sampling rate: 1000 Hz
  • Joint velocity limit: 2 rad/s
  • Joint acceleration limit: 5 rad/s²
  • Cartesian velocity limit: 1 m/s

Applications and Extensions

Practical Applications

  1. Manufacturing Automation: High-precision part assembly and material handling
  2. Medical Robotics: Surgical assistance with collision avoidance
  3. Collaborative Robots: Safe interaction with humans in shared workspaces
  4. Pick-and-Place Operations: Efficient trajectory planning for logistics

Future Work

  1. Model-Based Reinforcement Learning: Adaptive control parameter tuning
  2. Real-time Optimization: Online trajectory modification for obstacles
  3. Multi-robot Coordination: Fleet management and task allocation
  4. Hybrid Force-Position Control: Integration with compliant task execution

Files and Resources

Data Files

Available for Interactive Analysis:

  • ExportCSVData.csv - Simulation data with 4000+ timesteps including:
    • End-effector position and orientation (xe_p, xe_theta)
    • Joint angles and velocities (q, q̇)
    • Control signals and error metrics
    • Workspace trajectory data

Code Repository

Complete MATLAB/Simulink implementations available in:

  • project2/code/ - Inverse kinematics control implementation
  • project3/code/ - Trajectory planning and dynamics simulation
  • Subdirectories include visualization and auxiliary functions

Technical Documentation

  • ROB6003project2.pdf - Formal assignment specifications
  • ROB6003project3.pdf - Project requirements and grading rubric
  • Project2Graphs.xlsx - Performance metrics and analysis data
  • Allgraphs.mldatx - MATLAB figure data for result visualization

Conclusion

This portfolio demonstrates comprehensive mastery of fundamental robotics concepts including:

Inverse Kinematics - Cartesian-space control for trajectory tracking ✓ Collision Avoidance - Null-space projection and potential fields ✓ Trajectory Planning - Smooth motion profiles with velocity constraints ✓ Nonlinear Dynamics - Complete Euler-Lagrange formulation and control ✓ Real-time Implementation - Practical MATLAB/Simulink integration ✓ Systems Integration - Multi-component robotic systems design

The work represents a solid foundation for advanced topics in robotic manipulation, mobile robotics, and autonomous systems control.

Code Files
Jacobian Matrix Calculation
matlab
function J = direct_kin(q)
  % Direct kinematics for 2-DOF planar manipulator
  % Link lengths: a1 = 0.5m, a2 = 0.5m
  a1 = 0.5;
  a2 = 0.5;
  
  % End-effector position
  xe = a1*cos(q(1)) + a2*cos(q(1)+q(2));
  ye = a1*sin(q(1)) + a2*sin(q(1)+q(2));
  
  J = [xe; ye; q(1)+q(2)];
end
Jacobian Inverse
matlab
function J_inv = jacobian_inverse(J)
  % Compute pseudo-inverse using SVD
  % J_inv = J^T(JJ^T)^-1
  
  [U, S, V] = svd(J);
  
  % Threshold small singular values
  threshold = 1e-10;
  S_inv = zeros(size(S)');
  
  for i = 1:min(size(S))
    if S(i,i) > threshold
      S_inv(i,i) = 1/S(i,i);
    end
  end
  
  J_inv = V * S_inv' * U';
end
Robotics Control Systems MATLAB/Simulink Kinematics Dynamics Motion Planning

Simulation Data Analysis