You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this project, a rigid bar is connected to a sliding block along a horizontal track. The sliding block is connected to a spring that stretches and compresses. The rigid bar $L = 0.4~m$ acts as a compound pendulum.
$x_1-y_1-$ describes block 1 position and orientation, $\theta_1$
$x_2-y_2-$ describes the rigid bar position and orientation, $\theta_2$
The applied forces are,
Spring attached to block 1, $F = -k x_1$ where $k = 10~N/m$
Gravity acting on block 1 and the rigid bar, $F_1 = -m_1g\hat{j}$ and $F_2 = -m_2 g\hat{j}$ where $m_1 = 0.1$ kg and $m_2 = 0.3$ kg
The objectives of this project were to:
Determine constraint equations $C(\mathbf{q},~t)$
Create an augmented solution method for the dynamic motion of these two moving parts
Visualize the motion of the system as the two parts complete at least one oscillation
Calculate and show (graph or vectors) the constraint forces acting on the 2-body system
Results
Mechanism Animation
Mechanism Animation with Reaction Force Vectors
Positions vs. Time
Velocities vs. Time
Accelerations vs. Time
Constraint Forces vs. Time
Constraint Residual
Conclusions
The simulation above was derived using the Augmented Multibody Dynamics (MBD) approach and demonstrates the coupled dynamics of a spring-block system with an attached compound pendulum. For this simulation, the bar is released from rest at a horizontal position ($\theta_2 = 0$) with the block at the spring's natural length ($x_1 = 0$). Gravity then pulls the bar downward, beginning the simulation. As the bar swings, it pulls on the block through the pin joint, dragging the block along the track. The spring then pulls the block back. As a result, this coupling between the bar and the block through the pin creates oscillation in both $\theta_2$ and $x_1$.
A few important conclusions can be drawn from the results. From the position plots, one can observe that the block position $x_1$ oscillates while $y_1$ and $\theta_1$ remain at zero, confirming that the track and rotation constraints remain satisfied throughout the simulation.
The constraint force plots and the animation with constraint force vectors demonstrate the magnitude and direction of all constraint and reaction forces. The track normal force ($\lambda_1$) oscillates as the bar swings. When the bar swings through the vertical position, the centripetal acceleration increases the load on the track and the pin.
The pin joint reaction forces ($\lambda_3$, $\lambda_4$) show the $x$ and $y$ components of the force transmitted between the bar and block at the hinge. In the animation with constraint force vectors, one can observe that the pin force on the block (red) and bar (purple) are always equal in magnitude and opposite in direction, demonstrating Newton's third law at the joint. It should be noted that the constraint $C_2 = \theta_1 = 0$ represents the track preventing rotation of the block, and $\lambda_2$ is the moment that the track would need to exert to enforce that constraint. Since all forces act through the block's center of mass, there is no moment for the constraint reaction force to oppose; therefore, it remains zero throughout the entire simulation.
Finally, the constraint residual plot confirms that all constraints remain satisfied to high precision throughout the simulation due to the Baumgarte stabilization technique with $\alpha = \beta = 5$.
Derivations
Note: the following derivations use GitHub-compatible Markdown/LaTeX formatting. Certain expressions (e.g., subscripts or matrix notation) may need modification for standard LaTeX/Markdown environments.
In planar (2D) multibody dynamics, each unconstrained body has 3 degrees of freedom:
Translation in the $x$-direction
Translation in the $y$-direction
Rotation by angle $\theta$.
Therefore, the generalized coordinate vector for this project can be expressed as:
If the center of body i is located at $\vec{R}_i = [x_i, y_i]^T$ in the global coordinate system and orientation $\theta_i$, then point p located at $\vec{s}^{(i)} = [s_x, s_y]^T$ in the body's local frame has global position:
For this project, there are 6 coordinates and 2 degrees of freedom (the block is free to translate horizontally, and the bar is free to rotate). Therefore, $6 - 2 = 4$ constraint equations are required.
Block Center (Body 1)
The pin joint connects at the center of the block. In the block's local frame, the center is at the origin: $\vec{s}_{pin,1} = [0, 0]^T$. Therefore, the pin location on the block in global coordinates is:
The bar’s local $x$-axis runs along its length. The bar has length $L$, and its center of mass is at the midpoint. The end that connects to the block is at local coordinates $\vec{s}_{pin,2} = [-L/2,~ 0]^T$
The other end of the bar (the free, swinging end) is at local coordinates $\vec{s}_{free} = [L/2,~ 0]^T$. Therefore, this point can be expressed in global coordinates as:
The block slides along a horizontal track at $y = 0$, so the center of the block must remain at $y_1 = 0$:
$$
C_1 = y_1 = 0
$$
This eliminates vertical motion of the block, and the track must exert a normal force to maintain this constraint.
Constraint $C_2$: Sliding Joint (Orientation)
Due to the sliding joint, the orientation of the block is constrained to:
$$
C_2 = \theta_1 = 0
$$
In this case, the constraint force is a moment (torque) that keeps $\theta_1 = 0$.
Constraint $C_3$: Pin Joint ($x$-Component)
The revolute (pin/hinge) joint forces the pin end of the bar to coincide with the center of the block. As a result, these two points must have the same global position:
$$
\vec{r}_{pin,1} = \vec{r}_{pin,2}
$$
Which yields the following constraint equation for the x-component:
Again, since the revolute (pin/hinge) joint forces the pin end of the bar to coincide with the center of the block, it yields the following constraint equation for the y-component:
Given that none of these constraints depend explicitly on time $t$, the partial time derivative vector, $\vec{C}_t = \frac{\partial \vec{C}}{\partial t} = \vec{0}$.
The constraint Jacobian, $C_q = \frac{\partial \vec{C}}{\partial \vec{q}}$ can now be evaluated as:
Thus, the velocity constraint equation $C_q \dot{\vec{q}} = - \vec{C}_t$ can be constructed. Since $\vec{C}_t = \vec{0}$, the velocity constraint equation simplifies to:
$$
\begin{bmatrix}
m_1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\
0 & m_1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 \\
0 & 0 & I_1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 0 & m_2 & 0 & 0 & 0 & 0 & -1 & 0 \\
0 & 0 & 0 & 0 & m_2 & 0 & 0 & 0 & 0 & -1 \\
0 & 0 & 0 & 0 & 0 & I_2 & 0 & 0 & -\frac{L}{2}\sin\theta_2 & \frac{L}{2}\cos\theta_2 \\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
1 & 0 & 0 & -1 & 0 & -\frac{L}{2}\sin\theta_2 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & -1 & \frac{L}{2}\cos\theta_2 & 0 & 0 & 0 & 0
\end{bmatrix}
\begin{bmatrix}
\ddot{x}_1 \\
\ddot{y}_1 \\
\ddot{\theta}_1 \\
\ddot{x}_2 \\
\ddot{y}_2 \\
\ddot{\theta}_2 \\
\lambda_{1} \\
\lambda_{2} \\
\lambda_{3} \\
\lambda_{4}
\end{bmatrix}
=
\begin{bmatrix}
-k x_1 \\
-m_1 g \\
0 \\
0 \\
-m_2 g \\
0 \\
0 \\
0 \\
\left(\frac{L}{2}\cos\theta_2\right)\dot{\theta}_2^2 \\
\left(\frac{L}{2}\sin\theta_2\right)\dot{\theta}_2^2
\end{bmatrix}
$$
or further as:
$$
\begin{bmatrix}
0.1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0.1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 \\
0 & 0 & I_1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 0 & 0.3 & 0 & 0 & 0 & 0 & -1 & 0 \\
0 & 0 & 0 & 0 & 0.3 & 0 & 0 & 0 & 0 & -1 \\
0 & 0 & 0 & 0 & 0 & 0.004 & 0 & 0 & -\frac{L}{2}\sin\theta_2 & \frac{L}{2}\cos\theta_2\\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
1 & 0 & 0 & -1 & 0 & -\frac{L}{2}\sin\theta_2 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & -1 & \frac{L}{2}\cos\theta_2 & 0 & 0 & 0 & 0
\end{bmatrix}
\begin{bmatrix}
\ddot{x}_1 \\
\ddot{y}_1 \\
\ddot{\theta}_1 \\
\ddot{x}_2 \\
\ddot{y}_2 \\
\ddot{\theta}_2 \\
\lambda_{1} \\
\lambda_{2} \\
\lambda_{3} \\
\lambda_{4}
\end{bmatrix}
=
\begin{bmatrix}
-10 x_1 \\
-0.981 \\
0 \\
0 \\
-2.943 \\
0 \\
0 \\
0 \\
\left(\frac{L}{2}\cos\theta_2\right)\dot{\theta}_2^2 \\
\left(\frac{L}{2}\sin\theta_2\right)\dot{\theta}_2^2
\end{bmatrix}
$$
In this case, $M$ is a $6 \times 6$ mass matrix, $C_{\vec{q}}$ is a $4 \times 6$ Jacobian, $\vec{Q}_e$ contains the external forces, and $\vec{Q}_d$ collects the known terms from differentiating the constraints twice. The unknowns are the accelerations $\ddot{\vec{q}}$, and the Lagrange multipliers ($\lambda_{1}$, $\lambda_{2}$, $\lambda_{3}$, $\lambda_{4}$). Therefore, at each time step, a $10 \times 10$ linear system must be solved.
Baumgarte Stabilization
Instabilities resulting from integration at the acceleration level are corrected using the Baumgarte stabilization technique. In order to do so, the acceleration level constraints are re-expressed as:
where $\alpha = 5$ and $\beta = 5$ are stabilization parameters that control how aggressively the instabilities are corrected.
Initial Conditions
Before starting the simulation, the following parameters are required:
$\vec{q}_0$: initial positions that satisfy all constraints
$\dot{\vec{q}}_0$: initial velocities that satisfy all constraints (the simplest selection is releasing the objects from rest, so $\dot{\vec{q}}_0 = \vec{0}$)
Given that there are 4 constraint equations and 6 unknowns, the following can be specified to determine the initial configuration of the system:
$x_1(0) = 0$ m (block at the spring's natural length)
$\theta_2(0) = 0$ rad (bar initially horizontal)
The system now has an equal number of equations as unknowns, and can be solved for the initial time step. From the constraint equations at $t = 0$ with $x_1 = 0$, $\theta_2 = 0$:
Thus, the system is released from rest with the bar in the horizontal position, and gravity will pull the bar downward, initiating the motion of the system.
Extracting Constraint Forces
The Lagrange multipliers $\vec{\lambda} = [\lambda_1, \lambda_2, \lambda_3, \lambda_4]^T$ represent the constraint forces associated with each constraint equation. Where each $\lambda_i$ is associated with one constraint:
$\lambda_1 \rightarrow C_1 = y_1 = 0 \rightarrow$ Normal force from track on block (y-direction)
$\lambda_2 \rightarrow C_2 = \theta_1 = 0 \rightarrow$ Moment from track preventing block rotation