PULLEY JOINT

21
Jun
2012



A pulley is used to create an idealized pulley. The pulley connects two bodies to ground and to each other. As one body goes up, the other goes down. The total length of the pulley rope is conserved according to the initial configuration.

length1 + length2 == constant

You can supply a ratio that simulates a block and tackle. This causes one side of the pulley to extend faster than the other. At the same time the constraint force is smaller on one side than the other. You can use this to create "Mechanical Leverage".

length1 + ratio * length2 == constant

For example, if the ratio is 2, then length1 will vary at twice the rate of length2. Also the force in the rope attached to body1 will have half the constraint force as the rope attached to body2.

pulley_joint

Make sure the following codes are at the beginning.
var    b2Vec2 = Box2D.Common.Math.b2Vec2
,      b2BodyDef = Box2D.Dynamics.b2BodyDef
,      b2Body = Box2D.Dynamics.b2Body
,      b2FixtureDef = Box2D.Dynamics.b2FixtureDef
,      b2World = Box2D.Dynamics.b2World
,      b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape
,      b2CircleShape = Box2D.Collision.Shapes.b2CircleShape
,      b2RevoluteJointDef=Box2D.Dynamics.Joints.b2RevoluteJointDef
,      b2MouseJointDef =  Box2D.Dynamics.Joints.b2MouseJointDef
,      b2PulleyJointDef = Box2D.Dynamics.Joints.b2PulleyJointDef
,      b2DebugDraw = Box2D.Dynamics.b2DebugDraw
,      b2Fixture = Box2D.Dynamics.b2Fixture
,      b2AABB = Box2D.Collision.b2AABB;

Line 10 should be present.

Pulley Joint Definition

var myjoint = new b2PulleyJointDef();
var worldAnchorOnBody1 = new b2Vec2(6, 7); // Anchor point on body 1 in world axis
var worldAnchorOnBody2 = new b2Vec2(16, 7); // Anchor point on body 2 in world axis
var worldAnchorGround1 = new b2Vec2(6,3); // Anchor point for ground 1 in world axis
var worldAnchorGround2 = new b2Vec2(16,3); // Anchor point for ground 2 in world axis
var ratio = 1; // Define ratio
myjoint.Initialize(box1, box2, worldAnchorGround1, worldAnchorGround2, worldAnchorOnBody1, worldAnchorOnBody2, ratio);
//myjoint.lengthA = 10; // The a reference length for the segment attached to bodyA.
//myjoint.lengthB = 6; // The a reference length for the segment attached to bodyB.
world.CreateJoint(myjoint);

NOTE: If you know what lengthA and lengthB in lines 8 & 9 means, please share.

NOTE: To view Source for the given example, right click on canvas element and View frame source.

NOTE: Remember Box2d assumes body is in the correct position when the joint is made.

By administrator at 04:08:23 PM 4 Comment(s)

Comments

have you figure out what line 8 and 9 is for?

By L2L2L on 15 Oct, 2014 at 09:03:58 AM

Even I don't about those two lines. Play around by changing those two values and see what happens. And do share with me.

By administrator on 15 Oct, 2014 at 09:41:54 AM

The line8&9, I guess, they are the max length of the two ropes to be pulled…

By Villerio on 18 Jul, 2015 at 02:35:00 AM

Thanks! :)

By administrator on 18 Jul, 2015 at 03:49:22 AM

Add a Comment

Please enter the email address.Invalid format. (Won't be Displayed)
Notify me of followup comments
Enter the displayed Code: captcha