npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rawify/mantis

v0.1.0

Published

Inverse kinematics for six-legged robots

Readme

Mantis.js

NPM Package MIT license

Mantis.js is a JavaScript library for the kinematics and motion control of six-legged robots. It combines analytic inverse kinematics, quaternion-based body orientation, world-space foot anchoring and phase-based gait generation in a compact model that can be used both for simulation and for driving a real hexapod.

The mathematical model is independent of p5.js. Rendering is optional and uses the same state that is available to headless applications.

Visualization

Mantis.js visualization

The included p5.js example is useful for tuning dimensions, stance, gait timing and controller behavior before transferring the resulting joint angles to hardware.

npm install
npm run build
npm run dev

Open http://localhost:8000/examples/default.html.

The visualization can be controlled with the arrow keys or a gamepad. A second example at examples/gaits.html shows the timing and lift profile of each leg independently.

Coordinate system

Mantis.js uses a robotics-style right-handed coordinate system:

X = forward
Y = left
Z = up

The p5.js renderer performs the graphics-space conversion internally, leaving the kinematic model in robot coordinates.

Inverse kinematics

Each leg is modeled as a three degree-of-freedom chain:

coxa -> femur -> tibia

legIK() accepts a target in the local coordinate frame of a leg and returns the three joint angles together with reachability information. For a complete robot, Mantis.js transforms world-space foot targets into body space and then into the corresponding leg frame before solving the same analytic IK for all six legs.

neutralReach is the horizontal neutral foot offset measured outward from the end of the coxa. It is a stance parameter, not the maximum geometric reach. The reachable workspace itself follows from the femur and tibia lengths. For a vertical distance h between the coxa plane and the ground, the maximum horizontal reach beyond the coxa is

sqrt((femur + tibia)^2 - h^2)

provided that the leg can fully extend to that height. A neutral stance should remain comfortably inside the workspace so that each leg retains room for gait motion in every direction.

Gaits

Mantis.js includes four phase-based gait presets:

  • Tripod
  • Tetrapod
  • Ripple
  • Wave

A duty factor divides each leg cycle into stance and swing. During stance, the foot remains anchored to the ground in world space. During swing, the foot advances to its next landing point along a smooth trajectory. Gait changes and transitions back to a neutral stance are blended rather than applied as discontinuous target jumps.

Installation

Install from npm:

npm install @rawify/mantis

ES modules

The primary package entry is a modern ES module. quaternion and @rawify/vector3 remain normal external dependencies and are not bundled into Mantis.js.

import Mantis, { WebGamepad, legIK } from "@rawify/mantis";

const mantis = new Mantis({
  leg: {
    coxa: 30,
    femur: 100,
    tibia: 150,
    neutralReach: 125,
  },
});

mantis.setBodyPose({
  height: 110,
  roll: 0,
  pitch: 0,
  yaw: 0,
});

mantis.update(0, {
  gait: "tripod",
  speed: 1,
  stride: 72,
  lift: 42,
  duty: 0.62,
  treadmill: true,
  dt: 1 / 60,
  drive: { forward: 1, turn: 0 },
});

const angles = mantis.getServoAngles();

getServoAngles() returns 18 logical joint angles in radians: coxa, femur and tibia for each of the six legs.

Browser build

A transpiled ES5 browser build is available as dist/mantis.min.js. It is generated from the same modern source as the ESM build, wrapped in an IIFE, and deliberately does not bundle Quaternion.js or Vector3.js. Load those libraries first so that the global identifiers Quaternion and Vector3 are available:

<script src="path/to/quaternion.min.js"></script>
<script src="path/to/vector3.min.js"></script>
<script src="path/to/mantis.min.js"></script>
<script>
  var mantis = new Mantis();
</script>

The browser build exposes the same convenience API on Mantis, including Mantis.Gamepad, Mantis.Gaits, Mantis.legIK() and Mantis.legJoints().

Body pose

The body pose can be specified through position plus roll, pitch and yaw, or by passing a Quaternion directly:

mantis.setBodyPose({
  position: [0, 0, 110],
  orientation: quaternion,
});

Internally, body-to-world and world-to-body transformations are quaternion rotations. No rotation matrix is required by the model.

Gamepad input

WebGamepad is a small adapter around the browser Gamepad API. The left stick produces normalized forward/turn commands and the right stick produces normalized roll/pitch commands:

const gamepad = new WebGamepad({ deadzone: 0.12 });
const input = gamepad.read();

The adapter is optional; headless users can provide their own drive and body-orientation commands directly.

Development

npm install
npm run build
npm test
npm run dev

npm run dev starts the local example server on port 8000. npm run verify runs tests, builds both distribution targets, validates the browser build and performs an npm package dry run.

Copyright and Licensing

Copyright (c) 2026 Robert Eisele

Licensed under the MIT license.