Development of self balancing biped with inverse Dynamics

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Development of self balancing biped with inverse Dynamic

Postby Julio Jerez » Sat Aug 21, 2021 10:40 am

Ok, I have very good and stable now.

The character can actually sustain its pose and tolerate movement.

Now I hit the next road block.
It turns out that making poses in code is far more challenging than I thought. I managed to make a walk and idle, but they are too robotic.

This need some kind of authoring tool to do it visually.
Then when adding to that that configuring the connection of the ragdoll is quite arbitrary. You can see in the demos that there are too many arbitrary magic numbers, joint types, joint limits, what part are joint, etc.
Hey even more simpler model lake a vehicle is becoming hard to follow.

All this scream a visual tool that let people try thier own stuff.

I can probably use a game engine, but I hate that option.
I have 3dsmax 2013, but that old and very few people have it.
So I think the only viable solutions are
Write my own, that's always a bad idea.
Or write an add on for blender.

So I start that process.
I am now doing the file format, which will be xml.
The see if I can write a python adon that I can use to export authored data from blender.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Development of self balancing biped with inverse Dynamic

Postby JoshKlint » Thu Aug 26, 2021 11:02 pm

Video, please. :D
JoshKlint
 
Posts: 163
Joined: Sun Dec 10, 2017 8:03 pm

Re: Development of self balancing biped with inverse Dynamic

Postby Julio Jerez » Fri Aug 27, 2021 3:48 pm

I made a detour to get an official file format going.
I realize that many people find navigating the demos to hard and that is something that does not really have a solution.
Physics is complex and expecting everything to be trivial and easy to set up, is in fact a fool errant.

I am hopping that a file format make this process more palatable for many users.
I also plan using this for an authoring tool, maybe Blender, but since I now have a file format, any data can be exported from Max using Max script or Blender Max.

As I said before, thing as trivial as a Ragdoll requires lots of configuration of joint parameter, bone structure and so on, and that is just too difficult for most people, hey even I get confused when I look at a demo after few weeks.

The file format is mostly in already, can export any of the SDK demos, anyone can simply take them a load it into any application.

after that, probably next week, I will resume the active ragdoll, Good thing are coming and them we make a youtube video.

mean time I suggest that you move to Newton 4.0,
you can probably make it an option, if you have your engine with set in such way that it has a physics abstract wrapper.

newton 4 fixes lots of the rough edges of Newton 3.xx

stuff like the dreadful edge jump, was fixed with a better algorithm, you can see the vehicle demos. the joints are far more stable, and have a more funtionality than before.
For example some joints can have limits and motor on the same axis, that was not possible with 3.xx
Other stuff like triggers, and player capsules are part of the core engine, and so on, lots of other improvements over 3.xx
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Development of self balancing biped with inverse Dynamic

Postby JoeJ » Wed Sep 01, 2021 4:55 am

While i do frequent downloads to follow your progress, i have not tried them yet... (Need for CMake to build project each time is a bit an obstacle)

This need some kind of authoring tool to do it visually.


Oh, yes.
I'm actually in the process of maintaining my old project, which has Newton testbed, ragdoll, and editor.
I was still depending on Havok to import my character data, but Havok is now outdated and i have to use VC2012 to compile it. So i'm already spending days to replace Havok. Unfortunately i used it's math library in a lot of places.

The complex character data really is an obstacle. I dream about some procedural generator, similar to character customization in RPG games. But until i have this, i still depend on that single skeleton and animation data i made 20 years ago :)

Using Blender sounds a good idea. I hate it, but it's free. Personally i had used Softimage XSI at work. It had such a character generator where you can setup proportions and then it generates skeleton and IK Rig ready to use. I'd hope Bender has at least some default skeleton.
But in the end, users will likely use their own DCC tools, so you only have to focus on making it easy for yourself.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Development of self balancing biped with inverse Dynamic

Postby Julio Jerez » Wed Sep 01, 2021 10:48 am

Oh, wow you do not like cmake?

I partially agree, I wish CMake less less macro driven,
Too many, and many are so obscured that they are hard to use.
The feature I hate the most is that it uses absolute path, and I do not really see a good reason why they did insist on that.

But on the other hand, CMake is very powerful, has a very large user base, and most importan of all, It allows for a great simplification of the build systems across different platforms.

