mithi / hexapod-irl

A "fork" of Bare-Minimum Hexapod Robot Simulator 2 modified to be able to control a real physical hexapod robot.
Apache License 2.0
72 stars 6 forks source link

Walking Gaits #4

Open nikita1323 opened 5 months ago

nikita1323 commented 5 months ago

Hello. I'm new to javascript, but i liked this project so much, that desided to build my own hexapod from scratch following your tutorial. Now I'm able to control hexy via pc remotely. But I have a question, is it possible to alter some code in a way, that can allow me to control robot by virtual joystick and make it go any direction i want. I mean, right now it's direction vector points from center of gravity ro the HEAD point, while i want to set this vector via joystick.

I really apreciate any help you can provide.

mithi commented 5 months ago

Hi @nikita1323,

Really cool! Would you mind sharing a video? If you can share the video, I can update the README with a section to showcase your video...

Anyway, to answer your question

if you check out the pages

You will see something like

const ikParams = {
    tx: 0,
    ty: 0,
    tz: 0,
    rx: 0,
    ry: 0,
    rz: 0,
    hipStance: 0,
    legStance: 0,
}

solveInverseKinematics(dimensions, ikParams)

and

const gaitParams = {
    tx: 0,
    tz: 0,
    rx: 0,
    ry: 0,
    legStance: 0,
    hipStance: 20,
    hipSwing: 25,
    liftSwing: 40,
    stepCount: 5,
}

getWalkSequence(dimensions, gaitParams, gaitType, walkMode)

You need to override the following values:


// for ik
ikParams.rx
ikParams.ry
ikParams.rz

// for gaits
gaitParams.rx
gaitParams.ry

You can derive these values given your normal vector provided by your virtual joystick (google search to find the formula)

Hope that helps!

nikita1323 commented 5 months ago

Oh, thank you so much for your help! Sure, I will share a video with you, I just need a few days to finish this project.