How would I get these joints simulating correctly?

I’ve got a bunch of .stl files as parts of a suspension assembly. Here’s a photo:
The red circles show the joints. Technically, the leftmost joint at the apex of the arm is a ball joint but it’s mating joint is fixed in place. All of the joints are ball joints.

Here’s a video of how they move:

I’ve looked into using things like ammo.js or cannon but they simulate forces and not positions. I’d like to basically be able to do what solidworks is doing in that video when I click and drag the parts.

Ideally, I’d have a lookup table of all the angles of the parts based on the angle of one of the other parts. Therefore, a computationally heavy physics simulation doesn’t have to be done every time the links move. Any ideas?

You’re probably looking for Inverse or Forward Kinematics, and there’s a great list of resources in this answer from @ben: Does three.js supports FK (forward kinematics) and IK (Inverse kinematics)?

This will whet your appetite: https://github.com/notrueblood/FABRIK-for-threejs-and-beyond and this: https://jsantell.github.io/THREE.IK/

1 Like

Thanks @Aaa_Aaa
I’ve looked into these already and what my main problem is is getting my model set up with those.
My model requires three joints on one object which I’m not sure how to implement.

you can do verlet loop like they do in cloth simulation, just enter distance constraints and move the joints vertically - you will get your lookup table

Does this help?

I tried to build it using my new physics library (using ammo.js).

1 Like

Have you seen this?
RobotSimulation

see Collection of examples from discourse.threejs.org
https://hofk.de/main/discourse.threejs/2019/index2019.html

original post

Oh my god this is exactly what I need! Thank you @yannick ! You’re a god among men.

Is there a way to add an STL file in place of a physics.add ?
Also, I’d like to enter the angle of the top link (pole1) and have the rest of the components move to the correct place. The angle values will be coming in from a websocket stream so any value from -45 to 45 degrees can be encountered and not smoothly. So It can be -45 one timestep and 45 the next and everything in between.
Maybe I can use your simulation to get a list of angles of rotation for all of the components and use them as a lookup table instead? That way no simulation would be needed while it’s running.

I do not know .stl files. But there is an example how to add physics to a .gltf file.

I guess you could use btGeneric6DofConstraint (Degrees of freedom) for this instead of point to point. I have implemented it but without the configuration of the angles yet.

Maybe, but I do not know how to do it.

Hi @polishdude20,

It has been a while, but I finally made an example using many different constraints like Lock, Fixed, PointToPoint, Hinge, Slider, Spring, ConeTwist and 6DOF (Six degrees of freedom).

Hope you can use it :slight_smile:

2 Likes