I myself test 4.00 in three platforms, visual studio, ClangCL, and gcc under unbutu.
Plus few users had help testing with others like MingWG.
That was always a big pain in the arse when making make file for Linus, and ms solution.

I tried to make the cmake script 100% depended free,
Oone of the draw back I found annoying with cmake.
But all in all, the benefits of cmake far outweighs the drawbacks, in my opinion.

I already completed the file format, I even distribute two examples in the download, a ragdoll and a vehicle.
The file format supports exporting full scenes and selected models.
This second mode is very handy, because it makes a mini scene, with a model and all the dependencies, so it can be loaded in a application by just one function call.

On the authoring tool.
I already when over the painfull step of setting the Swig scrip to make an automatic python wrapper.
I test after thing already and seem to work.
The really cool thing is that by the magic of copy, paste and edit we can make wrappers for other script languages like charp, Lua, Java, Rugby and many others.
Swig supports more than a dozen targets.
So for example it would be eassy to go to Sketchup, or Unity.

Now my next step is to try using it blender.
You are right, last time I used blender I found it awkward been a 3dsmax person.
But I do not have a current version of max, I bought a copy in 2006 and they supported until max 2013.
But now they made it so expensive that it is not affordable for a hoviest project, beside very few people has access to max.
Last I heard Blender interface is very much max like now, plus it is also very popular among the target audience of newton.

So I will spend few days practicing blender navigation before I move to write the add on.

My idead is to be able to make an addon that let people to inteactive set up the asset.
Asign collision shapes, rigid body properties, make the model type, etc.
Them they be able to test it an tweak it in blender and finally export the model to the engine format.
Them they can export the graphic file, but that is already part of the blender.
Them this asset is ready to be used by any application.
At least that's the idea.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Development of self balancing biped with inverse Dynamic

Postby JoeJ » Thu Sep 02, 2021 5:09 am

Julio Jerez wrote:Oh, wow you do not like cmake?

No, i don't have any problem with it.
It's just i need to download / install CMake, then traverse to the proper directory, make my settings, generate project, traverse to the proper directory again from IDE, finally compile and run.
And those little extra steps are a bit annoying, so i end up with 'hmpf - i'll do that tomorrow...' :)

But no complaint. Probably there would be ways to make a bat file to automate those actions, or i could learn to use github better to just update the code but keep the project files.

You are right, last time I used blender I found it awkward been a 3dsmax person.

IMO it would be ok to use Max (in case you get frustrated). It's still the most widely used DCC tool, not sure if has Blender changed this.
But the point is: No matter what tool you pick, only a small group of users will be happy with that. The others have to write their conversation and import stuff anyway.
And at some point, if working on characters seriously, we need to work on our individual toolchain anyway. No way around that. Procedural extra bones, adaptive clothing, mixing animation, IK, etc...
There won't be a easy to use for all solution.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Development of self balancing biped with inverse Dynamic

Postby JoshKlint » Fri Sep 03, 2021 4:48 am

Julio Jerez wrote:mean time I suggest that you move to Newton 4.0,
you can probably make it an option, if you have your engine with set in such way that it has a physics abstract wrapper.

That might be possible. I'm at least three months away from releasing the new engine. Do you think Newton 4 is ready for commercial usage?
JoshKlint
 
Posts: 163
Joined: Sun Dec 10, 2017 8:03 pm

Re: Development of self balancing biped with inverse Dynamic

Postby Julio Jerez » Fri Sep 03, 2021 9:53 am

I am not making any guarantees.
you can download the SDK if you liek you use, if you do not, that's also fine.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Development of self balancing biped with inverse Dynamic

Postby MeltingPlastic » Sun Jan 16, 2022 1:45 pm

Are plans for Newton4 to have a way of calculating Inverse Dynamics on Any Body? (Or is it already in there?)

Mojoco looks like it has an api for getting inverse dynamics info:https://mujoco.readthedocs.io/en/latest/computation.html


So say an arbitrary jointed model is created (perhaps even with loops?). calculations like: "what force and torque would be needed to move a certain point on a certain body (in the jointed model) with the specified acceleration" could be asked at any timestep.

From what I understand - info is needed not only from standard joints but from the contacts as well. So doing the calculation on a body in a box stack would internally traverse all the contact joints.

Looks like Physx 4 (from the docs) has some of that as well but only for the "Articulation" joint structures and not the D6 joints.
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Development of self balancing biped with inverse Dynamic

