Dynamic Model of a

Horse Gallop in 2D

Eddy Boxerman

 

Introduction
        Motivation and Related Work
Materials
        Model
        Dimensions and Inertial Properties of Model
        Gait Poses
Methods
        Simulation Parameters
        Pose Control
        Search Algorithm
Results
        Analysis
Conclusion and Future Work
Acknowledgements
References
 

Introduction

I did this project for Michiel van de Panne's animation course at UBC in the term of Winter 2002.

The goal of the project was to model the dynamics (forces, torques) of a horse gallop on computer, and to determine a stable control strategy for a sustained gallop. The scope of the simulation was restricted to 2D, although in principle the method expands naturally to 3D.

An animation is worth a thousand words. The following two animations demonstrate the results of the project.

animation of stable gallop
animation of horse wiping out
A few cycles of a stable gallop
A gallop becoming unstable

Note: although all renderings are of simple skeleton models, more complex inertial body properties were used in the simulation.

 

Motivation and Related Work

Much can be learned from studying the graceful motion of animals. The topic of animal motion control touches upon such disciplines as control theory, biomechanics, robotics, artificial intelligence, and computer animation. A good overview of the problem, from a computer science perspective, can be found in [6].

Traditionally, computer animation relies on techniques such as key framing and motion capture. However, the former can be tedious and time consuming while the latter is difficult to generalize to differing models, motions and environments. Dynamic simulation has the potential to produce realistic animations in a more automated fashion.

Dynamic simulations of animals gaits (including horses) such as walking and trotting have been done [7]. In fact, as an intermediate step in this project, I simulated a horse trot. However, the trot is a simpler (symmetric along the sagittal plane) and more stable gait than the gallop. To the best of my knowledge, a dynamic simulation of a horse gallop had not yet been accomplished.

 

Materials

This section describes the data and tools used for the simulation.

 

Model

The horse was modeled using a 2D articulated figure.

Visualization of horse model used in simulation
(segment numbers identified in table below)

Muscle actions are simply modeled as joint torques over time. Model dimensions, inertial properties, and target motion data were gathered from various sources. The model was then simulated on computer in an attempt to achieve a stable control strategy for a sustained gallop.

 

Dimensions and Inertial Properties of Model

Inertial properties of the various body segments were extracted from [1]. Slight modifications were made to conform to the model being used. The following table contains the inertial parameters that were used in the simulations.

Body Segment
Segment Number
Length (m)
Mass (kg)
Center of Gravity (m)
Moment of Inertia (kg*m^2)
Trunk
1
1.160
347
0
64
Neck
2
0.540
26.8
0.248
0.94
Head
3
0.302
23.1
0.082
0.71
Shoulder (x 2)
4
0.440
20.1
0.176
0.74
Ante brachium (x 2)
5
0.434
6.70
0.152
0.129
Metacarpus (x 2)
6
0.287
1.59
0.126
0.015
Digit forelimb (x 2)
7
0.130
1.83
0.120
0.009
Thigh (x 2)
8
0.460
23.6
0.230
0.44
Crus (x 2)
9
0.434
8.30
0.164
0.145
Metatarsus (x 2)
10
0.353
2.84
0.113
0.050
Digit hind limb (x 2)
11
0.135
1.87
0.124
0.010

Note: Center of gravity is the distance of a segment's COG (along its axis) as measured from its parent link. The Trunk segment's COG is directly at its midpoint.

 

Gait Poses

The first successful sequential photographs of rapidly moving objects were taken by Muybridge [2]. A main focus of his work was horse gaits. A twelve frame sequence of a horse gallop (Plate 67) was used to define the target poses of the simulation.

A horse gallop stride in 12 phases (taken from [2])

Body segment lengths and joint angles were extracted directly from the photographs with a trusty ruler and protractor. While this does not yield precise values, it suffices for this purpose. In fact, since a reasonably stable gallop was produced, it demonstrates the technique's power to overcome relatively poor initial data.

