Revolute joint angle

General discussion about the R.U.B.E editor
Post Reply
Insomniac
Posts: 3
Joined: Tue Jul 09, 2013 8:02 pm

Revolute joint angle

Post by Insomniac »

Hi!

First of all thanks for great tutorials and R.U.B.E. tool. I'm still getting started with it, but it looks like a great tool.

One think that I'm strugling with is a starting angle of revolute joint. Here is the situation.

I have bodies (each has 1 fixture, rectangle, in fact they are all clones). I want to build some kind of bouncy tree using them and revolute joints. To do this I place them and connect using revolute joints. Some of them connect ok (at least vertical, main branch of the tree), but when it gets to connecting rotated objects they go crazy when I hit play.

Here is a screenshoot of connecting 2 bodies
https://dl.dropboxusercontent.com/u/394 ... _angle.png

As you can see,
1. Reference angle (green line) is set to 0 and pointing up.
2. Enable Limits is ON
3. Upper & Lower limits (yellow lines) are also 0, but point in absolutely different direction.

This is what I got by selecting bodyA (on the right) then shift-select bodyB (on the left), putting cursor to cross between them, adding revolute joint and enabling limits.

If I hit run, everything goes crazy. If I set reference angle to -152.147 degrees (which is joint angle as you can see in tooltip with info) everything works fine. But I'm a total noob in box2d and in tutorials everyone says that you shouldn't touch reference angle and leave it 0.

What is a proper way to create revolute points in R.U.B.E.? I've watched tutorial (on youtube with A & B letters, but there was no such issue with joint angle).

Thanks in advance for any help.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Revolute joint angle

Post by iforce2d »

I think you might just be having the same trouble these people had:
http://www.box2d.org/forum/viewtopic.php?f=3&t=7723
http://www.box2d.org/forum/viewtopic.php?f=3&t=9242
Insomniac
Posts: 3
Joined: Tue Jul 09, 2013 8:02 pm

Re: Revolute joint angle

Post by Insomniac »

Thanks for reply! I'm aware of that issue, I've seen first topic you mentioned, thanks for the second there is a good info about having mass of lower branch >= sum (children), but I belive currently issue is not in this one.

I've made a different scene. I have 1 edge (ground), and only 2 rectangles.
Here is everything that I have
Image

As you can see again right after adding revolute joint and checking "enable limit" reference angle and upper/lower limits are pointing different directions. What I expect is when I hit play, 2 bodies will fall down like a roof of the house.

Here is what world looks on pause (before I hit play).
Image

And here is what I see few milliseconds later (and it stays in this position).
Image

As you can see bodies are twisted by some force (revolute joint I guess), and completely not like a roof of the house ^

Thanks in advance!

UPD:
If I change reference angle of joint to angle value from tooltip, then everything works fine in both samples (tree and this roof), also tooltip shows revolute angle close to zero (because reference angle is close to the one in tooltip).


Image

Then everything works just fine in simulation (again for the tree and for this simple sample).
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Revolute joint angle

Post by iforce2d »

In your first screenshot, the joint limits are both zero, while the joint angle is -86, so when the simulation starts the joint is 86 degrees in violation of its constraints. That's why it gets pulled around so quickly.

Try setting the joint limits to where you want the bodies to be held to. In this case I'm guessing you might want both limits at -86. You can hit the 'L' key to set the limits visually if it helps.
Insomniac
Posts: 3
Joined: Tue Jul 09, 2013 8:02 pm

Re: Revolute joint angle

Post by Insomniac »

Thank you for explanation. Looks like I've misunderstood whole idea of revolute joint reference angle. I thought that when you create joint, current angle between bodies is taken as zero, and all further rotations are relative to that zero.
Image

But it looks like in tutorial the actual angle between bodies is also zero, and in my case it is non-zero and I have to adjust reference angle.
Post Reply