Teaching Rigid Body Dynamics using MATLAB and Computational Thinking - MATLAB
Video Player is loading.
Current Time 0:00
Duration 1:16:35
Loaded: 0.05%
Stream Type LIVE
Remaining Time 1:16:35
 
1x
  • Chapters
  • descriptions off, selected
  • captions off, selected
      Video length is 1:16:35

      Teaching Rigid Body Dynamics using MATLAB and Computational Thinking

      Overview

      In this presentation, we’ll demonstrate how to use MATLAB to support the teaching of rigid body dynamics – one of the staples in physics and engineering courses.  A collection of case studies from Mechanical and Mechatronic engineering will be presented, spanning 1st year concepts through to more advanced 3rd and 4th year rigid body dynamics.  Specific case-studies will include:

      • Kinematic analysis of a 4-bar linkage
      • Equations of motion of a 3-Link robotic manipulator (Newton)
      • Gyroscopic Boat Stabilization (Lagrange)
      • A quadcopter that balances an inverted pendulum (Lagrange)

      About the Presenter

      Bradley Horton is a member of the Academic Customer Success team at MathWorks, helping faculty members better utilize MATLAB and Simulink for education and research. Bradley has supported and consulted for clients on projects in process control engineering, power systems simulation, military operations research, and earthquake impact modelling. Before joining MathWorks, Brad spent 5 years as a systems engineer with the Defense Science & Technology Organization (DSTO) working as an operations research analyst. Bradley holds a B.Eng. in Mechanical engineering and a B.Sc. in Applied mathematics.

      Recorded: 18 May 2021

      Hello, everyone, and welcome to this session on teaching rigid body dynamics using MATLAB and computational thinking. My name is Bradley Horton. I'm one of the engineers at The MathWorks.

      In my role at The MathWorks, I engage predominantly with our university customers. And over the last few years, I've met with hundreds of academics from dozens of universities across Australia and New Zealand. The concepts and case studies that I'm going to share with you today have come from these engagements. So I'm hoping the message in today's session is also meaningful to you.

      Before we go any further, can we just shake hands on this? Can we agree that as educators what you want to do is create a learning environment that makes your students hungry to learn, capable of independent self-learning, and skilled in the computational methods needed to make the world a better place? And the more time your students spend in your learning environment, will they simply become better learners?

      And we understand that as educators you're constantly looking for ways to improve the learning outcomes within your classrooms, that you're looking at better ways to improve the comprehension of engineering concepts, that you're continuously looking to improve a student's ability to apply, analyze, and create. Well, computing technology is a powerful tool that can support these teaching objectives. And I hasten to add that as educators, you're probably not so interested that technology can produce just an answer. Rather, technology in the classroom becomes truly effective when it enhances the capacity of your students to understand the concepts that you're teaching.

      So, today, I'd like to talk to you about the role that MATLAB can play in your classroom. I'd like to introduce and define the concept of computational thinking and comment on how MATLAB supports a computational thinking approach to learning. To reinforce these concepts, I'm going to spend about an hour walking through seven case studies that are typically covered when rigid body dynamics is taught. And these examples will span years 1 to 4 of a typical undergraduate engineering degree.

      I'm sure that most of you came today to see MATLAB in action. And you're definitely going to see a broad spectrum of MATLAB applications. We'll finish off today's session with some comments on some teaching and learning resources and also how you can get some of the relevant examples that are shown today.

      Let's get on the same page, first of all, on what we mean by computational thinking. Computational thinking is simply a problem solving approach that utilizes computing technology. If you can formulate a design task in such a way that it can be implemented on a computing device, then you are doing computational thinking. The main components of this computational thinking workflow involve breaking one big problem down into a series of smaller ones, developing a mathematical model of your system, developing algorithms to support some design task, and, finally, confirming a design by doing simulations.

      A very simplified connection back to your teaching goals is to realize that these four high-level steps are focused on growing that cognitive development of your students. Developing mathematical models and algorithms encourages the application of concepts. Using models to simulate dynamic behavior encourages the analysis and evaluation of engineering design tasks. And these are all learning objectives that you want to see produced in your classroom.

      The challenge that most of us have though is determining when exactly is the right time to start incorporating computational thinking into our classes. Some people will say it's in the later years of a degree simply because this is usually when the more computationally intensive courses are introduced. And many will claim that if introduced too early it will dilute the learning experience. These are the top three concerns that I regularly hear from teaching academics. But when you pause and just take a moment to think about them, all of these concerns have happy endings.

      Problem-solving with pen and paper is still incredibly important. But, surely, you can supplement this with just a little bit of computational thinking. If you think computational thinking means that a computer does the thinking, well, that's really a misconception because without a living human brain driving the understanding of engineering concepts, computational thinking simply won't work.

      And, lastly, one of the main benefits that computational thinking will bring to your classroom is the sense of empowerment that it will give your students. And this empowerment and motivation stems from the fact that the laborious computations needed for problem-solving are not being done by hand. And this tends to encourage students into spending more time actually thinking about the relevant engineering concepts.

      So, today, I want to focus on how MATLAB enables computational thinking. I want to show you exactly how MATLAB encourages problem-solving and how this process of problem solving develops the thinking skills that you want from your students. We'll look at how students can take their understanding of engineering concepts and together with technology apply that understanding by developing mathematical models of dynamic systems. And we'll look at how these brain derived models can be validated by alternate ways of modeling. These models will then be simulated which gives the students the opportunity to analyze and evaluate the dynamic system being studied.

      There are seven rigid body dynamics case studies that we'll be reviewing today. And these examples cover a broad spectrum of concepts that are taught from first year all the way through to the fourth year of an undergraduate degree. For our first year examples, we'll look at the velocity analysis of two mechanisms, one of which will be the classic four-bar mechanism. We'll also look at an appropriate application of Newton's second law, a ball rolling down an inclined plane. We'll continue the discussion on Newton's second law by looking at the equation of motion derivation of a three-link robot.

      And this is a great example that demonstrates how a student's brain combined with technology can overcome the challenges of big scale derivations usually encountered with pen and paper. For our third-year case study, we'll look at driving and simulating the dynamics of a gyroscope. And we'll then look at an engineering application of the gyroscope. We'll look at developing a model of a gyroscopic boat stabilization system.

      And we'll finish off with a really fun application on deriving a model of a quadcopter that balances an inverted pendulum. So really something for everyone, I hope. And, look, on average, we'll spend about nine minutes on each case study.

      Let's get to the good stuff. Our first case study today is an example that is typically introduced during a first-year engineering dynamics class. We'll do a velocity analysis of a slider crank type mechanism. As we work through this example, I want you to keep your eye out for three things.

      Firstly, we'll analyze the system using our brains. Secondly, we'll then compare the results of our brain analysis against the results produced by a computer model. The computer model actually produces a CAD-like viewer, which animates as we simulate the model. And the animation reveals the complete motion behavior of the machine providing an incredible insight for that early year engineering student.

      Let's go to MATLAB and check it out. Here's the slider crank that we'll be analyzing. We've been given dimensions of all of the members. And we've been given a very specific pose on which to perform the analysis. And the problem statement is asking us to compute the translational velocity of the orange piston and the angular velocity of the yellow link.

      The analysis of this mechanism requires the student to apply an understanding of how to compute the velocity of point B based on knowledge of point A and the angular velocity of the yellow link. The motion constraint of the piston then allows the student to compute the two requested quantities. Now these computations are extremely simple and can easily be done by hand along with the help of a calculator. In fact, as I run this MATLAB script, we're basically using MATLAB as a glorified calculator.

      MATLAB has computed that the angular velocity of the yellow link is 12 radians per second. And the vertical velocity of the orange piston is about 6.235 meters per second. What this exercise hasn't done though is to illuminate the constrained motion of the mechanism. And let me show you a Simulink model that not only allows us to validate our brain computations. But it also automatically creates an animation of the mechanism.

      This is a Simulink model of the slider crank mechanism. And the model contains blocks from the Simscape Multibody Library. I've color-coded the blocks to match the schematic. We have the green, yellow, and orange blocks representing the rigid bodies of the machine. And we have the light blue colored blocks that represent the revolute and prismatic joints that connect the bodies together. Let me simulate this model.

      Because my model contains the Simscape blocks, this CAD-like viewer appears automatically. And as you can see, it provides an insightful animation that reveals the motion of the machine. Now, in the Simulink, any signal in your model can be probed and then visualized. This pink block is kind of like an oscilloscope. When I double click on it, it reveals the times series plots of some of the signals produced by this simulation.

      Now, the results of the simulation at time t equals 0 actually correspond to the very pose of the mechanism that we analyzed in MATLAB. So as I zoom in on the yellow angular velocity plot, you can see that at time 0, the angular velocity of the yellow link is 12 radians per second. And, similarly, when I zoom in on the orange vertical velocity, you can see that at time equals 0 we have a piston velocity of around 6.235 meters per second. And these results are identical to those that we computed earlier in MATLAB.

      So that's our first case study, a really simple slider crank mechanism. The next example that I'd like to show you is a slightly more sophisticated mechanism. And it's one that I'm sure you know extremely well.

      Our second case study today is a velocity analysis of a classic four-bar mechanism. It's another one of those mechanisms that are typically introduced during a first-year dynamics class. As we explore this problem, we'll start out by analyzing the mechanism in a given pose. And this constitutes what I'll refer to as our brain analysis.

      But by using computational thinking, we're able to go beyond analyzing the machine for just one pose. Instead, we can automate the analysis for hundreds of poses. And by doing this, we gain an insight into how this particular mechanism can produce a cam-like motion profile. Now, our computational thinking workflow, again, consists of three steps.

      Firstly, we do our brain analysis on the mechanism. And this brain analysis will eventually help us automate. Secondly, we compare the results of our brain analysis against a computer model. And, thirdly, we'll observe the behavior of the mechanism by simulating the model. Let's go to MATLAB and check it out.

      Here's a MATLAB live script that we're going to use to perform our velocity analysis. But before we focus on this script, I'd like to take a short detour on building apps with MATLAB. About six years ago, we rolled out a brand new tool for helping you create your own custom apps. As part of the core MATLAB product, we now have a tool called App Designer. And to launch App Designer, it's as simple as going to this new icon and choosing App.

      The App Designer allows you to design the graphical layout of your app by simply dragging user interface components onto the layout canvas. Let me drag a dial and an axis onto the first tab sheet. The App Designer then allows you to define the functional behavior of your app.

      You write the MATLAB code that runs when your students interact with the app. It is incredibly easy to develop engaging apps to share with your students. Let me show you an example of the kind of app that you could build.

      Here's a custom app that we can use to explore the motion behavior of the four-bar mechanism. Let me start out by choosing one of the pre-configured four-bar mechanisms. Let me choose this one.

      For this particular mechanism, the red link cannot fully traverse 0 to 360 degrees. Instead, the red link can only move between about plus or minus 77 degrees. And as the red link moves between this range, the angles of the blue and green links are also constrained to very specific intervals as shown by these three plots. But a much more insightful way of understanding these motion constraints is to simply watch an animation.

      Now, as this animation runs, you can see that we can configure the machine into a given pose provided the green circle intersects the blue circle. And this circle intersection problem can then be used to compute the green and blue link angles for a specified red link angle. Now we won't be covering that specific topic today. Instead, let me go back to the Layout tab sheet. And I'll choose the very specific four-bar mechanism that we're going to do the velocity analysis on today. And here it is.

      Again, if I review the valid red link angular pose that this mechanism can traverse, you'll see the red link can actually this time sweep a full 360 degrees. Now let me show you just one more animation to reveal the full sort of motion profile that this particular mechanism can move through. As this animation runs, you can now better understand those green and blue link angular ranges that we saw plots of earlier.

      Look, I think that's probably enough playing around with this app. The main takeaway from the last five minutes is that you can build your own custom apps in MATLAB to support your teaching tasks. So let's go back to MATLAB now and start the velocity analysis of our specific four-bar mechanism.

      We're going to use this MATLAB script to do our analysis. In our problem statement. We're given the dimensions of the red, blue, and green links. And we're told that the red link rotates at a constant angular velocity of 3 radians per second. And we're being asked to compute the angular velocity of the blue link and the translational velocity of point P on the green link.

      Now the workflow that we'll follow involves three main tasks. Firstly, we'll perform our velocity analysis symbolically. And this allows us to completely parameterize the mechanism. This symbolic analysis will follow the identical steps that would be used if a pen and paper approach was being applied. The big benefit in our symbolic approach is that it then allows us to automate the velocity analysis for any given pose of the mechanism.

      And that's exactly what we'll do. We'll solve our problem statement for hundreds of different configurations of this mechanism. And the third and final part of our workflow is to compare our brain analysis with a Simulink computer model.

      Let's start our brain analysis. On the left-hand side of this script, we're implementing our understanding of the system kinematics. We're typing out the symbolic form of the expressions of interest. And when we get MATLAB to evaluate these expressions, we can see their symbolic form echoed on the right-hand side.

      Now one of the more challenging aspects of this analysis from a first-year student's perspective is recognizing that the velocity of point P can be computed in two different ways, starting from point A and/or starting from point B. And this dual-pronged approach allows a system of two simultaneous equations to be solved for the two unknowns. And, look, conceptually, students know how to solve a 2 by 2 system of simultaneous equations and so does MATLAB.

      Here are the symbolic expressions for our two unknowns. They're the angular velocities of the green and blue links. And once we know these angular velocities, then the translational velocity of point P can then be computed.

      These symbolic expressions that we've just created, well, they can be automatically converted into MATLAB functions. And the MATLAB function function does this for us. We're now in a position to automate the velocity analysis for any specific pose of our mechanism. We're going to define a list of red link angles and then compute numeric answers for our quantities of interest.

      Here's the for loop that helps us automate our computations. And here's where we use the expressions for the blue and green link angular velocities that we derived earlier. And, finally, here's where we store the results for each pose that we're analyzing. Let me run this section so that we can see the results.

      The results of each analysis are presented in this MATLAB table. Now, instead of looking at a wall of numbers, let's plot a selection of columns from this table. Here's a time series plot of our three link angles, our theta our phi, and alpha. And the next plot shows the angular velocities of the green and blue links. And it also shows in pink the xy position of point P.

      Now, if we were to plot the position of point P as an xy graph, we see the cam-like motion profile traced out by point P. And this final result sums up our motivation in wanting to analyze this system using computational thinking. It would have been extremely unpleasant to produce this result using just pen and paper.

      So to summarize what we've just done, we looked at a custom app for exploring the motion of a mechanism. We then performed a velocity analysis on that mechanism. And then we automated that analysis to process hundreds of different poses of that same mechanism.

      Now, some of you might be sitting back right now and feeling that that was a lot of work that we just did. And you're right. It was. What I'd like to do next though is show you an alternate way of producing these same results. And it involves creating a Simulink model.

      Here's the Simulink and Simscape model of our four-bar mechanism. And for such a simple mechanism, you would expect the model to be equally as straightforward. And it is.

      I've color-coded the blocks of the model according to the schematic also shown. And as you've seen already from our previous case study, because I've created the model using the Simscape blocks, when I run the simulation, the Simscape Mechanics Explorer appears producing this CAD-like viewer. And we can use this CAD viewer to explore the motion of the machine that was produced by simulating our model.

      The simulation has also produced an xy plot of point P. And here's the cam profile that we saw earlier from our original MATLAB analysis. And don't forget in Simulink we can also monitor the time series of any signal in our model.

      Here's an oscilloscope plot of our red, green, and blue link angles. And these are identical to the plots that we produced from our earlier MATLAB analysis. Our Simulink Simscape model has just validated our brain analysis.

      Many of you may also be attracted to how simple these Simulink Simscape models look. For a relatively small time investment in actually creating the model, you really do get a lot of teaching and learning outcomes being produced by it. That's enough on mechanism analysis. Let me introduce you to our last example designed specifically for a first-year student audience.

      Our last example today that's tuned specifically for a first-year engineering audience is an application of Newton's second law. We'll derive the equation of motion for a ball rolling down a slope. We'll implement these brain-derived equations in Simulink and observe the time response of the derived system.

      We're also going to implement a Simscape representation of the exact same system. And then we're going to compare the results of the two different models. An exploratory task that we'll use these models for is to establish if the ball is rolling or sliding and rolling. Let's go to Simulink and check it out.

      Here's the top level of our Simulink file. It contains two models that we'll use to simulate the dynamics of a ball rolling down an incline floor. And probably the first thing that your eyes are drawn to are the interactive dial and slider bars embedded into the model. These interactive components allow us to adjust the angle of the yellow floor and the two friction coefficients used by our models. But we can adjust even more parameters by double-clicking on the great block in the center of the screen.

      Here's an interface where we can specify the ball's radius and mess and environmental parameters such as gravity. Now, when students work on this type of problem, they use their brains to apply Newton's second law. Let's do a really quick review of what this brain derivation typically looks like.

      Free body diagrams are first drawn and then it's the application of Newton's second law applied to the translational motion and rotational motion. In this derivation, we've made an assumption that the ball is always rolling, which may or may not be the case. And we'll talk about that again in just a moment.

      The rolling assumption then leads to expressions for the rolling acceleration of the ball and the friction force acting on the ball. So having derived this equation of motion, we can now implement them in Simulink. Let me show you what that looks like.

      Here are the Simulink blocks that implement the equation of motion that we just derived. If you're new to Simulink, note the two blue integrator blocks. These are the blocks that integrate the time varying signals. Let me go back to the top level of the model so we can run the simulation. I'll click on this green Run button to simulate the model.

      Let me open up some oscilloscope plots so that we can visualize the simulation results. These six axes show the times series response of six signals in our model, things like the normal and friction forces acting on the ball and the rotational acceleration and velocity of the ball. The orange lines that are displayed in each axis correspond to our brain derivation results. But you can see that we are also displaying another set of results in blue.

      The blue results have been produced by an alternate model of this ball and floor system. And these two different results are almost identical except for the strange discontinuity that occurs after five seconds. Let me show you what has produced this second set of blue results.

      Here's an alternate way of modeling the system. We are using Simscape blocks. We have the yellow block representing the floor, the red block representing the ball, and we have two motion constraint blocks.

      This spatial contact force block allows us to define a friction model that acts on the two bodies in contact. Because I have used these Simscape blocks, a CAD-like viewer can automatically appear when I run the simulation. Let me just tick the box that makes that happen. When I rerun the simulation, here's the mechanics explorer that gives us the CAD-like viewer.

      Do you remember a few minutes ago when we were looking at the oscilloscopes and there was that weird discontinuity in the plots? Well, that event corresponds to the moment that the ball completely rolls off the table. And when we did our brain analysis, we assumed that the bowl would always be in contact with the floor. On the other hand, our Simscape model can handle any scenario.

      Before we wrap up, there's one last thing that I'd like to show you. Let's increase the angle of the floor to say 75 degrees and see what our simulation says. As the simulation is running, notice the red lamp. This is telling us that our brain derivation assumption of pure rolling is actually invalid. It's invalid because the computered friction force is greater than the product of the normal force by the static coefficient of friction. So when our floor is inclined at 75 degrees, we have a combination of rolling and sliding.

      A great way to visualize this behavior is to bring up that Simscape viewer again. And as I scroll through the simulation results, we can clearly see that the ball is indeed experiencing a combination of rolling and sliding. Isn't the Simscape viewer just such a fantastic tool?

      That's enough on this example. What I'd like to do next is continue the conversation on Newton's second law but this time applied to a teaching context more indicative of a second-year level class. So let me introduce our next case study.

      The next example that we're going to look at is deriving the equations of motion for a three link robotic manipulator. We'll be using our brains and computational thinking to apply Newton's second law. And the big takeaway from this case study is how computational thinking removes the influence of a problem scale and complexity.

      Provided your students know the engineering fundamentals, they can use computing technology to take care of the tedious aspects of the derivation. When it's done the right way, there's a certain sense of empowerment that I'm sure your students will experience, the belief that by knowing the engineering fundamentals that technology can help them apply that understanding to big and interesting problems.

      Let's go to MATLAB and I'll show you what I mean. He is a MATLAB live script that we'll be using to develop a model of our three-link robotic manipulator. We're going to derive the equations of motion of this machine. And then we'll control it to move in a desired way.

      For this case study, here's the workflow that we're going to adopt. We'll start out with our core understanding of the engineering principles, for example, free body diagrams and applying Newton's second law. We'll then perform a series of symbolic manipulations. And this will allow us to summarize the machine dynamics into its traditional three degree of freedom form. And we'll then use the derived model within a simulation.

      So the first step in this problem is, of course, drawing the system free body diagrams. And this is something that you expect your students to be able to do. And the free body diagrams would look something like this.

      So the next few steps are all about rearranging, defining, and manipulating what we've defined in our free body diagrams. We're going to use MATLAB's symbolic computing capabilities to help us with these equation manipulation tasks. In preparation for applying Newton's second law, we'll first compute the center of mass accelerations of the orange and purple links. And, look, students should be able to do this part by hand. And when they do, they can check their computations using MATLAB. But after that, our next seven steps are all about writing down Newton's second law, force and moment equations that we produced from our free body diagrams.

      For example, here are the force equations for our orange link. And here's the torque equation about the center of mass for our orange link. And we repeat this identical process for the second link.

      Here are the force equations. And here's the center of mass torque equation. And, finally, we process the last link. Here's the torque equation about the fixed pivot point for the blue link.

      Let me run the script so that you can see these symbolic results that we've produced so far. The symbolic equations that we've just typed in from our free body diagrams are summarized here. We have seven equations with seven unknowns. And these unknowns represent the three joint accelerations along with four of the joint reaction forces. If a student has got to this stage, then they have clearly demonstrated an understanding of how to apply Newton's second law.

      So the next two steps really exemplify computational thinking. We're going to get MATLAB to simply rearrange our seven equations into a specific shape. These are A and B matrices represent our system of ordinary differential equations. And the significance of representing the equations this way is that we can now numerically solve them with Simulink using the standard integrator pattern.

      Now the process for converting our symbolic A and B matrices into a Simulink block, it's an automated process. The MATLAB function block function does this for us automatically. This little yellow Simulink block contains our derived equations of motion written out as a MATLAB function and wrapped up inside a Simulink block. And this little yellow block will be at the very heart of what we do next.

      Our next step is to use this derived mathematical model within a Simulink simulation. And let me show you what that Simulink model looks like now. So here's our Simulink file for simulating the three-link robot. And this Simulink file contains two different modeling implementations of the robot. It contains the hand-derived model that we just produced.

      And for comparison purposes, it also contains a Simscape implementation of the robot as well. For both of these models, we're using a feedback control system to produce the joint torques to make the robot move in a desired way. Now we won't be covering the control design process today. Let's just focus on our mechanical models of the robot.

      Here's the little yellow block that contains our hand derivation. Remember we automatically produce this during our equation of motion derivation from just a few moments ago. I've also included a Simscape implementation of the robot. The Simscape model has three joints, the blue blocks, and it has three rigid body blocks representing the three links.

      Let's simulate this to see what happens. Here's the mechanics explorer that automatically appears because of the Simscape blocks. And you can clearly see that our control system is making the robots end effector trace out the word "hello."

      Now I bet you're wondering if the Simscape model produces the same results as our hand-derived model, let's look at some oscilloscope traces and compare the two model outputs. The yellow plots show the time series results of our hand-derived model. We're looking at the angular positions, velocities, and accelerations of our three joint angles.

      The pink plots show the differences between the hand and Simscape joint positions. And these angel differences are of the order of 10 to the negative 8, really small. So, yeah, we've just validated our hand-derived model using Simscape. So that's all I wanted to say on this example. Let's go back to PowerPoint, and I'll introduce you to our next case study.

      Our next case study today is an example that is often introduced during the third-year level of a dynamics class. And, look, sometimes it creeps into a second-year class too. The case study is a gyroscope. Let me show you yet again how a combination of symbolic computing, Simulink, and computational thinking all come together to help you explore the dynamics of this system with your students.

      For this case study, I'll actually start with Simulink first. And then after we've looked at the models and run a few simulations, then we'll rewind and take a quick look at how MATLAB and symbolic computing helped us create the model. So let's go to Simulink now.

      This Simulink file actually contains three different implementations of this gyroscopic system. Let me start with the Simscape implementation first. Our system is made up of a wheel with a short attached red rod welded to its center. The other end of the red rod is connected to ground via a spherical joint. And we'll apply a time-varying torque to the wheel, which in turn modifies the spin angular velocity of the wheel.

      This staircase plot shows the spin velocity that we'll subject the wheel to. And note that in the last 10 seconds of the simulation the wheel actually isn't spinning at all. So what we're expecting to happen is that the angular momentum of the wheel combined with the gravity torque will make the wheel move in a very hypnotic way. Let's run the simulation and have a look at the mechanics explorer. So here's a view of the system as the model is being simulated.

      And as the simulation advances, our externally applied torque is progressively decelerating the angular spin velocity of the wheel. And as you can see, this causes the procession velocity of the wheel about the vertical axis to actually increase. And this behavior continues.

      In the last 10 seconds of the simulation, the wheel is not spinning at all. And what you see is that it simply collapses under the influence of gravity. Let me bring up some oscilloscope traces and I'll show you the three oil angles of the system versus time.

      These three axes show the procession, mutation, and spin angles as a function of time. In each axis, we're plotting the Simscape results in blue. And we've superimposed in yellow the corresponding results produced by a hand-derived model. And as I zoom in, you can see that these two results are very, very similar.

      So where did this second yellow set of results come from? Well, it came from here. This is a Simulink implementation of a brain or hand-derived model. The yellow block contains the hand-derived equations of motion. And if I double click on it, you'll see that it's one of these automatically generated blocks from the Symbolic Math Toolbox. So what I'd like to do next is rewind and quickly show you the MATLAB script that helped us do this brain derivation of these equations of motion.

      This MATLAB script does quite a few things. It allows me to display relevant diagrams and to clarify what the body-fixed and semi-fixed frames are in this analysis. It allows me to compute some of the inertia matrices that will be used and to summarize the gravity torque factor that's applied to the system. So the script is allowing me to centralize my thoughts and to document my analysis.

      Another great example of this knowledge capturing workflow is being able to type up a derivation and then placing it as an appendix at the bottom of the file. And that's what I've done in this example. Here's an appendix where I've derived a particular form of the modified Euler moment equation.

      The text that's on screen right now, it's all just commentary. It's storytelling. The MATLAB Live Editor allows us to write out the fundamental dynamic expressions in this richly formatted mathematical markup form. So anyone that is reviewing this analysis can really accelerate their understanding of what it is that I was trying to do. So the rest of the script is about implementing this modified Euler equation in symbolic form.

      On the left-hand side, you can see the MATLAB expressions that are being defined. And on the right-hand side, you're seeing those same expressions being echoed in beautifully formatted form. The Symbolic Math Toolbox really does make it easy to do so many of those laborious equation rearrangement tasks. For example, here, I'm replacing the angular velocities and accelerations with the corresponding Euler rate form. And after I've made those substitutions, I can again ask MATLAB to symbolically solve for the accelerations that I'm interested in.

      Here, finally, are the three ordinary differential equations that represent our gyroscopic system. In order to numerically solve these ordinary differential equations in Simulink, I don't need to waste my time manually typing them out. Instead, I can get MATLAB to automate that process. The MATLAB function block function will automatically convert our Simulink expressions into a little yellow Simulink block that is ready to be used. And here it is.

      Here's the automatically generated function that we were looking at five minutes ago. It represents our brain-derived model of the gyroscopic system. Just copy and paste this little yellow block into a Simulink file and you're ready to start simulating just like we did at the start of this case study.

      So that's all I've got to say about this example. Let's go back to PowerPoint. And I'll introduce to you the next example.

      Our next case study looks at an interesting application of the Lagrangian formulation for deriving equations of motion. And this topic is typically introduced in that third to fourth year of an engineering dynamics class. We're going to look at developing a model of a gyroscopic boat stabilization system. How can we use the angular momentum of a spinning disk to overcome wave disturbances that are trying to rock a boat?

      Now, our computational thinking workflow is the same as our previous examples. We'll develop a brain model. We'll compare our brain derivation to a Simscape model. And we'll simulate the models to observe cause and effect behavior. Now as we did in the previous example, I'm actually going to start this case study with the final Simulink file. And then we'll rewind and look at how the brain-derived model was produced.

      So let's go to Simulink. Here's our Simulink file. It contains a couple of Simscape models, as well as a brain-derived model. When we simulate this system, here is the Simscape viewer that appears.

      We actually have two boats being displayed. The red boat has the gyroscopic stabilizer disabled, while the blue boat has the stabilizer enabled. And when I simulate the model by applying identical torque disturbances to both boats, you can clearly see the impact that our stabilization system is having on the blue boat.

      The couple dynamics of the gyroscope is absorbing the torque disturbance and converting it into that pitching or precession motion of the green cage, which houses the yellow spinning disk. It's amazing, isn't it? Let me show you now a couple of oscilloscope plots that summarize the dynamics of the stabilized blue boat.

      Remember that all of these axes are displaying time series results. Here's the torque disturbance that we applied to both the blue and red boats. And here's a series of torque impulses that we applied to the yellow disk. And this allowed us to regulate the speed of the spinning disk so that we could explore cause and effect. The remaining plots all show the Euler angle positions, velocities, and accelerations of our system.

      Let me zoom in on the role angle of the ship's hull. And as I zoom in, you can see that we have two data sets being displayed on this axis. The pink data set was produced using our Simscape model.

      And, yep, you guessed it. The blue data set was produced by our brain-derived model. And, again, the two results are almost identical.

      So where did this brain-derived model come from? Well, it's here. This little yellow block was produced by our brain derivation of this system. And when I double-click on it, you can see that it's another one of these Symbolic Math Toolbox auto-generated functions. So let's now take a closer look at exactly how we derived these equations of motion.

      Here's a live script that we're going to use to apply our understanding of the engineering concepts for our gyroscopic boat stabilizer. And this example uses the Lagrangian technique for deriving the equations of motion. The live script really does provide such a stunning canvas for creating these richly formatted teaching documents. But it's obviously not just about the pretty pictures, yeah?

      The Symbolic Math Toolbox, it allows the conceptual steps of the derivation to be implemented, things like computing the center of mass velocities, things like computing the angular velocities, computing the kinetic and potential energies of the rigid bodies in our system. And the big benefit is that the size and scale of the expressions that we're creating aren't interfering with our problem-solving process.

      So once we've let the students apply their understanding of fundamental kinematics, the next part of the derivation is all about applying the derivative chain rule according to Lagrange's technique. Now, conceptually, students know how to do this. But the stink is that the expressions that need to be considered contain dozens and sometimes hundreds of terms. But these laborious computations can effortlessly be done with the Symbolic Math Toolbox without there being any dilution of the learning experience.

      Here's a simple MATLAB function that allows us to implement the symbolic operations of computing Lagrange's equation. As I scroll down the script, here's the section where we compute the system generalized forces. We're taking our understanding and converting it into implementation. Let me run the script, and I'll show you an example of what the derived equations of motion actually look like.

      Here are the three equations of motion for the boat stabilizer. There's quite a few terms, perhaps too many times for this to really be attacked using pen and paper. So after deriving the equations of motion, we now get the Symbolic Math Toolbox to automatically convert the equations of motion into a MATLAB function block. This little yellow Simulink block contains our derived equations of motion.

      Here's the MATLAB function that is wrapped up inside the block. And now we've come full circle. The little yellow block produced by our brain derivation simply gets pasted into a Simulink file. And you are ready to simulate just like we did at the beginning of this case study.

      Now I know that some of this is probably getting a little repetitious. But in a way, that is at the very heart of today's message. There is a computational thinking workflow that can span from a first-year application right up to that third and fourth year. I have one more, just one more example to show you today. So let's go back to PowerPoint.

      So the last example that I'd like to show you today is another application of the Lagrangian approach for model derivation. It's kind of a fun and interesting example. We're going to derive the equation of motion of a quadcopter that balances an inverted pendulum.

      Now we won't be covering the control system design task. That's for another time. Today, we'll just focus on developing a mathematical model of the machine dynamics. We're going to apply the exact same computational thinking workflow that you've seen over the last hour.

      We'll use our brains along with the Symbolic Math Toolbox to derive the system equations of motion. And then we'll compare the output of this brain derivation against the same system modeled in Simscape. So let's go to MATLAB and check it out.

      Here's a live script that we'll use to derive the equations of motion of a quadcopter balancing an inverted pendulum. We'll use this script to capture the thought process involved in the derivation. And we'll also include the MATLAB code that implements our understanding of the engineering principles. We start solving this problem by parameterizing the quadcopters airframe.

      We define its generalized coordinates. And we then start computing the velocities of the airframe and propeller assemblies. And note, again, the rich canvas that the live script provides. We document what we're thinking. And then immediately below it is the MATLAB implementation.

      So after characterizing the airframe and propellers, we, of course, need to do the same again for the pendulum. And note that while we're working through the solution, our focus is on applying those engineering principles. We don't need to be concerned by the scale of the computations that are involved, which as you'll see from this pendulum angular velocity term the computations are becoming uncomfortably large if you were trying to do it only with pen and paper.

      So after the engineering principles are applied, we perform a series of symbolic computations using the Lagrangian technique. The results of these symbolic computations are a collection of nonlinear, ordinary differential equations, which are the equations of motion for the quadcopter pendulum assembly. After computing the symbolic equations of motion, our next step in this exercise is to simply rearrange those derived equations of motion into a particular form. And the form that we're using here is one that is common amongst the robotics community, generating nonlinear mass, damping, stiffness, and gravity matrices.

      So after this equation rearrangement step, the final step is to automatically convert those equations of motion into a Simulink block. And here it is. Here's the automatically generated Simulink block that now contains the equations of motion of our quadcopter pendulum assembly. And as you've seen on numerous occasions now, you know that when I double-click on this little yellow block, it's going to reveal a MATLAB function that captures those equations of motion. And this MATLAB function has been automatically generated by this Symbolic Math Toolbox.

      OK. The last thing that I'd like to show you is the Simulink model, the Simulink model that contains this brain-derived derivation. So let's go to Simulink. So here's our Simulink file. And it contains two different modeling implementations of the quadcopter and pendulum assembly.

      Now both of these models are being stimulated by identical control laws. Let me first show you where our brain-derived model is. Here's the little yellow block that we produced just a few moments ago. We also have a Simscape implementation of the system. Let me show you what that looks like.

      Here we have a rigid body block for the airframe. And we have rigid body blocks for each propeller assembly. And, of course, we have the pendulum, which is attached to the airframe via a spherical joint.

      When we simulate this system, the Simscape viewer appears. And we can visualize the complex dynamics of this system in action. The control system is producing the propeller torques to both balance the pendulum and make the quadcopter traverse around a predefined flight path.

      So this is being produced by our Simscape model. But what about our brain-derived model? Let me bring up some oscilloscope time traces.

      These axes show the times series response of our 9 degrees of freedom. On each axes, we're showing our Simscape response in yellow and our brain-derived model response in blue. And as I zoom in, you can see that we, again, are getting very close agreement between the two different models. So from a student's perspective, you could view this comparison as a validation feedback that the engineering principles in our brain derivation were correctly applied. Let's go back to PowerPoint, and I'll summarize and also talk about some potential next steps.

      In the last hour, we've looked at seven case studies that contain concepts that are typically taught throughout a four-year undergraduate degree. And we've looked at how a computational thinking approach could be used to support the analysis and exploration of these systems. By using the Symbolic Math Toolbox, Simulink, and Simscape in the right way, you really can encourage a student to apply, analyze, and evaluate the concepts that you want them to develop competencies in.

      Now, if you're curious about trying some of this in your own classes, the next big question has to be this one. How do you get started when perhaps you haven't really used some of these tools before? And I'd like to offer four suggestions. My number one suggestion has to be the MATLAB Help Browser. Built directly into the MATLAB desktop is this help icon.

      When you click it, it launches the MATLAB Help Browser. And the Help Browser is a blend of a digital users guide with a web browser. You can use it to search for information on how to do specific things.

      For example, here's a Getting Started with Simulink page. Here you can access tutorials on how to use Simulink, as well as access hundreds of example models that we ship within the product. This MATLAB Help Browser really is an extremely helpful resource if you want to learn how to use our products.

      My second tip for getting started is our library of self-paced online training courses. The courses are presented through your web browser. So you can log in, do 30 minutes, then come back tomorrow and pick up where you last left off.

      And these courses don't just deliver static text and videos. But they also provide a built-in desktop into your browser where you get to apply and practice the concepts that are being taught in the videos. I'd recommend the Simulink Onramp, as well as the Introduction to Symbolic Math as two great courses to consider.

      My third suggestion is to check out our Online Teaching with MATLAB website. This site contains resources to help you ramp up on all of our new tools that have been developed specifically to help teaching. For example, if you've never used the live editor before, you'll find a quick 20-minute video explaining how to use it to make engaging documents for your class.

      And my final suggestion on getting started is to speak with one of our customer success engineers. Our customer success team can support you in developing new curriculum for your class. They can run hands-on workshops for you and your support team, such as the postgraduate students who are tutoring your class. And the work that these customer success engineers do is absolutely free.

      So that brings me to the end of this presentation. An offer that I'd like to leave you with though is this. If you're interested in getting some of the examples that we demonstrated today, then send a query to this email address and request to speak with one of our customer success engineers. One of our engineers will call you, speak to you about the classes that you're teaching, and discuss some concrete ways that we can support you. Thank you very much, everyone, for your time today.