Move joint for specfied time

General discussion about Box2D tutorials
Post Reply
blakey87
Posts: 28
Joined: Wed Jan 09, 2013 7:57 pm

Move joint for specfied time

Post by blakey87 »

Is there formula or technique I can use for moving a joint for specified number of world steps.

So basically If I had an elbow type joint, how would I open the elbow ,a certain amount degress each step, until it reaches the desired position based on on number of steps specified.

I hope to achieve this using motors and torque.

Any help is appreciated!
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Move joint for specfied time

Post by iforce2d »

So is the end goal to move a specified number of steps, or stop at a specified position?

For a specified number of steps you could just count the steps, eg. an int counter starting at zero and increment every time step until it was the right number.

To move to a specified joint angle, you can do GetJointAngle (presuming we're talking about revolute joint) to see what the current angle is, and then set the motor speed accordingly. So if the current angle is less than the target angle, the speed should be positive, otherwise it should be negative. You might like to also scale the speed down as the joint gets close to the target.
blakey87
Posts: 28
Joined: Wed Jan 09, 2013 7:57 pm

Re: Move joint for specfied time

Post by blakey87 »

OK great that seems simple enough, its a revolute joint and that is also the goal, could this work simultaneously on multiple joints also?

Thanks for the quick reply iforce
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Move joint for specfied time

Post by iforce2d »

Yep sure. You would just have to do the same thing for all of them.
You might be interested in the robot arm example here: http://www.iforce2d.net/blog/2011-07-25
That uses the second method I mentioned to move multiple revolute joints between target positions.
blakey87
Posts: 28
Joined: Wed Jan 09, 2013 7:57 pm

Re: Move joint for specfied time

Post by blakey87 »

Yeah that helped a great deal, I have now managed to get the legs alternating between lifting and going back down.

I think I'm now up for trying to create some sort of script to convert the animations built in this software into Box2d keyframed skeletal animation

http://demina.codeplex.com/documentation

An awesome looking game uses this technique

http://www.reddit.com/r/IndieGaming/com ... _new_game/

Thanks iforce!
Post Reply