This project explores path generation in mechanism design: designing a four-bar linkage whose coupler curve stays as close as possible to 9 specified target points.


πŸ“‹ Abstract

Unlike traditional graphical or trial-and-error methods, this project employs a numerical optimization strategy. Using MATLAB, I built a kinematic model based on the Vector Loop Equation and utilized the fminsearch algorithm for multi-variable iterative solving of link lengths and initial angles. The process produced a feasible set of low-error mechanism parameters while satisfying Grashof’s theorem (full rotation condition).


πŸ›‘ The Problem

In a course project, we were given 9 fixed spatial coordinate points. The task was to design a four-bar linkage such that when the driving link rotates one full revolution, a specific point on the coupler traces a path that closely matches these 9 points.

This is a typical nonlinear optimization problem facing the following challenges:

  1. Multi-variable Coupling: Changing any single link length dramatically alters the entire trajectory shape.
  2. Geometric Constraints: The mechanism must perform a full 360-degree rotation (Crank-Rocker) without locking.
  3. Mathematical Complexity: The nonlinear position equations of the coupler cannot be solved analytically and require numerical methods.

πŸ› οΈ Technical Deep Dive

The core of this project lies in transforming a physical mechanism into a mathematical model and defining an objective function that the computer can “score.”

1. Mathematical Modeling: Vector Loop Method

To calculate the mechanism’s position at any angle, I used the Complex Numbers Method. As shown in the figure, the four-bar linkage is viewed as a closed vector loop:

$$\vec{r_2} + \vec{r_3} = \vec{r_1} + \vec{r_4}$$

Using Euler’s formula ($e^{i\theta} = \cos\theta + i\sin\theta$), this expands into real and imaginary parts:

$$r_2 e^{i\theta_2} + r_3 e^{i\theta_3} - r_4 e^{i\theta_4} - r_1 = 0$$

Through this equation, for each input driving angle $\theta_2$, we can derive the follower angle $\theta_4$ and coupler angle $\theta_3$ using geometric relationships, thereby calculating the precise coordinates $(x, y)$ of trajectory point $P$.

![Four-bar linkage vector loop diagram](/postImg/4-Bar Linkage/1.png)

2. Optimization Strategy

I chose MATLAB’s fminsearch (based on Nelder-Mead simplex method) as the solver.

  • Design Variables: Parameters to be adjusted include the lengths of 4 links ($L_1, L_2, L_3, L_4$) and the initial angle of the driving link ($\theta_{start}$).

  • Cost Function: To define “optimal,” I adopted the Least Squares concept. Calculate the sum of Euclidean distances between corresponding trajectory points and the 9 target points:

    $$Error = \sum_{i=1}^{9} \sqrt{(x_{target,i} - x_{calc,i})^2 + (y_{target,i} - y_{calc,i})^2}$$

    The algorithm’s goal is to find a parameter set that minimizes this $Error$ value.

3. Constraint Handling

Not all length combinations can form a rotatable mechanism. To ensure the mechanism operates smoothly through one full rotation without locking, it must satisfy Grashof’s Law:

$$S + L \le P + Q$$

(Where $S$ is the shortest link, $L$ is the longest link, and $P, Q$ are the remaining two links)

In implementation, I used the Penalty Function technique: before calculating the error, check whether current parameters satisfy the Grashof condition. If not (e.g., mechanism cannot complete full rotation), immediately return an extremely large error value (like Infinity), forcing the fminsearch algorithm away from that parameter region to find a feasible solution.


πŸ“Š Results & Conclusion

Through hundreds of iterations, the program converged to a feasible set of link length parameters. When plotted, the resulting coupler curve stayed close to the 9 target points, and the mechanism operated without obvious dead points.

This project clarified two engineering takeaways:

  1. Mathematical modeling reduces trial-and-error: Euler’s formula and vector methods turn mechanical motion into computable parameters.
  2. Numerical methods are useful for nonlinear constraints: When analytical solutions are difficult to obtain, clear objective functions and constraints can produce verifiable approximate solutions.

Results