Git Product home page Git Product logo

hexapod's Introduction

build status Code Climate technical debt codecov code style: prettier buy me coffee

Mithi's Bare-Minimum Hexapod Robot Simulator 2

drawing

You can use this web app to solve inverse kinematics, simulate various gaits, and more. In real time, you can also view all the angles the robot's eighteen joints make at any particular pose. All the computations are solely done in your browser, nothing's fetching data from somewhere else, so it should be fast. Another (somewhat) cool thing is that this app does NOT depend on any external mathematics library; it only uses Javascript's built-in Math object.

Consider buying me a few cups of coffee ☕ ☕ ☕ to motivate me to build other robotics-related visualizers. (Quadrotors?!)

Features

drawing

🎉 Control

  • The robot's dimensions
  • The robot's 3d orientation, translation, stance, and more

🎉 Solve

  • Inverse Kinematics
  • Forward Kinematics

🎉 Simulate

  • Ripple and tripod gait variations
  • Walking forward and backwards
  • Rotating clockwise and counterclockwise

🤖 🐳

Related Things

If you'd like to build your own user interface with Node, you can download the algorithm alone as a package: Hexapod Kinematics Library. There is also a "fork" modified where you can use the app to control a physical hexapod robot as you can see in the gif below.

Walking Gaits Kinematics

Main Contributors PRs welcome!

Any contribution to improve the source code is always appreciated. See contributing Guide. I will put your name below if I've merged your PR multiple times or if you've substantially contributed to this project in other ways.

I love badges! (Don't we all?)

License code climate issues last commit commits per month top language code files size repo size code base blanks count code base line count number of files count number of comments line in code base lines of code HitCount

hexapod's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hexapod's Issues

Improve code coverage

Add more tests for inverse kinematics edge cases

Add google analytics

Remove cloneRotXYZ and replace accompanying tests with cloneTrot since this won't be used anymore

The best practice i've discovered is to compute the transformation matrix outside and pass it
to the hexagon. This is because usually we use the same transformation matrix not only to the hexagon but other things like legs or coordinate frames (axes). So we'll just compute the transformation matrix only once for all the objects that need it. This is why we don't need these kinds of abstractions anymore.

cloneRotXYZshift(thetaX, thetaY, thetaZ, tx, ty, tz) {

Default camera view being overridden on page load

When you look at the app state, on load, latestCameraView is undefined even though we explicitly define it . Why?

Also when we move from one page to another it does not remember this default state, if we don't change the camera view on page load, (ie we intend to use the default camera view). What happens is it moves to a camera view that we don't intend (probably plotly's default camera view)

however, when we do change it (ie we explicitly play with the camera view), the app state does remember this camera view.

latestCameraView: CAMERA_VIEW,

This is not the behavior we intend. We need to fix it.

Namespace properties of LinkageIKSolver

https://github.com/mithi/hexapod/blob/master/src/hexapod/solvers/LinkageIKSolver.js

From:

class LinkageIKSolver {
    legXaxis = new Vector(1, 0, 0, "legXaxis")
    bodyContactPoint = new Vector(0, 0, 0, "localBodyContact")
    coxia
    femur
    tibia
    summa
    rho
    p1
    targetFootTipPoint
    parsVector
    pars
    beta
    gamma
    obtainedSolution
    reachedTarget
    message```

To:

class LinkageIKSolver {
    legXaxis = new Vector(1, 0, 0, "legXaxis")
    dimensions = { coxia: null, femur: null, tibia: null, summa: null, pars: null }
    points = {
        bodyContactPoint: zeroVec("bodyContactPoint"),
        coxiaPoint: zeroVec("coxiaPoint"),
        femurPoint: zeroVec("femurPoint"),
        footTipPoint: zeroVec("actualFootTipPoint"),
        targetFootTipPoint: zeroVec("targetFootTipPoint"),
    }
    angles = { alpha: null, beta: null, gamma: null, rho: null }
    vectors = {
        legXaxis: new Vector(1, 0, 0, "legXaxis"),
        parsVector: null
    }
    additionalInfo = {
        obtainedSolution: false,
        reachedTarget: false,
        message: "",
    }

Optimize: Reduce Bundle Size Further

Using only a partial bundle of Plotly reduced the bundle size by 50%.
Right now, Plotly still occupies 75% of the bundle.
#54

Other things that we can try:

  • Remove MathJS as dependency and just write all the matrix multiplications from scratch
  • Remove ReactMarkdown and just write them in html
  • Figure out if react-icons is taking up more space than it should
  • Check if it's a good idea to use preact and eject

Related Links

Eject

Preact

Codesplitting

Importing only one icon from react-icon

Sanity checks of parameters?

const solveInverseKinematics = (
dimensions,
rawIKparams,
flags = { rotateThenShift: true }
) => {
const { tVec, rotMatrix, startPose } = convertIKparams(dimensions, rawIKparams)
const startHexapod = new VirtualHexapod(dimensions, startPose)

Add check.

that tx, ty, tz are between -1 and 1,
rx, ry, rz, hipStance and legStance are within what is specified in

https://github.com/mithi/hexapod/blob/master/src/components/vars.js

We can return null (early exit) or throw and error

Make offline first progressive web app

It should work on all modern web browsers (including mobile web browsers like iOS safari)

Your app will work regardless of network state, even if offline. This means your users will be able to use your app at 10,000 feet and on the subway.

Readings

Optimization: Remove unnecessary computation when cloning

Hexagon cloning function

    cloneTrotShift(frame, tx = 0, ty = 0, tz = 0) {
        let clone = new Hexagon(this.dimensions, {hasNoPoints: false } )
        clone.cog = this.cog.cloneTrotShift(frame, tx, ty, tz)
        clone.head = this.head.cloneTrotShift(frame, tx, ty, tz)
        clone.verticesList = this.verticesList.map(point =>
            point.cloneTrotShift(frame, tx, ty, tz)
        )
        return clone
    }

New Hexagon constructor to remove computation

    constructor(dimensions, flags = { hasNoPoints: false } ) {
        this.dimensions = dimensions
        if (hasNoPoints) { return }

        const { front, middle, side } = this.dimensions
        const vertexX = [middle, front, -front, -middle, -front, front]
        const vertexY = [0, side, side, 0, -side, -side]

        this.verticesList = POSITION_LIST.map(
            (position, i) =>
                new Vector(vertexX[i], vertexY[i], 0, `${position}Vertex`, i)
        )
        this.head = new Vector(0, side, 0, "headPoint", 7)
        this.cog = new Vector(0, 0, 0, "centerOfGravityPoint", 6)
    }

Rename functions to use new conventions


leg.CloneTrotShift(leg, frame, tx, ty, tz)
pointCloneTrotShift(leg, frame, tx, ty, tz)
pointNewTrotShift(point, frame, tx, ty, tz)
hexagonCloneTrotShift(hexagon, frame, tx, ty, tz)
pointCloneShift(point, tx, ty, tz)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.