PDA

View Full Version : Walking with physics



galok
22-12-2015, 02:28 PM
I wanna make an algorithm that use physics for walking in 2D. Like in Euphoria engine (Rockstar) or like in this video:
https://www.youtube.com/watch?v=tb-t4j9wt7E
I think i should manage revolute or hinge joint velocity, but i haven't precise idea how it should be done. I think maybe you can point me at code or a book or anything else, so practically any related information would be very helpful.

galok
24-12-2015, 05:29 AM
first serious progress, i found research with source code:
https://www.cs.ubc.ca/~van/papers/Simbicon.htm

Ñuño Martínez
24-12-2015, 09:41 AM
Cool. If you find more stuff, please share it too. :)

galok
24-12-2015, 12:39 PM
well, first of all i compile it and i must admit it was very easy with VS 2008 Express Edition (as was said in README), but README was telling the truth and it's very not user friendly, actually a first thing i found out - it's doesn't working and i found out an error that occurs - it's heap corruption, but if you start application from VS 2008 - heap corruption still occurs, but after this - app doesn't care about it. I dont know why this happening, but i must mention this to be precise.
And next step was found out that there is no controls to do something with rendered skeleton, after few minutes i figured out that there is a GUI but coordinates of it is out of my screen space, so i adjust it manually in "\src\AppGUI\init\setup.tcl" file. After this GUI is appear and i played an animation, learned how to throw obstacles and after more few minutes i figured out that there is no animation change menu. Animation can be changed only manually in "\src\AppGUI\init\input.conF" file by commenting and uncommenting loads, after this i read comment about 2D and i learned that there is no 2D, but instead there is a 3D biped with toes (?).



# Define the rigid bodies that will make up the character - this is the same as the normal bip3d, but has toes


so i posting a video and hope i could manage read their code and translate it to 2D environment. yeah...
i need to mention that there is comments everywhere, so they must be helpful, but when i run debug build with debugger - fps slows down to 5-7 and that is increase difficulty in understanding


https://www.youtube.com/watch?v=ZfONNg1e5Ts

galok
25-12-2015, 10:32 AM
i found 2D demo on java applet and i make a Delphi port of it (i'm using XE7), here is not so stable build and source, and frankly it's scary :).
instead of a physics engine they use something that no carbon-based life form could ever understand, but it seems that balancing and walking part is present in normal code

1387

galok
27-12-2015, 05:42 AM
first try to port it to box2d, this doesn't seem right

https://www.youtube.com/watch?v=1WXVYj_sGG0

Roland Chastain
27-12-2015, 07:23 PM
Hello! This isn't really what you asked for, but you may be interested in this FlashPascal demo:

http://flashpascal.execute.re/CubeMan3D.php

The source code is included in the examples shipped with the compiler (http://flashpascal.execute.re/).

galok
28-12-2015, 06:35 AM
Hello! This isn't really what you asked for, but you may be interested in this FlashPascal demo:

http://flashpascal.execute.re/CubeMan3D.php

The source code is included in the examples shipped with the compiler (http://flashpascal.execute.re/).
thank you, writing flash apps in pascal is truly remarkable and running example is really good

galok
28-12-2015, 07:46 AM
a torque is applied to knee joint in zero gravity (simbicon simulation)

https://www.youtube.com/watch?v=10F63sof8sg
how can i do this in box2d? as far i understand i shouldn't apply torque to bone, since it would be applied to center of mass, and it's not a joint motor, because he would rotate bones around joint center, so... i'm a little confused here

galok
28-12-2015, 01:07 PM
this is so close, i almost did it guys

https://www.youtube.com/watch?v=vSuJC5UtNko

SilverWarior
28-12-2015, 03:19 PM
this is so close, i almost did it guys

Nice work.
I tried making a walking simulation myself some time ago but failed miserably :-) Main problem was that I really lacked even basic knowledge on how humans do balance themselves. If I would have tried that today I would definitely have better chances of succeeding.

galok
28-12-2015, 04:09 PM
i guess this is relatively stable.
here is source (Delphi XE7) and build: 1388

https://www.youtube.com/watch?v=3ajCxSgRn1I

Nice work.
I tried making a walking simulation myself some time ago but failed miserably :-) Main problem was that I really lacked even basic knowledge on how humans do balance themselves. If I would have tried that today I would definitely have better chances of succeeding.
Thank you, it wasn't easy for me either, you can look at my source if you want

SilverWarior
28-12-2015, 10:02 PM
Thank you, it wasn't easy for me either, you can look at my source if you want

