The following is a real-time Java applet running a simulation of the simplified dynamics described in the previous section.
The applet is fairly self-explanatory. The coloured lines are the various links of the controller. Simply set the values of the torques that you wish on each pivot, plus the direction, and click the "Step that Monkey!" button to do a 4th order Runge-Kutta based step. The current values for both the angles and angular velocities are given below the diagram. The user can also adjust the length of the time step, the value of the dissipative constant, the linear density of the links and the acceleration due to gravity (negative is down). Note that changes to the length or the density will only be incorporated after a reset. Also, this applet has no error checking, so please enter numbers in the proper format.The default values in the applet are those that were later used in the simulation, and are reasonable magnitude in MKS units. The user is welcome to deviate from the defaults, but should be warned that these values are the ones that (by experience) give the best dynamics. Links to the applet code can be found at the bottom of the page.
This applet proved a very useful tool in determining appropriate values for the parameters. To begin with, we used with link lengths (in meters) of {0.3,0.3,0.3,0.2,0.2,0.1} which is fairly similar to the ratio of link length in an actual monkey's tail, an x-ray of which is shown below (from [5]). A density of 0.1 kg/m was used, which assumes links made of 1 cm radius aluminium bars.

Initially, all motors had the same torque of 1 kg rad/s^2. However, it was discovered that this value was appropriate only for the first few links, and completely overpowered for the later links. The motor torques were therefore scaled such that their ratio was equivalent to the ratio of the moment of inertial about that pivot for a straight tail, giving values of {1.0,0.5,0.2,0.05,0.01,0.0004}, which then gave qualitatively good results.To find an appropriate time step, relative error tests were performed. For all motors on in the same direction for 0.5 seconds, the difference between 0.05 second and 0.01 second time steps was less than 1%. Therefore, 0.05 second time steps are suggested.
The dissipative coefficient is a more difficult case. It turns out that we have a stiff system of differential equations, since the dynamics of the last link require a much shorter time step that those of the first link. This resulted in a situation were an appropriate dissipative constant for the first links would cause the last link to diverge and an appropriate dissipative constant for the last link would leave the first link unaffected. This problem might be solved by advancing each link with a different time step, though care must be taken with the coupling. However, in the interests of time, the somewhat hackish solution of multiplying the base dissipative constant by the moment of inertia for each link to get the link dissipative constant was used instead. While this gives good qualitative results, this is not strictly correct. That said, a base constant value of 2 is suggested.
Now that we have a tail, we want to find out how to get it into a variety of positions. That will be described in the next section, controllers.
Two files are necessary for this applet. The main code is in MonkeyApplet.java, while MonkeyCanvas.java does the drawing. The project file for Symantec Visual Cafe 3.01c is also provided.