The following animation displays a rendering of the extracted data. Note that this is not the result of a physical simulation, but merely a projection of the poses against a ground plane (notice how the torso remains perfectly horizontal).

Visualization of pose data extracted from [2]

The measured joint angles can also be found in the following (tab delimited text) file.

 

Dynamics Simulator

To simulate the system dynamics, I employed Michiel van de Panne's 2D dynamics simulator. First a "dynamics compiler" - given a description of a 2D articulated figure - produces a symbolic description of the equations of motion in the form of a 'C' procedure. The procedure is then linked with a dynamics engine which, when executed, calculates the system state (forces, torques, rectilinear and angular positions and velocities) over time. The engine simulates ground reaction forces using a penalty based method.

For the purposes of this project, I expanded the simulator to accept additional simulation parameters such as: target poses for the articulated figure, joint stiffnesses, etc. For the purposes of running test suites as well as monitoring and organizing results, I wrote several perl scripts. I also wrote a C++/OpenGL utility for rendering and capturing the animations.

 

Methods

In the context of this project, modeling a stable gallop consists of finding the correct combination of parameters for the simulation. The problem then becomes one of searching for a solution in some high dimensional space. To this end many simulations were executed with varying parameters, guided by an optimization scheme and rejection criteria.

 

Simulation Parameters

The following parameters are used in the horse simulation. The Min and Max columns identify the ranges of values that are legal (may be attempted) for each parameter.

Parameter
Number of occurrences
Min
Max
Description
Segment Length
11
Used values as given above

Length of a segment (in meters) in the articulated figure (although there are 19 segments, symmetry reduces the number to 11)

Segment Mass
11
Used values as given above
Mass of a segment (in kg) in the articulated figure
Segment COG
11
Used values as given above
Center of gravity of a segment (in meters) in the articulated figure
Segment Moment of Inertia
11
Used values as given above
Moment of inertia of a segment (in kg*m^2) in the articulated figure
Segment Joint Angle
216
+/-0.5 from targets in pose file
Target angle (in radians) of a given segment for a given pose (12 poses * 18 controlled joints = 216 parameters)
Initial Joint Positions
0
n/a
The horse's pose at the beginning of the simulation. This is set to the angles as defined by the first pose in the cycle.
Initial Joint Velocities
18
Fixed at 0
The horse's angular joint velocities at the beginning of the simulation.
Joint KS
10
1000
25000
Spring control constant (muscle stiffness, in N/m) of each joint (although there are 18 joints, symmetry reduces the number to 10)
Joint KD
10
1
30
Damping control constant (friction, in N*s/m) of each joint
Ground KS
1
1000
50000
Spring constant (in N/m) used for figure-ground interactions
Ground KD
1
500
5000
Damping constant (in N*s/m) used for figure-ground interactions
DTpose
1
0.01
0.500
Target time increment (in seconds) between poses
DTsim
1
FIxed at 0.0002
Time step (in seconds) of simulation
Initial Velocity
1
5
15
Horizontal velocity (in m/s) of horse torso (midpoint) at start of simulation
Initial Height
1
1.0
1.6
Vertical position (in meters) of horse torso (midpoint) at start of simulation
Initial Torso Angle
1
-0.2
0
Angle (in radians) of horse torso (wrt horizontal) at start of simulation
Simulation Time
1
2
n/a
Time (in seconds) for which to run simulation (in simulation time, not real time). As more stable gaits are produced, higher values are attempted. A perfectly stable gait would run forever.
Joint Limit
1
Fixed at 2.0
Maximum value (in radians) by which a joint's current angle can deviate from its target angle. If this value is exceeded by any joint at any time, the current simulation trial is rejected.
Torso Limits
1
Fixed at 1.0
If the absolute value of the horse torso's angle (in radians wrt horizontal) exceeds this value at any time, the current simulation trial is rejected.
COG Limits
2

Fixed at min = 0.8 and max = 1.8