Maybe some other time. I already have to many unfinished projects of mine. :(

galok
29-12-2015, 06:59 PM
i'm tried as hard as i can translate simulation parameters to box2d, i translated object sizes, mass, inertia and positions of joints, after this i created fixed step loop procedure (200 iterations with Dt = 0.00005) and run simulations in zero gravity to step 33, but results is still far from good, i think i'm mistaken somewhere...
http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1390&stc=1http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1391&stc=1
and values of variables are different
(torque hash, root velocity, relative angles)



Simbicon:
--- 33 ---


384,45


0,47 -0,09


-1,80
-0,23
-0,70
-0,01
-30,86
1,43
-0,01

Box2D:
--- 33 ---


287,05


0,40 -0,07


-1,48
0,10
0,79
0,46
-31,42
14,11
9,78

SilverWarior
29-12-2015, 07:58 PM
The cause might be in different floating point precision between your and original program.

galok
29-12-2015, 09:33 PM
The cause might be in different floating point precision between your and original program.
I tried to do less iteration in order to decrease precision error, 20 iterations with 0.0005 Dt give same results. simbicon use single precision float for calculations. i'm not sure, but it seems box2D use single precision float as well.

i tweak simbicon a little and the only way i got something that looks like what i've seen in box2d is when i manually decrease left shin torque by 10 times, don't know what this mean

http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1392&stc=1

galok
29-12-2015, 11:54 PM
oops, i found out a problem, angular velocity should be also relative to parent angular velocity, this doesn't seemed obvious to me... now it works perfectly




Simbicon:
--- 106 ---


37969,48


0,08 0,00


-2,49


34,48
-89,00
12,03


-60,76
-18,80
14,67




box2D:
--- 106 ---


37983,68


0,08 0,00


-2,47


34,48
-88,98
12,01


-60,60
-18,82
14,64

galok
30-12-2015, 07:53 AM
:)

https://www.youtube.com/watch?v=UbCusvnwhhY
1393

galok
30-12-2015, 12:07 PM
scaling code is correct now
1394

Ñuño Martínez
31-12-2015, 10:30 AM
:)

https://www.youtube.com/watch?v=UbCusvnwhhY
1393

Really impressive, but hilarious too. :D

SilverWarior
31-12-2015, 12:33 PM
Really impressive, but hilarious too. :D

If you think this is hilarious then I strongly suggest you check game named Sumotori Dreams (http://www.gravitysensation.com/sumotori/) which is implementation of similar algorithm in a Sumo Wrestling game.

galok
03-01-2016, 01:37 PM
now i'm reading cartwheel-3d sources, as far as I understand this is latest project of that research group
https://code.google.com/p/cartwheel-3d/

galok
21-01-2016, 06:32 PM
not sure if this is a completely correct conversion of cartwheel sources, but at least it's a starting point

https://www.youtube.com/watch?v=xGNhTI-u878
1396

phibermon
21-01-2016, 07:39 PM
Awesome stuff man! - it's a complex topic and there's no 'right' way as such - if it looks and feels good - be happy :) I have an implementation of a similar, perhaps older method in my engine but it's not robust yet, still gives some odd results now and then - I've also done work on an implicit skinning implementation (https://vimeo.com/105364564) that would go hand in hand with this for some truly next-gen character animation! but it's just for research - DQ/LBS for now.

The euphoria engine produces similar results to this but from what I understand it works in a very different way - that's a trained neural network with full contact support - no 'fix-ups' are needed - the animations from the network don't produce intersecting results as in euphoria there would be collision and the character would trip and likely fall.

However euphoria requires training for a given body - it can't 'learn' from existing animation cycles as such - they can be used to train the network, provide joint forces etc so the network can become better by using them as an input but euphoria isn't aware of them - it doesn't know what 'feet' are - a Euphoria training session without user guidence might produce a character that tried to break its fall by throwing its head as quickly as possible at the ground - the cool effects in Euphoria are emergent properties of a trained neural network and in fact without such a system you're aaaalways going to have odd behaviour now and then - but I think with proper joint constraints and some way of defining a point of failure - a time to go rag-doll - it'd be good enough for games :)

Alas we don't know have any code samples ;)

galok
22-01-2016, 11:13 AM
phibermon, Thank you. However, i will seek further for better robustness. Implicit skinning is very impressive, i would like to use it in my applications. Your knowledge in field of euphoria engine is most full of what I heard, can you share an information source?

phibermon
24-01-2016, 12:35 AM
What I've gleaned over the years - familiarity with exposed elements in script hooking - descriptions of function and a convo or two with a friend in the game industry that was reviewing such solutions - exact specifics elude me but I do know that their approach involves machine learning in order to give high quality results in complex 3D situations - be that in research, genetic algorithms or a functioning neural network. There's probably much in common between this solution and theirs - but their approach produces direct quality results - it doesn't need 'fix ups' - I think at least the one that shipped with GTA4 - there was some 'fixing' of feet but that was more slope and minor height adjustment.

I believe there's more to the transition between animation and physic aware rigs than just lerping in an animation manager - and different paths for special cases