modeling squat jump

Upload: albert-ai

Post on 10-Jan-2016

36 views

Category:

Documents


5 download

DESCRIPTION

Models the human squat jump using symbolic python

TRANSCRIPT

  • Modeling a Squat Jump Using SymbolicPython

    Albert Ai

    August 27, 2015

  • Contents

    1 Introduction 31.1 Modeling a Human Jump . . . . . . . . . . . . . . . . . . . . 31.2 Symbolic Python for Multibody Systems Reference Frames

    and Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Kinematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 Building the body . . . . . . . . . . . . . . . . . . . . . . . . . 41.5 Kanes Method . . . . . . . . . . . . . . . . . . . . . . . . . . 51.6 Equation of Motion . . . . . . . . . . . . . . . . . . . . . . . . 51.7 Impulse - Momentum Method . . . . . . . . . . . . . . . . . . 7

    1

  • 2 Programming and Implementation 102.1 Programming Details . . . . . . . . . . . . . . . . . . . . . . . 10

    2.1.1 Libraries Used . . . . . . . . . . . . . . . . . . . . . . . 102.1.2 Details of Files and Functions . . . . . . . . . . . . . . 11

    3 Programs and Functions 113.1 Body Part Object - BodyModel.py . . . . . . . . . . . . . . . 113.2 Body Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.3 Modeling the dynamics - BodyJumpForce.py . . . . . . . . . . 133.4 Graphical User Interface . . . . . . . . . . . . . . . . . . . . . 13

    4 References 15

    5 Acknowledgement 16

    2

  • 1 Introduction

    There are two variations of the human vertical jump the countermovementjump, which involves a springing from a standing position to add potentialenergy, and the squat jump, which is a simple jump from a squatting position.This program was written in symbolic python to simulate the squat jumpvariation of the human jump.

    1.1 Modeling a Human Jump

    A human vertical jump is divided into two phases. In the first phase, thesubject rotates its body into a standing position while retaining a certainamount of upwards momentum, and in the second, uses the built up mo-mentum to launch itself into the air. The second phase is simple and can bemodeled as upwards projectile motion with any method of linear approxima-tion such as Eulers Method. However, the first phase is a lot more difficultto the fact it has multiple simultaneous moving components involved.

    In the first phase, there are three degrees of freedom to worry about arotation at the ankle, knee, and hip. For simplicitys sake, I have modeled thesystem as three rotating rigid bodies and a static ankle as a fixed referenceframe, with three joints modeled as ideal torques between the adjacent bodyparts. For each joint, the required torque will be determined according tothe starting position of the human body and the mass of the segments at thestarting points.

    1.2 Symbolic Python for Multibody Systems Refer-ence Frames and Symbols

    The advantage of using a symbolic language such as SymPy for this project isthat it can break a complicated multibody rotating system down to a groupof reference frames with properties assigned to them. With parameters set,these reference frames can then be modeled using a wide number of existingsimulation modules built into SymPy. There are four reference frames inthe model the torso reference frame, upper leg reference frame, lower legreference frame, and a fixed inertial reference frame I chose to representthe ankle.

    3

  • 1.3 Kinematics

    Using the ReferenceFrame module in SymPy, I can define the orientation ofeach frame relative to the other reference frames, along with an initial angularvelocity and acceleration. With the sympy.physics.mechanics library, I canautomatically calculate the linear and angular velocity of the center of massfor each frame as it rotates.

    I start by setting the orientation of the lower leg relative to the fixed ankleframe. To do this, I first define a value for 1, 2, and 3, the flexion angles ofthe ankle, knee, and hip respectively. The built in ReferenceFrame.orient()function makes orienting the frames to each other simple. The functionrequires the following: input parameters of a fixed frame, initial rotationangle, and a directional vector about which to rotate. For this simulation, Ivechosen to start the movement by rotating the lower limb counter-clockwisealong the Z axis. The rotation matrices used for this are as follows:

    Lower leg.dcm =

    cos(1) sin(1) 0sin(1) cos(1) 00 0 1

    I can then rotate the upper leg relative to the lower leg through the knee

    flexion angle, 2. Adding the two angles flips the sign, causing it to rotateclockwise.

    Upper leg.dcm =

    cos(1 + 2) sin(1 + 2) 0sin(1 + 2) cos(1 + 2) 00 0 1

    Likewise, the rotation matrix of the torso can be defined with a similar

    rotation matrix about the Z direction.

    Torso.dcm =

    cos(1 + 2 + 3) sin(1 + 2 + 3) 0sin(1 + 2 + 3) cos(1 + 2 + 3) 00 0 1

    1.4 Building the body

    With a method to set the orientation of the 3 limbs created, I need to definethe positions of the various joints and center of masses in their referenceframes. I will use the ankle as a fixed point for the system, such that allother points in the system will be defined with respect to the ankle. Theknee joint K is then defined with respect to the ankle using a vector thatis equal to the length from the ankle to the knee, L1 in the direction of

    4

  • the lower leg unit vector, iy. To do this, I needed to define a new con-stant length for the lower leg and to define the point of the knee K and theother pivot points. This can be easily done with the Point.setpos function,which returns the reference point along with the vector and can also be usedto express the returned vector with respect to another reference frame. Thus:

    Vector of position of Knee in lower leg reference frame = Ll.iyVector of lower leg in Sole reference frame = Ll sin(1)ix+Ll cos(1)iy

    In a similar fashion the hip is defined with respect to the knee.

    Vector of position of Hip in Upper leg reference frame = Lu uy Position ofHip in Sole reference frame = (Llsin(1)Lusin(1 +2))ix+(Llcos(1)+Lucos(1 + 2))iy

    1.5 Kanes Method

    With the reference frames built, I used a computational method designedfor symbolic languages explicitly created to simplify and model multibodysystems Kanes method.

    Kanes method as implemented in SymPy requires a set of generalizedspeeds w1, w2, w3 such that the time derivative of these generalized speedsare equal to their generalized coordinates. From there, the equations ofmotion can be easily derived in first order form. First, I create the timevarying symbols in Python:

    n = n

    n n = 0 :[1 1, 2 2, 3 3]

    1.6 Equation of Motion

    Now I can use the KanesMethod module, a built in function in SymPy foran automated computation of the first order differential equations. At abare minimum for unconstrained systems, KanesMethod in SymPy needsthe generalized coordinates, generalized speeds, the loads, the bodies, and aNewtonian reference frame.

    5

  • First, I made a list of the generalized coordinates, i.e. the three joint angles:

    coordinates = [1, 2, 3]

    Then I listed the generalized speeds, i.e. the angular velocity:

    speeds = [1, 2, 3]

    Now I can use KanesMethod to build the object with the inertial refer-ence frame, coordinates, speeds, and kinematical differential equations:

    [1 1, 2 2, 3 3]kane = KanesMethod(inertial frame, coordinates, speeds, kine-

    matical differential equations)

    The equations of motion can now be computed using the kanes equationsfunction, which takes the list of loads and bodies and returns the equationsof motion (i.e. first order ordinary differential equations) in Kanes form:

    Fr + Fr = 0

    Which is essentially equivalent to the classic Newton Euler form:

    F = maT = I

    With a reliable way of calculating the forces and torques, I can chooseone of several methods to calculate the trajectory of the jump. The methodI chose to calculate the jump for this project was the Impulse-momentummethod, detailed extensively in reference 1

    6

  • 1.7 Impulse - Momentum Method

    7

  • Countermovement jump impulse-momentum curve:

    Squat jump impulse-momentum curve:

    8

  • The integral of a force over time is equal to a change to the momentumof a body,

    J =Fdt = P

    Applying this formula to the ground contact phase of the jump, startingfrom when the jumper is stationary with v = 0 and t = 0 to the instant oftakeoff where a = 0 gives

    J =

    (FGRF )mg)dt = mvi

    The impulse due to the resultant force on the jumper may be consideredas two separate impulse: t2t1FGRFdt

    t2t1mgdt = JGRF JBW = mvt0

    These areas are shown in the figure below:

    9

  • With the rotation angle and angular velocity of each segment updatedand summed using Kanes method, I have determined the inertia forces ofeach segment at the end of the first phase of the movement. With thesevalues stored, I can use the trapezoidal rule with the trapz function to cal-culate the vertical velocity in the last second of stage one. At the moment oftakeoff, the ground reaction force is equal to 0, which means the jump willbe the result of throwing the body into the air with a specific velocity. Themaximum height then, is determined using the equation below, which wascalculated at the beginning of the project.

    Hmax =v2t02g

    2 Programming and Implementation

    This section describes the programming aspect of the squat jump model

    2.1 Programming Details

    The program was created with Symbolic Python as a core library. Thefollowing is a full list of libraries used.

    2.1.1 Libraries Used

    wxPython http://www.wxpython.org/ Python bindings to the wxWin-dows GUI cross-platform toolkit. All GUI files were created using thesimple wxPython builder.

    mpmath http://mpmath.org mpmath is a Python library that calculatereal and complex floating-point arithmetic with arbitrary precision

    SymPy www.sympy.blogspot.in SymPy is a symbolic language libraryin Python

    PyDy www.pydy.org Multibody dynamics tool kit package NumPy www.numpy.org NumPy is the fundamental package for nu-

    merical computing with Python

    SciPy www.scipy.org Open Source Library of Scientific Tools

    10

  • IPython www.ipython.org IPython is a command shell for interactivecomputing and animation

    matplotlib www.matplotlib.org matplotlib is a python 2D plotting li-brary

    Cython www.cython.org Cython is an optimising static compiler forboth the Python programming language and the extended Cython pro-gramming language (based on Pyrex

    Theano www.deeplearning.net/software/theano/ Theano is a Pythonlibrary that allows you to define, optimize, and evaluate mathematicalexpressions involving multi-dimensional arrays efficiently.

    2.1.2 Details of Files and Functions

    Active Scripts

    1. jumpsim - Simulator Startup Script

    2. jumpsimtest - Test to plot angular velocity against time

    Core Data Model and Simulation files

    1. bodymodel.py - Defines the BodyModel class built using the BodyPartobject

    2. bodyjumpforce.py - Builds physical properties to the BodyModel whenkinematic equations are calculated via Kanes Method

    3. jumpsimcore.py - Integrates the functions together

    4. transmat3.py - Function to impelement rotation matrices

    3 Programs and Functions

    3.1 Body Part Object - BodyModel.py

    This is the basic building block of the simulator. A Body part is an objectwhich has the following properties. (Refer to the kinematics section for moredetails)

    frame - Reference frame

    11

  • theta - Angle with respect to another frame omega - Angular velocity length - Scalar length from one frame to another com length - Center of mass position within frame mass - Total mass inertia - Moment of inertia mass center - coordinates of center of mass

    3.2 Body Model

    The objects written in BodyModel.py are used to build the model of thehuman body, with each segment linked together at the joints.

    The BodyModel class in bodymodel.py defines the actual physical modelof the body. BodyModel.py is comprised of objects from the BodyPart classwith physical values assigned to it. Each component within BodyModelcontains the common variables and functions for all the body parts used tocalculate movement.

    The following classes are created in BodyModel and constitute the vari-ables in the BodyParts class

    1. sole frame

    2. lower leg

    3. upper leg

    4. torso

    5. ankle

    6. knee

    7. hip

    1. body parts name contains lower leg, upper leg and torso

    2. body joints name contains ankle, knee and hip

    3. body part joints

    12

  • body part joints defines the three joints

    1. lower leg [ ankle & knee ]

    2. upper leg [ knee & hip ]

    3. torso [ hip ]

    3.3 Modeling the dynamics - BodyJumpForce.py

    The BodyJumpForce Object calculates the dynamics of the model. This pro-gram uses pre-derived calculations from the sympy library sympy.physics.mechanics.I used scipy.integrate to apply the KanesMethod algorithm to the BodyJump-Force Class.

    3.4 Graphical User Interface

    This module created a simple GUI I used to experiment with initial angles us-ing the wxpython library. The GUI was created using wxFormBuilder, whichcreated the UI files gui.py,gui.fbp, formpanelgui.py and formpanelgui.fbp.

    The mainwindow.py file contains the MainWindow class which rendersthe bodymodel in the wxpane and provides a routine for frame by framesimulation.

    This class is used by the startup script.The animation scene is rendered by using the playback.py file which im-

    plements the feature through the Playback(wx.EvtHandler) class.

    13

  • Figure 1: Vector jumping model

    14

  • Figure 2: Angular Velocity vs Time

    All images with the exception of Figure 1 and 2 are sourced from Refer-ence 1

    4 References

    1. Analysis of standing vertical jumps using a force platform. NicholasP. Linthornea School of Exercise and Sport Science, The University ofSydney, Sydney, New South Wales, Australia 8 May 2001

    2. Kanes Equations for Haptic Display of Multibody Systems, R. Brent

    15

  • Gillespie. Department of Mechanical Engineering, University of Michi-gan, Ann Arbor, MI

    3. Humanoid Vertical Jumping based on Force Feedback and InertialForces Optimization, Sophie Sakka and Kazuhito Yokoi. AIST/CNRSJoint Japanese-French Robotics Research Laboratory (JRL) IntelligentSystems Research Institute (ISRI), AIST Central 2, 1-1-1 Umezono,Tsukuba 305-8568, Japan [email protected]

    4. Amirouche, Farid M.L. Computational Methods in Multibody Dynam-ics. New Jersey: Prentice Hall, 1992.

    5. Anderson, Kurt S. Lecture Notes from Applied Multibody Dynamics.Rensselaer Polytechnic Institute 1998.

    6. Critchley, James H. Personal Interviews. February-May 1999.

    7. Critchley, James H. Personal Notes: Kanes Method Application. March1999.

    8. Huston, Ronald L. Multibody Dynamics. Boston: Butterworth-Heinemann,1990.

    9. Kane, Thomas R., and David A. Levinson. Dynamics: Theory andApplications. New York: McGraw-Hill, 1985.

    5 Acknowledgement

    Im sending out a special thanks to Daniel Berkowitz for alerting me to andsuggesting the use of symbolic languages, which vastly simplified the task ofcreating a multi-body computational physics model.

    16