|
Here's an AnyScript file to start on if you have not completed the previous lesson: demo.lesson4.any.
If you have completed the three previous lessons, you should have a model with an upper arm grounded at the shoulder joint and connected to a forearm by the elbow. What we want to do now is to make the arm move.
How can an arm with no muscles move? Well, in reality it cannot, but in what we are about to do here, the movement comes first, and the muscle forces afterwards. This technique is known as inverse dynamics. We shall get to the muscles in the next lesson and stick to the movement in this one.
Our mechanism has two degrees of freedom because it can rotate at the shoulder and at the elbow. This means that we have to specify two drivers. The natural way is to drive the shoulder and elbow rotations directly and this is in fact what we shall do. But we could also choose any other two measures as long as they uniquely determine the position of all the segments in the mechanism. If you were building this model for some ergonomic investigation, you might want to drive the end point of the forearm where the wrist should be located in x and y coordinates to simulate the operation of some handles or controls. And this would be just as valid a model because the end point position uniquely determines the elbow and shoulder rotations.
For now, let's make a new folder and define two drivers:
}; // Jnts folder
AnyFolder Drivers = {
//---------------------------------
AnyKinEqSimpleDriver ShoulderMotion = {
AnyRevoluteJoint &Jnt = ..Jnts.Shoulder;
DriverPos = {-100*pi/180};
DriverVel = {30*pi/180};
}; // Shoulder driver
//---------------------------------
AnyKinEqSimpleDriver ElbowMotion = {
AnyRevoluteJoint &Jnt = ..Jnts.Elbow;
DriverPos = {90*pi/180};
DriverVel = {45*pi/180};
}; // Elbow driver
}; // Driver folder
This is much like what we have seen before. The folder contains two objects: ShoulderMotion and ElbowMotion. Each of these are of type AnyKinEqSimpleDriver. A driver is really nothing but a mathematical function of time. The AnyKinEqSimpleDriver is a particularly simple type that starts at some position at time = 0 and increases or decreases at constant velocity from there. These two drivers are attached to joints, and therefore they drive joint rotations, but the same driver type could be used to drive any other degree of freedom as well, for instance the Cartesian position of a point.
The lines
AnyRevoluteJoint &Jnt = ..Jnts.Shoulder;
and
AnyRevoluteJoint &Jnt = ..Jnts.Elbow;
are the ones that affiliate the two drivers with the shoulder and elbow joints respectively. They are constructed the same way as the joint definition in Lesson 3 in the sense that a local variable, Jnt, is declared and can be used instead of the longer global name if we need to reference the joint somewhere else inside the driver. Notice also the use of the reference operator '&' that causes the local variable to be a pointer to the global one rather than a copy. It means that if some property of the globally defined joint changes, then the local version changes with it.
The specifications of DriverPos and DriverVel are the starting value of the driver and the constant velocity, respectively. Since these drivers drive angles, the units are radians and radians/sec.
Try loading the model again by hitting F7. If you did not mistype anything, you should get the message "Loaded successfully" and no complaints about lacking kinematic constraints this time.
This is good news, because you are now actually ready to see the model move. If you look closer at the pane in the bottom of the main frame, you will notice that it now contains the root of a tree in its upper left cell. This is the place where the AnyBody system places your studies, and from this window you can execute them, i.e., start analyses and calculations.

Try expanding the ArmStudy root. You will get a list of the study types that the system can perform. "Study" is a common name for operations you can perform on a model. When you click one of the studies, the buttons on the middle, lower part of the panel come to life. Try clicking the KinematicAnalysis study. With the buttons, you can now execute various types of analysis. The panel contains three buttons:
- Run. This button starts the highlighted study and runs it until the end, usually producing some sort of motion in the model. When Run has been pushed, it changes name to Break. If you push it in this state, it pauses the running operation. F5 is a shortcut to this function to Run and Break.
- Step. This button advances the operation one step. What a step is depends on the type of operation, but it is typically a time step in a dynamic analysis. (F6 is the shortcut key for Stepping)
- Reset. This puts the operation back to its initial position. You must reset before you can start a new analysis, if you have stopped it in the middle. (F4 is the shortcut for resetting operations)
All these functions are also available from the Main Frame toolbar and the menu Operation.
Do you have a Model View window open? This is the one where you can see the model graphically. If not, open one with Window->New model view from the pull down menus at the top of the screen. Now, try your luck with the KinematicAnalysis study and the Run button. What should happen is that the model starts to move as the system runs through 101 time steps of the study.
Since we have no muscles so far, kinematic analysis is really all that makes sense. A kinematic analysis is pure motion. The model moves, and you can subsequently investigate positions, velocities, and accelerations. But no force, power, energy or other such things are computed. These properties are computed by the InverseDynamicAnalysis, which is actually a superset of the KinematicAnalysis.
Try the Reset button, and then the Step button. This should allow you to single-step trough the time steps of the analysis. When you get tired of that, hit the Run button, and the system completes the remaining time steps.
The analysis has 101 time steps corresponding to a division of the total analysis time into 100 equal pieces. The total time span simulated in the analysis is 1 sec. These are default values because we did not specify them when we defined the ArmModelStudy in the AnyScript model. If you want more or less time steps or a longer or shorter analysis interval, all you have to do is to set the corresponding property in the ArmModelStudy definition. When you click "Run", all the time steps are executed in sequence, and the mechanism animates in the graphics window.
So far, the model is merely a two-bar mechanism moving at constant joint angular velocities. There is not much biomechanics yet. However, the system has actually computed information that might be interesting to investigate. All the analysis results are available in the ArmModelStudy branch of the tree view. You can expand the tree as shown in the figure to the right.
Directly under the ArmModelStudy branch you find the Output branch where all computed results are stored. Notice that the Output branch contains the folders we defined in the AnyScript model: GlobalRef, Segs, and so on. In the Segs folder you find ForeArm, and in that a branch for each of the nodes we defined on the arm. Try expanding the branch for the HandNode. It contains the field 'r' which is the position vector of the node. We might want to know the precise position of the HandNode at each time in the analysis, for instance if we were doing an ergonomic study and wanted to know if the hand had collided with anything on its way.
If you double-click the 'r' node, the position vector of the hand node for each time step is dumped in the message window at the bottom of the screen. So you get the information you wanted, but perhaps not in a very attractive way. But we can do much better than that. AnyBody has special windows for investigating results. You open them from the pull-down menus by choosing Window -> ChartFX 2D (new).
This gives you a new window structured just like the editor window with a tree view to the left, but with an empty graphics field instead of the large text editor field to the right. The graphics field is for graphing results.
The tree in this window is much like the tree in the editor window except that some of the data have been filtered out, so that you mainly see the parts of the tree that are relevant in terms of results or output. You can expand of the tree in the chart window through ArmStudy and Output until you come to the HandNode. When you pick the property 'r', you get three curves corresponding to the development of the three Cartesian coordinates of this node during the analysis. Try holding the mouse pointer over one of the curves for a moment. A small label with the global name of the data of the curve appears. All data computed in AnyBody can be visualized this way.

So far, we have only the kinematic data to look at. Before we can start the real biomechanics, we must add some muscles to the model.
This is the subject of Lesson 5: Definition of muscles and external forces.
|