If the vertical position (in meters) of the horse's COG (torso midpoint) exceeds these boundaries at any time, the current simulation trial is rejected.
Joint Velocity Limit
1
1000
Maximum absolute angular velocity permissible for a joint (in radians/s). If this value is exceeded by any joint at any time, the current simulation trial is rejected. This is to trap numerical instabilities.

 

This gives a total of 311 parameters, a high dimensional space to search. In order to reduce this number, I made the following assumptions and adjustments:

  • Segment lengths, masses, COGs and moments of inertia are, as stated above, held fixed to the values extracted from sources. This seems reasonable since there probably exists a horse (somewhere) which has those exact properties and which can gallop. What remains is to determine the other parameters for that horse's specific gallop. This reduces the number of parameters by 44. Moreover, whenever these properties are changed, the system must recompile the dynamics procedures for the horse model; avoiding this compilation phase decreases the time required to run each simulation.
  • Initial Joint Velocities are all set to 0, reducing the number of parameters by 18. This was an initial assumption that was never revisited over the course of the project. In retrospect, maybe this should be changed.
  • For the initial search phase, all Joint KS and Joint KD values are held equal. Although each joint will have its own muscle properties, the initial goal is to simply find the correct order of magnitude for these parameters - and making them all equal is sufficient to accomplish this. This reduces the number of parameters by 18 for the initial phases of the search.
  • For the initial search phase, the Segment Joint Angle deviation (+/-0.5 radians) is set to zero. This holds the poses fixed to the measured values. This reduces the number of parameters by 216 for the initial phases of the search. How can this reduction be justified? Essentially, ballpark figures for the joint angles are already known, whereas values for other parameters such as DTpose and Ground KS are not. Holding the "known" values fixed while searching for some ballpark values for the "unknown" parameters seems reasonable - and in practice worked well.

Thus for the initial phases of the search, the number of parameters in the search space is reduced to 15. In addition, some of these values have limited ranges (or are held fixed). This greatly reduces the size of the search space. Eventually, the number of parameters is increased to 249.

Another question is how to choose the Min and Max values for each parameter. This was done by spending some time (under an hour) experimenting and witnessing what values were clearly unreasonable. For instance, choosing a DTpose value of 0.01 caused the horse model to flail manically; and a value of 0.5 allowed the horse to fall before it barely moved. To be safe, the ranges chosen were even larger than what seemed reasonable after experimentation. Automating this process may not be entirely possible, since some minimum and maximum (or mean and standard deviation) values must always be chosen for the ranges.

 

Pose Control

How are the measured poses (joint angles) used to achieve the gallop motion? Essentially, the poses are used as control targets for the joint angles of the articulated figure at any given point in time.

The 12 poses of the gait are cyclical in nature and the poses are separated by a time interval defined by DTpose. At time = 0, the target angles are exactly those defined by pose 1; at time = DTpose, the angles are defined by the values at pose 2; and so on. When in between two poses (at time = 0.3 * DTpose for instance), linear interpolation between the two poses is done to calculate the target angles.

Once the target joint angles are known for the current simulation time, basic PD control is used to "force" the horse model through the desired configurations. For a given time step in the simulation:

Control Torque = KS * (joint_target - joint_position) + KD * joint_velocity

Spring and damping constants for each joint are defined by the Joint KS and Joint KD parameters. Shortest paths are always used between target and current joint positions (so for example 1.9*PI and 0.1*PI are only 0.2*PI radians apart). Also, since target joint velocities are not known, the damping component of the control serves merely to dampen the system; this is needed for stability. Note that although this is considered closed-loop control from a robotics perspective, in this context (animation) we refer to it as open-loop control. Here the distinction is that, although the horse model "knows" and reacts to its current internal state (joint angles, etc.), it uses no information about its environment. For example, the horse continues to cycle through its gallop motions even if it falls on its back in the simulation - thus it is not closed-loop.

 

Search Algorithm

