new video + notebook: Flappy bird kinematics #24
Replies: 43 comments 3 replies
|
The system of position constraint equations for the piston crank system is as derived in the lecture. Once we have established |
|
I think it would be interesting to explore a scenario where the bird either accelerates or decelerates to see how the graphical motion would change. I tried plotting it with 2^t/2 but I am struggling a bit -- is anybody having better luck? I am running the file in Julia and changing the C constraint but not noticing a difference in the plot. |
|
For this example, the system of equations comes from the constraint equations that define both the shape of the path and how Flappy moves along it. In the notebook, those are For other paths, there are a lot of options just by changing either the geometric constraint or the driving constraint. A couple easy ones would be a decaying sine-wave path like |
|
|
So I concur with everyone else however, that was for a sine wave. I took a slightly different approach using some research and other paths for a flappy bird....in my case I am exploring a tanh step which would mimic almost like a signal where we would have two horizontal smooth levels. This introduces y = tanh(x). To start the equation would be y = Atanh(kx) where A is the height of the step (difference between low and high level) and k is the steepness of the transition. The constraint equation would Next similar to the other equation we take the Jacobian which is the partial derivative of the constraint with respect to x,y.
To add the change in levels we would just need to subtract the tanh functions like the following equations... This still will translate to the following like others proved in class... I think this is so unique because it can be used for different probblems like decaying oscillation, parabolic path, step/square waves as long as the Jacobian is fully defined. Please note...research included was combination of Gemini and ChatGPT and the Textbook material. |
|
This was fun way to represent sinusoidal motion. Obviously Flappy’s path is not exactly sinusoidal depending on tube height and user input bit it’s a good approximation to make the point. This leads to the constraint equations C(q,t). At each time step, the position of the bird can be found by solving this constraint system, then, the speeds of the moving parts are obtained by differentiating the constraints with respect to time and solving the linear system Cqq˙=−Ct.C_q \dot{q} = -C_t. I think Danny Kruzick said it well that you could send Flappy on paths like a decaying sine-wave path or an exponential path (Flappy goes to space!). |
|
I think this example does a really good job showing how everything comes from the constraint equations. For Flappy Bird, if we take q=[x,y], the system is just the path constraint y−sin(πx)=0 and the driving constraint x−2t=0. Together those give the full system C(q,t)=0. The way it’s solved is pretty interesting too. First, you solve that nonlinear system to get the position at each time step. Then, instead of setting up full equations of motion, you just differentiate the constraints and solve Cqq˙=−Ct, which is linear, to get the velocities. So it splits into a nonlinear position solve and a linear velocity solve, which makes things a lot simpler. I also like how flexible it is. You can basically send Flappy on any path just by changing the constraint. A few ideas could be a parabola, a circle, or even something like a decaying sine wave so the motion flattens out over time. You could also change how it moves along the path, like using x=t^2 so it speeds up. |
|
For the Flappy Bird example, the system of equations consists of the constraint equations: the path constraint y−sin(πx) = 0 and the driving constraint x−2t = 0. Together they form C(q,t)=0. To find velocities, we differentiate the constraints and solve the linear system Cqq = -Ct at each time step after solving for positions nonlinearly. Other paths for Flappy Bird could include:
|
|
What will the system of equations be for this system? |
|
For the Flappy Bird problem, the system of equations comes directly from the constraint equations that define both the path and the forward motion. Taking For the other Flappy Bird paths, just by changing the geometric constraint will give many other possibilities. Some examples include a circle, parabola, cosine wave, or decaying sine/cosine waves. I find it interesting how you are able to create basically any path just by changing the constraints. |
|
This flappy bird system is governed by constraint equations on the position q = [x, y]^T which are a path constraint y-sin(πx)=0 and a motion constraint x-2t=0. Together, these form the system C(q,t)=0, which is solved at each time step to find the bird’s position. The speeds are not given directly and instead are computed by differentiating the constraints with respect to time, giving the linear system ∂C/∂qqdot=-∂C/∂t. Substituting the current values of x, y and t turns this into a 2x2 linear algebra problem whose solution gives xdot and ydot. Other paths for the bird can be created by changing the geometric constraint like y = Asin(kx) for greater flapping, y=x^2+bx+c for a parabolic dive, or parametric paths like x=Rcos(ωt), y=Rsin(ωt) for circular motion, while keeping the same constraint solution approach. |
|
From what I understand, making the flappy bird path included using constraint equations that were specifically of a sine wave. We use the variable q to generalize the position of the bird. We made the x position move forward at a constant speed of 2t. Our system was C(q,t), which involved both of these relationships. To find the speed of the moving parts, we needed to do the time derivatives of the constraints found. Doing this allowed us to find a linear system that we could compute. We could probably send Flappy Bird on a circular path using both x and y values like: (x-x0)^2 + (y-y0)^2 - R^2 = 0. |
|
I think it would be interesting to model Flappy Bird on a decaying function. I.e. the amplitude of his motion decreases with time. This would introduce a new challenge to the game, in which you'd have to fit into a smaller space as the round goes on. We could simply define the decaying y-position as: |
Since there are two equations and two unknowns, we would solve for the position (x,y) at each time step using a nonlinear solver.
After solving for position, we can plug those values into the Jacobian and solve this linear system to get velocities.
|
|
Because the constraints in the model are only the path constraint: y = sin(pi*x) and the horizontal speed being x' = 2 this then can make the system of equations: This makes sure that for any time We can also make the bird go along different paths. Some of these paths include circular paths such as |
|
I looked at this by separating what is being prescribed versus what is being solved through constraints. |
|
For the Flappy Bird example, the system of equations comes from the path constraint and the driving constraint. Using q=[x,y], the sin wave motion can be written as C(q,t) = [y - sin(pix); x - 2t] = 0. The first equation keeps Flappy Bird on the sine wave, and the second equation makes it move forward at a constant speed. To solve for the speeds, you have to solve the position constraints at each time step. Then you have to differentiate the constraints and solve C_qq_dot = -C_t. This gives us the velocity of the moving parts after the position is known. Other paths for Flappy Bird could be a parabola, cos wave, or a decaying sine wave. |
|
For the Flappy Bird example, the bird follows a sinusoidal path, which demonstrates constrained two-dimensional motion. Other possible paths could include a circular trajectory, a parabolic arc, or a spiral path. A damped oscillation path could also simulate realistic flying behavior where the the amplitude decreases over time. More complex motion could be designed using spline curves or piecewise functions. |
|
This discussion provided a good opportunity to reflect on how the tools from this course fit together and apply beyond individual homework problems. Concepts like generalized coordinates, Lagrangian mechanics, stability analysis, and damping all form a consistent framework for modeling real mechanical systems. What stood out most was how simulations, animations, and phase portraits helped bridge the gap between theory and physical intuition. Rather than just solving equations, the course emphasized understanding system behavior and how design choices affect motion and stability. Overall, this discussion reinforced the value of energy‑based methods and made it clear how these ideas carry over to more advanced dynamics, controls, and real‑world engineering applications. |
|
To set up the equations for this problem, we use generalized coordinates. With four rigid bodies, there are 12 generalized coordinates in total. To find the speeds of the moving parts, we would take the Jacobian of the constraint equations and solve for the velocity vector at each time step. A good example from biomechanics is isokinetic testing on a Biodex machine. In this test, the machine keeps the leg moving at almost a constant angular velocity and treats the knee joint as a hinge constraint. In both situations, constraints control how the system moves and how fast it can go. |
|
For the piston-crank system, the governing equations are a set of algebraic position constraints, often written as Phi(q, t) = 0. In this setup, we have generalized coordinates (q) for the crank, connecting rod, and piston, which are tied together by constraints like pin joints and the slider block. Because this is a kinematic simulation, we aren’t actually solving differential equations of motion; instead, we are solving nonlinear algebraic equations at every time step to see how the parts must be positioned to stay connected as the driver moves. To find the speeds of the moving parts, we move to the velocity level by taking the time derivative of the constraints. This gives us the linear system: [Jacobian] * [velocities] = -[partial time derivative], or (Phi_q) * (q_dot) = -Phi_t. Once we use an iterative solver like Newton-Raphson to find the positions (q) for a specific moment, we plug those values into the Jacobian matrix and solve the resulting linear system for the velocities (q_dot). It’s a really efficient workflow because the velocity problem is just straightforward linear algebra, even though the position problem is nonlinear. As for Flappy Bird’s path, the framework is flexible enough to handle almost any geometry. Instead of a standard sine wave, we could send him on a "bouncing" trajectory using an absolute value function like y = |A * sin(B * x)|, which would make his path look like he’s hitting a floor and popping back up. We could also change the driving constraint—maybe instead of a constant horizontal speed, we use a function like x = t^2 so he starts slow and rapidly accelerates across the screen. |
|
The system of equations for this model will contain 12 equations that define the connectiveness and motion of the four bodies: 3 constraints to immobilized the ground body, 2 constraints each of all of the joints (origin, crank-rod pin, and rod-piston pin) so 6 in total, 2 constraints to ensure the piston only moves along the x-axis without rotating, and finally 1 time dependent constraint that governs the rotation of the crank. Once the nonlinear position solution has been found, at a time ,t, then the speeds can be found next. Solving for the speeds can be done using linear algebra rather than integration by using the complete set of the constraint derivatives of the with respect to time and the Jacobian matrix, [Jacobian][Velocities]=-[Partial derivatives of constraints with respect to time]. Using software like MATLAB or arithmetic methods like Newton-Raphson, we can find the positions at a time t, then plug those values into the Jacobian and solve the resulting linear system. Since Flappy Bird’s motion is defined entirely by the intersection of a geometric constraint (the path) and a driving constraint (the speed), you can change its trajectory by using decaying oscillations (y=Asin(pi*x)exp(-alphax), where alpha is the decay constant) to simulate the bord gradually losing energy and flattening its path. |
|
For this example (flappy bird) the motion can be described by defining the horizontal position as the function of time and constraining the vertical to follow a sine path. If the bird moves at a constant speed: X(T) = VxT And the path is Y(T) = Asin(KX + phi), and we can substitute X(T) in and get Y(T) = Asin(KVxT + phi). Then, the constraint equation is: C(X, Y, T) = Y - Asin(KX + phi)Xdot = 0 As for the piston and crank the same idea works, but with more constraints between the angle, the rod, and piston displacement. First we could write out the constraint equations, then differentiate them to get velocity equations. Then these can be solved in matrix form to get the unknown speeds. |
|
The system of equations for this problem comes from the constraint equations that define the motion of the system. In the Flappy Bird example, the bird is constrained to move along a sine-wave path while also moving forward with time. The equations are y - sin(πx) = 0 and x - 2t = 0. The first equation forces the bird to stay on the sine-wave path, while the second equation controls the forward motion at a constant speed. Together, these equations form the full constraint system. For the piston-crank system, the same process is used, except there are more equations because of the revolute joints, slider constraints, and driving rotation between multiple rigid bodies. To solve for the speeds of the moving parts, the constraint equations are differentiated with respect to time. This gives the velocity equation, which is Cq * q_dot = -Ct. First, the nonlinear position equations are solved at each time step. Then, the Jacobian matrix (Cq) and time derivative vector (Ct) are evaluated using the current positions, and the resulting linear system is solved for the velocities. This makes the problem easier because the velocity analysis becomes a linear algebra problem instead of requiring differential equations. Other paths for Flappy Bird could be created by changing the constraint equations. For example, the bird could move along a parabola using y = ax^2, a circle using x^2 + y^2 = R^2, or a decaying sine wave using y = A*sin(πx)*e^(-αx). The driving constraint could also be changed from x = 2t to x = t^2 which would cause the bird to accelerate as it moves forward. |
|
I solved the separation of the Flappy Bird example into two constraints, one that controls the forward motion and one that controls the path shape. If the bird is moving forward at a constant speed, the horizontal position could be prescribed as x−vt=0 Then the vertical motion could be constrained to a sine wave, y−Asin(ωt)=0 This makes the motion fully prescribed because the bird is not really being “solved” dynamically. Instead, the constraints are forcing it to follow a certain path. To get the speeds of the moving parts, I would differentiate the constraint equations and use the velocity-level constraint equation Cq˙=−Ct For the simple time-based sine path, this gives you x˙=v, y˙=Aωcos(ωt) So once the position constraints are known, the velocity constraints give the speeds at each time step. For the piston-crank system, the same idea applies, but there are more constraints because the bodies are connected through joints. The crank angle, connecting rod angle, and piston position all have to satisfy the geometry of the mechanism. After solving the position constraints, the Jacobian can be used to solve for the unknown velocities. For other Flappy Bird paths, I think it would be interesting to try a decaying sine wave, a circular loop, or a figure eight path. A decaying sine wave would probably look more realistic because the bird could start with larger motion and then slowly level out over time. |
|
For this example the motion is coming straight from the constraint equations that define both the path and the driving motion. The sine wave path constraint controls where the bird can move. the driving contraint controls how the bird moves along the path over time. Solving the nonlinear position constraints allows us to solve the velocity equations using a Jacobian matrix relationship. |
|
Another interesting extension would be solving for accelerations by differentiating the velocity equations once more. This leads to the acceleration-level constraint equation, where the Jacobian, generalized accelerations, and additional quadratic velocity terms are included. Using this approach, we could analyze how rapidly the bird speeds up or changes direction along different paths. For example, with a driving constraint like x=t^2, the bird would not only accelerate forward, but its vertical acceleration would also increase because of the curvature of the path. This demonstrates how the same constraint-based framework can be extended from position analysis to full kinematic analysis, including velocities and accelerations, without directly integrating equations of motion. |
|
To allow for precise control of a sinusoidal wave utilizing a 2-dimensional arm like system. you will need 12 equation systems of equations to constrains the system (12 equations are needed becasue you have 4 parts each with 3 attached variables). These 12 equations constrain the locations and angels of every peice of the system. using this system of equations you can calculate there position with respect to time aswell as the angels compared to the other peices. the goal is to get this system C(q,t) to be equal to 0 to solve it and this is how to set it up to do that. The derivatives of these equations contain the velocities of all of the points of the system. this system could move in all sorts of ways you could have this move as a function of a different wave such as "square" or saw tooth wave you could also have it move in different directions. I have previously worked with similar systems that use this in 3 dimensions to trace complex part surfaces. |
|
In this example, the motion comes directly from the constraint equations that define both the path and how Flappy moves along it. For the sine‑wave case, the constraints are 𝑦 − sin ( 𝜋 𝑥 ) = 0 for the geometry and 𝑥 − 2 𝑡 = 0 for the driving motion, which together form 𝐶 ( 𝑞 , 𝑡 ) = 0 . At each time step, the position is found by solving this nonlinear system, and the velocities follow from differentiating the constraints and solving the linear system. I thought it was interesting that the motion can be obtained entirely from constraints, nonlinear solve for position, linear solve for velocity, without writing differential equations first, which is the same idea used in the piston‑crank problem. |
|
For the Flappy Bird example, the system of equations comes from the constraint equations that define the bird’s motion. Let q = [x,y]. The constraints are: |
Uh oh!
There was an error while loading. Please reload this page.
In this video, we use a two dimensional motion example, Flappy bird moving on a sine-wave, to demonstrate the process of creating multibody dynamics (MBD) kinematic simulations. Then, we start to derive the constraint equations and constrained motion of a piston crank system. For further info and reading, check out the Shabana ch 3 examples.
What will the system of equations be for this system? How will we solve for the speeds of the moving parts?
What other paths could you send Flappy bird on?
All reactions