Only allow rotation in one direction?

Topics: Developer Forum
Oct 17, 2012 at 11:24 AM

Hi

I am trying to recreate a machine in Farseer that uses one way bearings to only allow a weight to rotate in a single direction around a pivot point.  So I need to be able to apply a force to move them in an anti-clockwise direction, but they cannot move backwards in a clockwise direction.

I have them set up using Revolute joints and they are swinging away nicely, but I am stuck on how to constrain rotation to one direction only... is this possible and if so, does anyone have any pointers as to how I would do this?

Cheers

Paul

Oct 17, 2012 at 5:49 PM

I have posted this question on Stackoverflow, to reach a wider audience...

http://stackoverflow.com/questions/12939274/farseer-box2d-constrain-rotation-of-revolute-joint-or-other-to-one-direction

Any help would be met with copius amounts of good karma!

Oct 17, 2012 at 6:21 PM
Edited Oct 17, 2012 at 6:21 PM

How about you zero the angular velocity if it's negative (clockwise) in each time step. Similar to the top-down-car tutorial here where lateral velocity is cancelled:

http://www.iforce2d.net/b2dtut/top-down-car

Oct 17, 2012 at 10:51 PM
Edited Oct 17, 2012 at 10:52 PM

Thanks very much for the reply!

Unfortunately AngularVelocity and/or AngularDampening either/combined have a dampening effect, rather than a halting effect.  I tried ResetDynamics for the weight bodies, but that had undesirable results.  I had a look at RevoluteJoint.cs to see if I could hack a OneWayRevoluteJoint, but it is eluding me at the moment.

Thanks again.

Oct 18, 2012 at 9:50 PM

Have you also tried a simpler solution with limits? Setting lower limit to some positive value and the upper to some big positive value. Then at each update get the joint angle and bump the lower limit to be equal to the joint angle. This way the joint is allowed to move only from lower to upper limit and if it does move then the lower limit will be changed to represent the new starting point. 

Oct 22, 2012 at 9:09 PM
Edited Oct 22, 2012 at 9:09 PM

Sorry for the late reply.  Yes I had tried that, but the model doesn't respond well... ie the objects with the limits are applied to start moving out of control the minute force/movement is applied to the structure they are attached to.  I made sure I included the zero degree angle value in the range as specified in the box2d documentation, but it didn't help.

Thanks again for the help though.

Oct 25, 2012 at 8:07 PM

Well apart from playing with revolute joints limits and motors you could try a prismatic as well connected to a kinematic center body. Subscribe to the contact listener and calculate the torque to be applied to the center body T=r cross F. Apply the torque only if it's in the direction you want. 

Oct 27, 2012 at 7:39 PM

Could you use the gear shapes to model an invisible ratchet?
Here is a google image of what I mean: http://gravityandlevity.files.wordpress.com/2010/12/feynmans_ratchet.png

I'm modelling planets going around a star and I'm running into the same issue.
The best results I've had so far have been to pin a thruster onto the planets and have the thurster cut-out if already at the desired speed. It works a lot better than relying on a motorised revolute joint. It's still not ideal though. I intend to try the ratchet.