Postby Julio Jerez » Sun Jan 16, 2022 3:58 pm

That has been a features of newton since it came out almost 18 years ago.

you can set a joint and place an effector anywhere within in the workspace of the effector, and the solver will move it there, them you can read the forces on each dof, along the trajectory. this works with or without loops.
We do not listed as a feature since we think s it should be a basic funtionality of any physics library.

inverse dynamics is just close loops. and if the app model them in a way that the do not have singular configurations, it just works.

Be wared that there is a lot of misinformation, about that specially coming from the self appointed experts.
They keep inventing brand new law of phyis to solve these problems, stuff like position based physics, Impulsive passes and position correction passes, mass and inertia scaling, shock waves, long distance constraint, and it goes and on.
Non of that stuff is physic that abide but the equation of rigid body mechanics, it provides fast demos, but send peoe in wild goose shase fir years, and never get result that can even resemble a realistic simulation.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Development of self balancing biped with inverse Dynamic

Postby MeltingPlastic » Sun Jan 16, 2022 5:12 pm

Ok, is that ndJointKinematicChain?

I see SetTargetGlobalMatrix(const ndMatrix& matrix);

I am assuming once that is set, that moves the body, as its handling stuff internally to move the body. And the force and torques can be read from the joint using
Code: Select all
ndVector GetForceBody0() const;
ndVector GetTorqueBody0() const;


How would one get the forces needed to create a specified linear and rotational acceleration?

EDIT: Is it?:
1. SetTargetGlobalMatrix to where the body would be under that linear and rotational acceleration.
2. GetForceBody0(), GetTorqueBody0()
3. SetTargetGlobalMatrix back to normal
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Development of self balancing biped with inverse Dynamic

Postby MeltingPlastic » Sun Jan 16, 2022 5:16 pm

EDIT: Is it?:
1. SetTargetGlobalMatrix to where the body would be in the future under the desired linear and rotational acceleration.
2. GetForceBody0(), GetTorqueBody0()
3. destroy the ndJointKinematicChain joint

Then you have the forces/torques that "would" be needed. Then you could add those forces on the outside if wanted.

Let me know if thats right
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Development of self balancing biped with inverse Dynamic

Postby Julio Jerez » Sun Jan 16, 2022 5:35 pm

So you want to know the force given an acceration.

A way to do it, is by looking ahead.

It would required exposing the joint Skeleton to the app.

If you look at, the engine core.

The is a data structure called ndSkeleton.

This represent a matrix factorization of a system compose of joints an contacts.

In the matrix, formulation, is in the form

InvMass * f = a

f0 < f < f1

f is a vector of the forces in the system.
a is a vector of the acceleration of each
Constraint row.

Invmass is the mass matrix.

Right now is set that, a is provided by the joint, and it calculate the f vector.

What you want, it to some how set the a vector, and in advance make a funtion call the gives you the f, vector
Without Changing the configuration.

Did I get that right?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Development of self balancing biped with inverse Dynamic

Postby Julio Jerez » Sun Jan 16, 2022 5:45 pm

You can't think of a simple body, it need to consider the full system.

The cool think about the Skelton, is that the factorization make so the the submarines that are disjoint appear as a block matrix.

Take for example three bodies joint by joints.

Imagine one joint is a hinge motor, the other is a slider.

If the hinge rotate, it after the other two, but if the slider move it only affect that body.

This information is in the mass matrix of the system.
And the factorization capitalize on that to solve it very fast.

So if for example yo have that mass matrix.

And you determine the force ot torque, you can actually use it to make decision. But in the end, you have to apply the same fir as friction limit, and that acceration, because if you change it. The the solution would be a different configuration.

Do you understand. What I am trying to say?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Development of self balancing biped with inverse Dynamic

Postby Julio Jerez » Sun Jan 16, 2022 5:55 pm

If this is what you mean,
The it is not that difficult to expose.

Now that we have the ndModel in 4.0
We can add a funtion that expose the Skeleton.

And there you can manipulate it because, you can get a immediate mode solver. That give the acceleration ot the forces, you can find the unknown, by calling he Skeleton solver, the you use thos values to set in the general solver.

It seems the ndModel is a natural way to expose that funtionality.
The robotic people would love it, I think. But I do no set my hopes high.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 43 guests