[Help] 2 revolute joints + 1 prismatic joint = fail for me

I'm trying to come up with a system of joints that simulates a pendulum like object. I'm not sure what I'm trying to do is possible with the approach I'm taking. See the diagram down below. Here's the action I'm trying to achieve:

- black shape is a base and has a fixed location
- orange shape is a rod that connects the base to the weight and swings back & forth (indicated by the orange arrows)
- red shape is a weight that can rotate (red arrows) and include some "give" along the green axis as marked (green arrows).

If I define the upper joint to be a revolute joint between the base and the rod, and the lower joint to be a revolute joint between the rod and the weight, I get close to what I want. The rod swings back and forth (rotating about the upper joint), carrying the weight which revolves around the lower point. Life is good.

The problem appears when I introduce a fourth body that I name the axle. This is a go-between from the rod and the weight. I create a prismatic joint between the rod and the axle, and then a revolute joint between the axle and the weight. The intent is to allow the weight to move up and down along the green axis as the rod swings back and forth. However, what I end up with is a rod that no longer swings and seems constrained to its initial vertical position. The weight still revolves about the lower joint and has the additional action of up and down movement. Close, but no cigar.

I thought that the prismatic joint between the axle and the rod would be relative to the rod's position, but that does not seem to be the case since the rod is now constrained from swinging back and forth. Am I trying to do something that simply isn't possible or is it perhaps due to an implementation problem on my part.

Thanks,
--tim
What kind of settings does the axle body have? I'm guessing it doesn't need to be a visible body in your final product, so perhaps you didn't give it any fixtures? In particular, if you didn't give it any density it will be a fixed rotation body - that would prevent the rod from rotating.

If this is indeed the case, the easiest fix would be to add a fixture and just not draw it in your final game.

Another way would be to manually SetMassData for the body, but it's kinda hard to know what values to use. I have done it by first attaching a fixture and using GetMassData to get the settings it resulted in, then removing the fixture and using SetMassData to set those values back so the body ends up with the same mass and rotational inertia but with no fixtures.

One more point to consider is that the axle should not be too light if you want it to hold the rod and the weight together solidly 🙂
You sir... are a genius. 🙂

I originally created the axle without a fixture. I just added the fixture and now it works. Thank you VERY MUCH!

--tim

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