b2FrictionJoint setup question

I'm creating what I believe to be a simple top-down simulation and have come across the recommendation in the user manual to employ a friction joint to apply translational friction, which is desired.

Unfortunately, the manual just says "See b2FrictionJoint.h and ApplyForce.h for details"

There doesn't appear to be a file called ApplyForce.h (unless I missed this file when setting up my project), but I included the friction joint header in my code and declared a joint definition struct to see what was required to set one up. The initialization function calls for the two bodies in order to create a joint, and I'm not sure how a second body would be used in this case. I'm under the belief that this joint will act as a damper for velocity on both axes. None of my objects rotate in this world. So programmable velocity damping is all I'm after.

Still... not sure how to set this up with two bodies if I'm not intending to tie this body to another one. Am I missing a basic concept here? If you've used these joints successfully, let me know what's expected here. Thanks!

Kind Regards,
Seth Gorden
ApplyForce.h is the rather unfortunately named example of using friction joints that is part of the testbed.
http://code.google.com/p/box2d/source/b ... plyForce.h

A friction joint tries to make the relative velocities (linear and angular) between the two bodies zero. So it does act similar to a damper that works on all degrees of freedom, but you can set an upper limit on how effective it is by specifying a maximum force/torque for it.
Typically one of the bodies would be a static 'ground' body so it may seem unnecessary to have a second body for that situation, but there is no reason both bodies could not both be dynamic, eg. moving one body should cause the other body to be affected by the friction between them, like a biscuit on a plate.
On the other hand the joint anchors are unnecessary 🙂
I'm confused by your comment: "On the other hand the joint anchors are unnecessary". Are you talking about the requirements for creating and initializing a friction joint, or is this some other kind of comment?

On the subject of a 'ground' body. I have not created one in my simulation. In your analogy, I have no plate. All I have is biscuits here.

Is there an implicit ground object I can use or is it required that I explicitly define a ground body in order to get the friction results I want?
Then you are gonna have to create a ground body. It can be just:
b2BodyDef bd;
b2Body* groundBody = world->CreateBody( &bd );

Yes, I mean the joint anchors are not used in a friction joint, because there is no specific point on either body that needs to be kept in a particular position. It's just the relative velocity between them that gets constrained.
Thanks for providing an example.

I was thinking for a moment that I'd have to make sure the ground body is the same size as the entire explorable area of my simulation. It looks like, from your sample, that the ground body doesn't require any specific dimensions or anything- it just has to exist as a body object in memory. Is that true?
Yeah that's right. The default settings for a body def are ok for a ground body, and you don't need to give it any fixtures. It just needs to exist as one side of the joint so that the "friction" has something to act against.

Original thread: https://box2d.org/forum/viewtopic.php?t=9061