Sei sulla pagina 1di 17

Modeling a Squat Jump Using Symbolic

Python
Albert Ai
August 27, 2015

Contents
1 Introduction
1.1 Modeling a Human Jump . . .
1.2 Symbolic Python for Multibody
and Symbols . . . . . . . . . . .
1.3 Kinematics . . . . . . . . . . .
1.4 Building the body . . . . . . . .
1.5 Kanes Method . . . . . . . . .
1.6 Equation of Motion . . . . . . .
1.7 Impulse - Momentum Method .

. . . . . .
Systems
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .

. . . . . . . . . .
Reference Frames
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .

3
3

.
.
.
.
.
.

3
4
4
5
5
7

2 Programming and Implementation


10
2.1 Programming Details . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.1 Libraries Used . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.2 Details of Files and Functions . . . . . . . . . . . . . . 11
3 Programs and Functions
3.1 Body Part Object - BodyModel.py . . . . .
3.2 Body Model . . . . . . . . . . . . . . . . . .
3.3 Modeling the dynamics - BodyJumpForce.py
3.4 Graphical User Interface . . . . . . . . . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

11
11
12
13
13

4 References

15

5 Acknowledgement

16

Introduction

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

1.1

Modeling a Human Jump

A human vertical jump is divided into two phases. In the first phase, the
subject rotates its body into a standing position while retaining a certain
amount of upwards momentum, and in the second, uses the built up momentum to launch itself into the air. The second phase is simple and can be
modeled as upwards projectile motion with any method of linear approximation such as Eulers Method. However, the first phase is a lot more difficult
to the fact it has multiple simultaneous moving components involved.
In the first phase, there are three degrees of freedom to worry about a
rotation at the ankle, knee, and hip. For simplicitys sake, I have modeled the
system as three rotating rigid bodies and a static ankle as a fixed reference
frame, with three joints modeled as ideal torques between the adjacent body
parts. For each joint, the required torque will be determined according to
the starting position of the human body and the mass of the segments at the
starting points.

1.2

Symbolic Python for Multibody Systems Reference Frames and Symbols

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

1.3

Kinematics

Using the ReferenceFrame module in SymPy, I can define the orientation of


each frame relative to the other reference frames, along with an initial angular
velocity and acceleration. With the sympy.physics.mechanics library, I can
automatically calculate the linear and angular velocity of the center of mass
for each frame as it rotates.
I start by setting the orientation of the lower leg relative to the fixed ankle
frame. To do this, I first define a value for 1 , 2 , and 3 , the flexion angles of
the ankle, knee, and hip respectively. The built in ReferenceFrame.orient()
function makes orienting the frames to each other simple. The function
requires the following: input parameters of a fixed frame, initial rotation
angle, and a directional vector about which to rotate. For this simulation, Ive
chosen to start the movement by rotating the lower limb counter-clockwise
along the Z axis. The rotation matrices used for this are as follows:

cos(1 ) sin(1 ) 0
Lower leg.dcm = sin(1 ) cos(1 ) 0
0
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 rotate
clockwise.

cos(1 + 2 ) sin(1 + 2 ) 0
Upper leg.dcm = sin(1 + 2 ) cos(1 + 2 ) 0
0
0
1
Likewise, the rotation matrix of the torso can be defined with a similar
rotation matrix about the Z direction.

cos(1 + 2 + 3 ) sin(1 + 2 + 3 ) 0
Torso.dcm = sin(1 + 2 + 3 ) cos(1 + 2 + 3 ) 0
0
0
1

1.4

Building the body

With a method to set the orientation of the 3 limbs created, I need to define
the positions of the various joints and center of masses in their reference
frames. I will use the ankle as a fixed point for the system, such that all
other points in the system will be defined with respect to the ankle. The
knee joint K is then defined with respect to the ankle using a vector that
is 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 constant length for the lower leg and to define the point of the knee K and the
other 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 used
to express the returned vector with respect to another reference frame. Thus:
Vector of position of Knee in lower leg reference frame = Ll.iy
Vector 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 of
Hip 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 designed


for symbolic languages explicitly created to simplify and model multibody
systems Kanes method.
Kanes method as implemented in SymPy requires a set of generalized
speeds w1, w2, w3 such that the time derivative of these generalized speeds
are equal to their generalized coordinates. From there, the equations of
motion can be easily derived in first order form. First, I create the time
varying symbols in Python:

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

1.6

Equation of Motion

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

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 reference frame, coordinates, speeds, and kinematical differential equations:

[1 1, 2 2, 3 3]
kane = KanesMethod(inertial frame, coordinates, speeds, kinematical differential equations)
The equations of motion can now be computed using the kanes equations
function, which takes the list of loads and bodies and returns the equations
of 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 = ma
T = I
With a reliable way of calculating the forces and torques, I can choose
one of several methods to calculate the trajectory of the jump. The method
I chose to calculate the jump for this project was the Impulse-momentum
method, detailed extensively in reference 1

