See attached file
trunkAnimate.dvi ME 5241 Computer Aided Engineering Tom Chase Spring 2022 Project #2, Finale Animation of a Trunk Lid Hinge Linkage (structured programming materials due Friday 3/18/22; program code due Wednesday 3/23/22) Overview I am fascinated by interesting linkages. One that caught my attention recently is the hinge linkage used for the trunk lid of a 2011 Cadillac CTS sedan. The basic linkage is a Grashof double-rocker four bar linkage (see Fig. 1). This assignment will consist of demonstrating the working of this trunk lid linkage by animating a model of it. Along the way, we will learn how to exploit the “graphics pipeline” to help us perform animations1. We’ll also learn how to implement animations in MATLAB. The animation will be limited to two dimensions for simplicity; i.e., only the plane of motion of the links should be drawn. You can exercise your creativity by making the links utilized in the animation appear realistic. The overall quality of representation of your mechanism will be considered in the grading. You will be able to re-use several functions that you developed for Project 2 Parts 1 & 2 in this portion of the project. Some will require minor modification or enhancement. For example, the trunk lid linkage is a Grashof double-rocker mechanism, not a non-Grashof mechanism. There- fore, your limits of motion code will need to be modified or extended to analyze this particular mechanism. 1Robotics and advanced kinematics leverage essentially the same background. Figure 1: Trunk lid linkage (fully open position). 1 -400 -300 -200 -100 0 100 200 300 400 -300 -200 -100 0 100 200 300 400 500 600 Trunk Lid Linkage Animation Re-Run Figure 2: The MATLAB graphics window of the completed animation. The trunk lid linkage is shown at the fully open position. Note that a pushbutton is provided at the right of the plot to re-run the animation. If you are a graduate student, you are asked to implement (a) button(s) to open and close the trunk lid. (A simple stick figure representation of the mechanism will earn substantial partial credit if well written.) 2 More About the Trunk Lid Linkage The basic links of the mechanism are described with vectors ~r1 (ground), ~r2 (driver), ~r3 (basic cou- pler), and ~r4 (follower), consistent with the “Four Bar Linkage Displacement Equations” handout that is posted on the Canvas course site. The car body serves as the ground link. The fully open and closed positions of the trunk lid linkage are represented by: Fully Closed Position Fully Open Position ~r1 = 150.0 mm /180.0 ◦ (ground) ~r1 = 150.0 mm /180.0 ◦ ~r2 = 205.0 mm /170.0 ◦ (driver) ~r2 = 205.0 mm /140.0 ◦ ~r3 = 40.0 mm /− 174.3 ◦ (basic coupler) ~r3 = 40.0 mm /− 62.4 ◦ ~r4 = 97.0 mm /160.9 ◦ (follower) ~r4 = 97.0 mm /83.2 ◦ µ = +1 (configuration) µ = −1 In reality, the trunk lid linkage is coupler driven; e.g., the user lifts the trunk lid directly. However, using the coupler link as the “driver” makes using our simple four bar linkage displacement analysis code (as defined in the “Four Bar Linkage Displacement Equations” handout) awkward. Therefore, for the purposes of this project, we will assume that the link that is pinned to ground, and closer to the rear of the car, serves as the driver link. A complication of this assumption is that the linkage appears to pass through a “stationary configuration”, where the coupler and follower links become collinear and the driver reaches its lower limit of motion. Therefore, the configuration of the linkage, µ, changes between the fully closed and open positions. While we usually consider this to be a problem, in reality, it is not for this linkage, as vector ~r2 is not really the driver link. But our analysis code needs to account for the change in direction of the driver link while moving from the fully closed to the fully open position. More specifically, when the linkage is in the fully closed position, the angle of the driver link is 170◦ and the linkage configuration is µ = +1. The driver angle decreases as the trunk lid opens. The driver then rotates to its lower limit of motion (approximately2 138◦). The configuration then changes to µ = −1, and the driver angle increases until the trunk lid reaches its fully open position (where the angle of the driver link is 140◦). Program Guidelines 1. You must implement your animation using the “graphics pipeline” described in lecture. Using the graphics pipeline will enable simplifying your code! Using modeling coordinates enables you to focus on the link geometry without worrying about the four-bar kinematics. Do not be concerned with the actual (x, y) position and angle of each link when you are defining its geometry. Rather, reference the geometry of each link to a convenient local coordinate frame. For example, if one of the links were represented as a triangle, you might define its geometry as suggested in Fig. 3, regardless of its actual position and angle. Note that point A is aligned with the local origin and B is aligned with the local x-axis. The modeling coordinates for the link are then read directly from the local coordinate frame. 2Please calculate the lower limit of motion accurately using your limits of motion function. 3 ����������� ����������� ����������� ����������� ����������� ����������� ����������� ����������� x y C B A Figure 3: Defining a link relative to a convenient local coordinate frame. When this link is animated, a modeling transformation is applied to move the entire link to its proper position in the world coordinate frame. Specifically, the coordinates of point A, (xA, yA), and the angle of the link, θ, can be obtained from your four bar displacement analysis function. Then you can use these values to set up a modeling transformation to move the link from modeling space to its actual position in world space. All three moving links can be rotated and translated to their kinematically correct positions in this manner. The procedure is clarified below: Position the driving link. – Rotate the driver by /~r2. – Translate the driver by (xAO, yAO) (if AO is not at the origin). Position the coupler link. – Rotate the coupler by /~r3. – Translate the coupler by (xA, yA). Position the follower link. – Rotate the follower by /~r4. – Translate the follower by (xBO, yBO). Note that you will need 3 different modeling transformation matrices to position the 3 moving links in world space. 2. Undergraduates are asked to animate the trunk lid linkage by starting at the fully closed position and ending at the fully open position. A MATLAB “uicontrol pushbutton” should be provided to enable re-running the animation (see Fig. 2). If pushed, the linkage should return to the fully closed position, then the animation is repeated. 3. Graduate students are asked to provide uicontrols to enable toggling the trunk linkage between the open and closed positions. In other words, if the linkage is in the fully open position, a uicontrol should be provided to close it. If the linkage is in the fully closed position, a uicontrol should be provided to open it3. 3You may use one or two buttons, as you prefer. 4 4. All students are asked to include the following elements shown in Fig. 2: (a) A representation of the two ground pivots, AO & BO. (You do not have to use the symbols shown in Fig. 2.) (b) The two moving pivots, A & B. (c) The driver link. (d) The coupler link. (e) The follower link. A simple stick figure representation of the linkage will suffice to earn substantial partial credit, if they animate properly. However, to earn full credit, you are expected to represent the moving links more realistically, as suggested in Fig. 2. In particular, an improved representation of the trunk lid (coupler link) is valued4. 5. Please include a minimum of 50 positions in your final animation5. 6. An important aspect of this project is to take advantage of modeling transformations. Ap- plying modeling transformations should make it relatively easy for you to implement the animation. If you find that you are having to write a lot of code or that your code is becom- ing very complicated, then you are probably not properly utilizing modeling transformations. 7. You only need two modeling transformations to implement this project: a simple 2-dimensional translation, and a simple 2-dimensional rotation about the origin. Some of the transformations that you need to implement the animation may require combining multiple transformations. However, you do not need any more modeling transformations than these two: simply multiply the translations and the rotations in the correct order to obtain a multiple transformation. A suggested input/output chart for your 2-dimensional translation function is: updated modeling transformation matrix (modMtx) current modeling transformation matrix (modMtx) y−translation (TY) trans2D: Add an (x,y) translation to a mod mtx x−translation (TX) The rotation function will have a very similar structure. Note that the input transformation matrix and the output transformation matrix are neces- sarily the same matrix. However, the values of the elements of the matrix will have changed as a result of sending it through “trans2d”. 8. You can build a complex modeling transform by taking a modeling matrix initialized to the identity matrix and modifying it with any desired combination of translations and rotations6. 4You do not need to use the exact representations shown in Fig. 2 (although that is acceptable). Use your creativity to illustrate the links. 5I recommend using far fewer positions (maybe 3-5!) while creating and debugging your animation. 6A 3×3 identity matrix called “modMtx” can be created in MATLAB by using the standard “eye” function: modMtx = eye(3); 5 (Remember, order is important!) For example, you could build a rotation of 90◦ about point (1, 1) by sending an initialized modeling transform through “trans2d” with TX and TY set to −1, then sending the same modeling transform through “rot2d” with θ set to 90 deg, then sending the same modeling transform through “trans2d” with TX and TY set to +1. If desired, the modeling transform can be re-set to the identity matrix at any time to cancel any previously applied transformations. 9. The functions described so far set up the graphics pipeline, but none of them actually generate any graphics output! You will likely need functions to draw filled polygons and lines7. A filled polygon can be created with the MATLAB “patch” function. A line can be created with the MATLAB “line” function. Your animation can be implemented efficiently if you provide two different functions for drawing filled polygons, and two very similar functions for drawing a line8. The first polygon function should create a polygon in modeling