Page 1 of 1

Move joint for specfied time

Posted: Sun Jan 20, 2013 2:24 pm
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!

Re: Move joint for specfied time

Posted: Sun Jan 20, 2013 2:33 pm
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.

Re: Move joint for specfied time

Posted: Sun Jan 20, 2013 2:39 pm
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

Re: Move joint for specfied time

Posted: Sun Jan 20, 2013 3:14 pm
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.

Re: Move joint for specfied time

Posted: Mon Jan 21, 2013 9:44 am
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!