Advanced Dynamics -- Lecture 16: Simulating Impacts and Hybrid Dynamical Systems
Overview
Christian Hubicki explains how to extend continuous Lagrangian simulations into hybrid dynamical systems, where MATLAB's ode45 event detection pauses a trajectory at a contact guard and an impact map updates velocity. He develops a bouncing bead and parabolic bowl example using the constraint h(q) = y - x^2, its Jacobian, and a restitution-based impulse equation, then codes the event and restart loop; the final simulation remains unfinished after debugging.
Key takeaways
- An impact can be modeled by stopping continuous integration at a guard h(q) = 0, applying an impulse-based map to velocity, and restarting the integrator.
- For a bead contacting the bowl y = x², the guard h(q) = y - x² has Jacobian J = [-2x, 1], which determines the contact direction in the impact equations.
- MATLAB ode45 event functions return value, isterminal, and direction; for downward-only contact detection, use direction = -1 and isterminal = 1.
- A fixed time-step loop can miss a contact between steps, while ode45's adaptive event handling can refine integration near the guard crossing.
- The instantaneous impact model keeps position continuous and changes velocity according to the impact map, with restitution e = 0 for plastic impact and e = 1 for elastic impact.
- The lecture's MATLAB implementation reaches event detection and constructs a restart loop, but the final bead trajectory remains incorrect and unresolved at the end of class.
Chapters
- Christian Hubicki reports median exam scores of about 90 for graduate students and 94 for undergraduates.
- A bug moving radially outward across a spinning record has no inward centripetal acceleration relative to the record if it is not moving in a circle.
- A child walking around the rim does have centripetal acceleration toward the center, even if the rim itself is not spinning.
- The next exam, planned for about two and a half weeks later, covers constrained Lagrangian mechanics, Baumgarte stabilization, 3D rotations, and non-conservative forces.
- Hubicki says practice exams are intended to benchmark the expected exam material.
- The Monday of Thanksgiving week will be a remote lecture.
- The homework is due Monday, November 16, two days before the next exam, and solutions will be released when it is due.
- The assignment combines constrained Lagrangian mechanics, 3D problems, non-conservative forces, and MATLAB coding, with a graduate bonus involving MuJoCo.
- An in-person quiz is planned for the start of class the following week and will last about 10 minutes.
- MuJoCo prevents objects from passing through the ground using a stiff spring-damper-like contact force.
- In constrained Lagrangian mechanics, a normal contact force can be represented by a Lagrange multiplier.
- Hubicki contrasts that continuous-force treatment with the instantaneous impact model introduced in this lecture.
- The continuous constrained equations solve simultaneously for generalized accelerations and Lagrange multipliers using a block matrix system.
- The impact formulation replaces continuous constraint forces with an impulse and solves for the velocity immediately after impact.
- The constraint Jacobian is J = ∂h/∂q, where h(q) = 0 defines a holonomic position constraint.
- The coefficient of restitution e distinguishes a plastic impact at e = 0 from an elastic impact at e = 1.
- For an object above ground, h(q) = height can serve as a guard: stop when h reaches zero, record the pre-impact state, then apply the impact map.
- A rigid rod can be modeled with multiple contact guards, one for each endpoint that must not pass through the ground.
- Hybrid dynamical systems combine continuous evolution with discrete jumps at events such as impacts.
- At impact, position remains continuous while generalized velocity jumps from q-dot-minus to q-dot-plus.
- The impact map is also called a jump map because it changes velocity instantaneously at a guard.
- MATLAB's ode45 supports event detection, allowing a simulation to stop when a guard function crosses zero.
- Adaptive time stepping helps ode45 refine its steps near an event, unlike a manually selected fixed-step loop that may step past contact.
- The intended workflow is to detect an event, calculate the new velocity, update initial conditions, and restart integration.
- The example uses a point mass under gravity and a bowl defined by y = αx², with α set to 1.
- The generalized coordinates are q = [x, y], and the contact guard is h(q) = y - x².
- The guard Jacobian is J = [-2x, 1], a 1-by-2 matrix for one constraint and two coordinates.
- Hubicki creates a MATLAB script named beadbowl.m and uses symbolic variables for time, x, and y.
- For the unconstrained falling bead, the mass matrix is m times the 2-by-2 identity matrix and the force vector is [0; -mg].
- With m set to 1 and g set to 9.8, the acceleration is [0; -9.8].
- The ode45 state is arranged as [x, y, x-dot, y-dot], pairing two positions with two velocities.
- The state derivative combines velocities [x-dot, y-dot] with accelerations [0, -g].
- An indexing mistake initially made the bead rise; using state elements 3 and 4 for the velocity components fixes the falling trajectory.
- MATLAB's odeset adds an event-function handle to the ode45 options.
- An event function returns value, isterminal, and direction; a zero crossing triggers an event when its direction condition is satisfied.
- For the bowl, the event value is y - x², direction is -1 for a descending crossing, and isterminal is 1 to stop integration.
- The first event attempt fails because the isterminal and direction outputs are supplied in the wrong order.
- After switching to MATLAB's expected order, the simulation stops when the bead reaches the parabola, near x = 1 and y = 1 from the initial position [1, 2].
- A terminal event provides the final event state needed to calculate the impact update before restarting.
- Hubicki assembles the impact system from the mass matrix, the contact Jacobian, the pre-impact velocity, and restitution set to 1.
- The loop updates the initial velocity with q-dot-plus and advances the current time to the last ode45 event time; failing to update time initially creates an infinite loop.
- The plotted trajectory still behaves incorrectly, so Hubicki ends the session without a finished bounce simulation and plans to continue debugging and add a rotating rod example.
Transcript excerpt
0:01 Okay, folks. I think we're ready. So, good morning. >> Happy Monday. Make sure we're good to go. Looks like we got good good bit rate and everything. Wonderful. All right. So, as we just passed back your exams, I I think that overall class did quite well. The median for grad students was a a 90, a little just above a 90. Median for undergrads was about 94. Um, I hope that that means that you made good use of the practice materials that I gave you and it was a pretty good reflection of what was on the exam. Uh, few people had a few questions about the actual content of the exam. Uh, just little things here and there. One of which, um, let's see, there was a there there was a problem that looked kind of like this. You had a you had a you had a gosh, it
0:49 was a ladybug on a record. The ladybug was moving outward and Oh, you can't even see. Sorry. Thank you. There you go. You had a record. There's a little ladybug. Oh, ladybug. Oh, look at that ladybug. Okay. And it was moving outward with a with a constant velocity relative to the spinning record player. Okay. And some people put a centripal acceleration term uh as for for their relative acceleration for an ail term. And because one of the practice problems uh had a similar looking problem where there was a kid who was walking on the outside of a rim. Okay. And the key of that and the key difference is so there is no ail term in the on the problem on
1:37 the exam because the bug is not being told to walk in a circle along the disc. Okay. It was not it was not doing that.
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Christian Hubicki.