1.7

Impulse - Momentum Method

Countermovement jump impulse-momentum curve:

Squat jump impulse-momentum curve:

The integral of a force over time is equal to a change to the momentum


of a body,
J=

F dt = P

Applying this formula to the ground contact phase of the jump, starting
from when the jumper is stationary with v = 0 and t = 0 to the instant of
takeoff where a = 0 gives
R
J = (FGRF ) mg)dt = mvi
The impulse due to the resultant force on the jumper may be considered
as two separate impulse:
R t2
t1

FGRF dt

R t2
t1

mgdt = JGRF JBW = mvt0

These areas are shown in the figure below:

With the rotation angle and angular velocity of each segment updated
and summed using Kanes method, I have determined the inertia forces of
each segment at the end of the first phase of the movement. With these
values stored, I can use the trapezoidal rule with the trapz function to calculate the vertical velocity in the last second of stage one. At the moment of
takeoff, the ground reaction force is equal to 0, which means the jump will
be the result of throwing the body into the air with a specific velocity. The
maximum height then, is determined using the equation below, which was
calculated at the beginning of the project.
v2
Hmax = 2gt0

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. The
following is a full list of libraries used.
2.1.1

Libraries Used

wxPython http://www.wxpython.org/ Python bindings to the wxWindows GUI cross-platform toolkit. All GUI files were created using the
simple wxPython builder.
mpmath http://mpmath.org mpmath is a Python library that calculate
real and complex floating-point arithmetic with arbitrary precision
SymPy www.sympy.blogspot.in SymPy is a symbolic language library
in Python
PyDy www.pydy.org Multibody dynamics tool kit package
NumPy www.numpy.org NumPy is the fundamental package for numerical computing with Python
SciPy www.scipy.org Open Source Library of Scientific Tools

10

IPython www.ipython.org IPython is a command shell for interactive


computing and animation
matplotlib www.matplotlib.org matplotlib is a python 2D plotting library
Cython www.cython.org Cython is an optimising static compiler for
both the Python programming language and the extended Cython programming language (based on Pyrex
Theano www.deeplearning.net/software/theano/ Theano is a Python
library that allows you to define, optimize, and evaluate mathematical
expressions 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 BodyPart
object
2. bodyjumpforce.py - Builds physical properties to the BodyModel when
kinematic equations are calculated via Kanes Method
3. jumpsimcore.py - Integrates the functions together
4. transmat3.py - Function to impelement rotation matrices

Programs and Functions

3.1

Body Part Object - BodyModel.py

This is the basic building block of the simulator. A Body part is an object
which has the following properties. (Refer to the kinematics section for more
details)
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 the
human body, with each segment linked together at the joints.
The BodyModel class in bodymodel.py defines the actual physical model
of the body. BodyModel.py is comprised of objects from the BodyPart class
with physical values assigned to it. Each component within BodyModel
contains the common variables and functions for all the body parts used to
calculate movement.
The following classes are created in BodyModel and constitute the variables 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 program uses pre-derived calculations from the sympy library sympy.physics.mechanics.
I used scipy.integrate to apply the KanesMethod algorithm to the BodyJumpForce Class.

3.4

Graphical User Interface

This module created a simple GUI I used to experiment with initial angles using the wxpython library. The GUI was created using wxFormBuilder, which
created the UI files gui.py,gui.fbp, formpanelgui.py and formpanelgui.fbp.
The mainwindow.py file contains the MainWindow class which renders
the bodymodel in the wxpane and provides a routine for frame by frame
simulation.
This class is used by the startup script.
The animation scene is rendered by using the playback.py file which implements 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 Reference 1

References
1. Analysis of standing vertical jumps using a force platform. Nicholas
P. Linthornea School of Exercise and Sport Science, The University of
Sydney, 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 Michigan, Ann Arbor, MI


3. Humanoid Vertical Jumping based on Force Feedback and Inertial
Forces Optimization, Sophie Sakka and Kazuhito Yokoi. AIST/CNRS
Joint Japanese-French Robotics Research Laboratory (JRL) Intelligent
Systems Research Institute (ISRI), AIST Central 2, 1-1-1 Umezono,
Tsukuba 305-8568, Japan sophie.sakka@aist.go.jp
4. Amirouche, Farid M.L. Computational Methods in Multibody Dynamics. 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. March
1999.
8. Huston, Ronald L. Multibody Dynamics. Boston: Butterworth-Heinemann,
1990.
9. Kane, Thomas R., and David A. Levinson. Dynamics: Theory and
Applications. New York: McGraw-Hill, 1985.

Acknowledgement

Im sending out a special thanks to Daniel Berkowitz for alerting me to and


suggesting the use of symbolic languages, which vastly simplified the task of
creating a multi-body computational physics model.

16

Potrebbero piacerti anche