I need to change revolute joint's angle in one timestep, without angle errors! How can I do this?
Changing revolute joint's angle
General DiscussionI think you should use animation for this, not physics simulation.
but then I would have problems with body parts which go into walls..
EDIT: ragdoll finally works right, I made a copy-paste mistake in body state interpolate function 🙂
EDIT: ragdoll finally works right, I made a copy-paste mistake in body state interpolate function 🙂
pushing up the topic again.. 😳
I seek for the correct speed to pass to SetAngularVelocity so the body's direction would be changed in exactly one call to Step() function!
Maybe someone has some ideas?
I seek for the correct speed to pass to SetAngularVelocity so the body's direction would be changed in exactly one call to Step() function!
Maybe someone has some ideas?
SpeedInRadiansPerSecond = AngleToChange / TimeStep = AngleToChange * Framerate
I thought about that first, but it didn't work..
Perhaps you have some damping or other interactions going on that are messing things up. Gravity maybe? Or you could have the sign of angle displacement wrong. But speed = distance over time is definitely correct for when nothing else is happening.
Yes, the world has gravity force working
and no damping for the objects of that joint
but the problem is different - it goes too fast!
and no damping for the objects of that joint
but the problem is different - it goes too fast!
Your problem is that angular velocity is a per-body value, and is only implicitly connected to the revolute joint's angle, so the math is not quite that simple.
If you insist on going with this direct approach rather than tuning motors, limits or springs to achieve your desired result, you're pretty much attempting to reproduce the functionality of the SolvePositionConstraints function in b2RevoluteJoint when the limits are both equal, so I would look through that code and see what it's doing.
But does this absolutely have to happen in one time step? I can't see many reasons you would need to create your own solution when the whole motors + limits mechanism is in place...
If you insist on going with this direct approach rather than tuning motors, limits or springs to achieve your desired result, you're pretty much attempting to reproduce the functionality of the SolvePositionConstraints function in b2RevoluteJoint when the limits are both equal, so I would look through that code and see what it's doing.
But does this absolutely have to happen in one time step? I can't see many reasons you would need to create your own solution when the whole motors + limits mechanism is in place...
So, I've got one more idea about doing this 😀 (yeah, again)
setting the revolute joint's limits should work..
but it doesn't!
I just enable limit at the start and set it every frame but it looks like I can't change it!
What I am doing wrong?
EDIT: now it holds the joint angle to zero..
setting the revolute joint's limits should work..
but it doesn't!
I just enable limit at the start and set it every frame but it looks like I can't change it!
What I am doing wrong?
EDIT: now it holds the joint angle to zero..
Original thread: https://box2d.org/forum/viewtopic.php?t=672