Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



27 Commits

Repository files navigation

Stewart Platform

NPM Package MIT license

Stewart Platforms are used for motion platforms with six dimensions of freedom. With this library you can simulate Stewart Platforms as well as use the calculated angles to drive a real platform.



The code can run headless, but to set up all parameters properly, a visualization of the platform can help a lot. To do so, we use p5.js and quaternion.js

<script src="p5.js"></script>
<script src="quaternion.js"></script>
<script src="stewart.js"></script>
var sketch = function(p) {

  p.setup = function() {
    p.createCanvas(600, 600, p.WEBGL);, -290.0, (p.height / 2.0) / Math.tan(Math.PI / 6),
            0.0, 0.0, 0.0,
            0.0, 1.0, 0.0);

    platform = new Stewart;
    platform.initHexagonal(/*{ options }*/);

  p.draw = function() {



    p.translate(50, -70, 200);
    p.rotateX(Math.PI / 2); // Work in correct X-Y-Z plane

    // Set correct position where to drive to
    platform.update([0, 0, 0], Quaternion.ONE);

    // Draw the updated platform

    // Send to servos
    // platform.getServoAngles();

new p5(sketch, 'canvas');


In the examples folder are use cases documented.


The default example can be controlled via key presses on letters from a-z on the keyboard. Not all letters have a function.


Here is a list:

  • q: Skewed square
  • w: wobble
  • e: eight
  • r: rotate
  • t: tilt
  • y: lissajous
  • m: mouse control
  • g: Gamepad control, using Gamepad Web API
  • b: Simulation of breath
  • h: Helical animation

SVG Plotter

SVG paths are parsed and used for motion commads. This way SVG images can be plotted with a Stewart platform by attaching a pen:



The hand tracking device LeapMotion can be read via JavaScript using the leapjs package. The example uses the LeapMotion to use the hand position and orienttion as input for the platform.


The platform visualization is meant to draw a platform in milimeter. When you work headless, the unit does not matter. The following options are available:


The length of the rod attached to the servo horn and the platform. Default=130


The length of the servo horn attached to the motor shaft and the rod. Default=50


The horn direction indicates if the servo horn is rotated to the left or to the right. 0=right, 1=left, Default=0


A valid range for the servo motors to rotate. A typical low-cost servo has 180° working space. The value is an array [minAngle, maxAngle]. Default=[-pi/2, pi/2]


A boolean if the servo range should be visible in the drawing. Default=false

baseRadius + baseRadiusOuter

When a hexagonal stewart platform is used, the baseRadiusOuter is used to draw the base plate in accordance to the description.

platformRadius + platformRadiusOuter

When a hexagonal stewart platform is used, the platformRadiusOuter is used to draw the platform plate in accordance to the description.

shaftDistance + ankerDistance

For a circular platform this indicates the radial distance of pairs of rod ankers between the shafts on the base plate and the platform plate. For hexagonal platforms this indicates the distance from the middle of a side to attach the rod ankers. Default=20


A boolean for hexagonal platforms to indicate if the platform shall look into the same direction as the base plate. Default=true


Installing Stewart is as easy as cloning this repo or use one of the following command:

npm install stewart

Copyright and licensing

Copyright (c) 2023, Robert Eisele Licensed under the MIT license.