The search algorithm used is similar in nature to that found in [6] with a few adaptations to the problem at hand. It begins with a global search of the parameter space, followed by local searches of promising regions that were discovered by the global search. It is arguably related to such algorithms as simulated annealing and greedy optimization. The pseudo code is as follows:

  • Simulation Time <- 2.0 seconds
  • Randomly generate parameters (use full ranges) and evaluate via simulation for 1000 sets.For any simulation that is not rejected, add that set of parameters to the successful trial database
  • Perturbation Factor <- 0.3
  • Repeat until trials converge (or you're fed up waiting)
    • For each of the 10 best trials
      • Perturb the parameter set of the given trial and evaluate via simulation. If it is not rejected and the optimization metric is higher than the original's, update the parameter set and continue searching.
    • Simulation Time = Simulation Time * 1.5
    • Perturbation Factor = Perturbation Factor / 3
  • Output best parameter sets

A few terms and details require explanation:

  • Rejected Simulation: this refers to any simulation in which the horse model violates a rejection criteria. These are defined by the Joint Limit, Torso Limit, COG Limit and Joint Velocity Limit parameters defined above. For instance, if the model violates the Torso (angle) limit, it is probably about to flip over - definitely an unsuccessful gallop. More subtle is the Joint Limit criteria: if at any time any joint deviates from its target angle by more than a threshold value, the gait is rejected. Before implementing this restriction, I observed some interesting and successful (relatively fast) gaits, but they did not resemble a horse gallop! By adding this restriction, only gaits that are similar to the gallop are accepted.
  • Perturbation Factor: This value controls the percentage of the Min / Max range that is explored through randomization. For instance, when Perturbation Factor = 0.05, the perturbed parameters will only deviate from the current set's by up to 5% of the ranges as defined in the parameter table. It is initialized to 0.3 once the algorithm begins its local searches. As more and more successful parameter sets are found, this value decreases, shrinking the perturbation ranges and refining the local search.
  • Simulation Time: Finding a long-term stable gait is a delicate matter [5]. It is much easier to find one that is stable for a short period of time. Hence, the algorithm begins its global search for gaits that are stable for at least 2 seconds. At each stage of the search, the Simulation Time is increased to ensure that the gaits become stable for longer periods of time - ideally forever.
  • Optimization Metric: the criteria used to judge a (non-rejected) parameter set is simply distance traveled. This was chosen over velocity so that parameter sets that were run for different Simulation Times can be compared against one another; ie. when comparing a fast but unstable gait to a slower but longer-term stable gait, the more stable gait should be chosen.

 

Results

Overall, the results obtained from the approach described were good. Some animations are provided.

Over several runs of the search algorithm, the most successful gallop found was stable for 22.77 seconds of simulation time, or for approximately 86 gait cycles. The parameter set for this simulation can be found in the following file. For convenience, some interesting values are presented in the following table:

Parameter
Value
Simulation Time
22.77 seconds
Distance Traveled.
418.45 meters
DTpose
0.022 seconds
Initial Horizontal Velocity
15.939 m/s
Avg. Joint Stiffness
~8000 N/m
Ground Stiffness
21950 N/m

In general, production of stable gaits lasting up to 10 seconds was quite common. No indefinitely stable gait was found. The question remains open as to whether an indefinitely stable, open-loop gallop exists.

As for simulation performance, it runs in approximately real-time. ie. it requires about 10 seconds to execute a simulation that models 10 seconds of simulation time. Typically, gaits that were stable for 2-3 seconds could be found within a few minutes of searching; and gaits that were stable for 10 seconds required about 1-2 hours of searching.

 

Analysis

Encouragingly, various properties of the simulated gallop that were not explicitly controlled were found to conform quite closely with a real gallop:

  • Frame Rate: the most stable simulated gait's DTpose parameter (time between poses) was 0.022. Muybridge gives a measured frame rate of 0.22 seconds/frame. These values are identical!
  • Gallop Velocity: the most stable simulated gait covered 418.45 meters in 22.77 seconds, or galloped at an average velocity of 18.38 m/s. Muybridge cites the gallop to cover thirteen and three-quarter inches per frame, where the inter-frame time is 0.022 seconds. This gives a velocity of 15.88 m/s. These values differ by 16%.

An additional metric which would prove useful for analysis is foot-fall timing of the simulated gaits; which could provide quantitative evidence that the simulated gallop has the same phase characteristics as a real gallop. Unfortunately time did not permit this.

An aspect that should be reconsidered is that all initial angular joint velocities were set to zero for the simulations. However, the initial state of the system should in fact represent a point in the steady state of a horse galloping. In retrospect, appropriate initial velocity ranges should have been chosen and these parameters should have been randomized as well. While this would have increased the number of search parameters by 18, perhaps these too could have been postponed until later phases of the search (as the poses themselves were).

 

Conclusion and Future Work

The results of this project are encouraging and lay a solid foundation to work from. The technique in theory could be applied to any creature-gait combination that is symmetric in the sagittal plane. Other interesting animal subjects in Muybridge's book include baboons, gazelles, dogs, kangaroos and ostriches!

The technique applied here should generalize naturally to three dimensions. This entails more complicated simulation techniques and higher dimensional spaces, but the approach and algorithm should remain essentially the same.

As already mentioned, initial angular joint velocities should not be assumed to equal zero. This in itself may be causing the initially successful gaits not to converge to stable long-term gaits.

Currently, the optimization criteria used to judge the success of a gait - and to choose a parameter set to locally search - is based on distance traveled. Another alternative is to consider energy expenditure; or distance traveled. per energy expended. This may prove useful since it is generally accepted that animal gaits use energy efficiently.

Of course, closing the loop could provide an indefinitely stable gait. Various techniques that decouple or linearize the complexity of this problem can be found in [3] and [4]. The work here involves finding a few key simulation states to monitor and a few control parameters that could be adjusted "in-simulation" to compensate for the state divergence. A good candidate for states to monitor may be foot-fall timings, which could be compared to actual gallop timings. Indirect control over the timings may be achieved via modifying the model's compliance (Joint KS parameters) temporarily, or by adjusting the interpolation parameter accordingly (ie. if the target pose is in a post foot-fall condition, but the foot-fall in the simulation has not yet occurred, the interpolating parameter could be "slowed down" to wait for the foot-fall to occur).

Fleshing out of the skeleton-rendering would yield more attractive results of course.

 

Acknowledgments

I'd like to thank Michiel van de Panne for his help and suggestions during this project; as well as for allowing me to use his simulator.

 

References

[1] Buchner, H.H.F., Savelberg, H.H.C.M., Schamhardt, H.C. and Barneveld A. (1997) Inertial Properties of Dutch Warmblood Horses. JOURNAL OF BIOMECHANICS 30(6) pp 653-658

[2] Muybridge, E.J. (1887). Animal Locomotion.

[3] Laszlo, J. F., van de Panne, M., Fiume, E. (1996) Limit Cycle Control and its Application to the Animation of Balancing and Walking, SIGGRAPH 96 Conference Proceedings (ACM Computer Graphics), 155-162.

[4] Playter, R. (2000) Physics-based simulations of running using motion capture. SIGGRAPH 2000 Course Notes, Course #33

[5] van de Panne, M. Lamouret, A. (1995) Guided Optimization for Balanced Locomotion. Computer Animation and Simulation '95 -- Proceedings of the 6th Eurographics Workshop on Simulation and Animation, Springer Verlag. Maastricht, Netherlands, 165-177.

[6] van de Panne, M. (2000) Control for Simulated Human and Animal Motion. IFAC Annual Reviews in Control 2000, 24(1), Elsevier Science Ltd., 189-199.

[7] Villanova, J., Guinot, J-C., Neveu, P., Gasc, J-P. (2000) Quadrupedal Mammal Locomotion Dynamics 2D Model. Proceedings of the 2000 IEEE/RSJ International Conference on Intelligent Robots and Systems.