Joints with changing positions?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
seabert
Posts: 11
Joined: Sun Aug 29, 2010 10:33 pm

Joints with changing positions?

Post by seabert »

Hey guys,

I was wondering if anyone could help me with this problem. Check out this mock-up:
Image

I currently have the green part of the drawing done. It is basically a platform with spider like legs that have motors to expand or shrink.
What I am trying to achieve is have another box (the blue line) attached to the platform that should always go through the middle of the red line, the centre of the 2 spider legs. Problem is that the red line can become longer or shorter. I really have no clue how to tackle this.

Hope someone can give me some tips on this?
Other than that I am amazed how easy to use this physics engine is, great work! :o
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Joints with changing positions?

Post by Norbo »

One option that comes to mind is to create a BallSocketJoint/(angular motor of some kind) pair at the attachment point between the blue box and green platform.

If I'm understanding the behavior correctly, a RevoluteMotor in servo mode would do the trick. The angle could be calculated from the offset between the platform attachment point and the midpoint of the red line.

There may be another option involving a linear constraint that operates at the red line midpoint, but the ones I've thought up so far would probably take more work to set up than the RevoluteMotor. If I think up something better, I'll post it here.
Other than that I am amazed how easy to use this physics engine is, great work!
Thanks :D
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Joints with changing positions?

Post by Norbo »

By the way, to anyone reading this who wants to know how to set up a servo in the above:

Code: Select all

            //after the RevoluteMotor is created, assign its mode.  Settings also includes all sorts of configuration options (stiffness, target velocity for velocity motors, etc.)
            //While in servo mode, the motor uses its Servo settings, like target angle.
            motor.Settings.Mode = MotorMode.Servomechanism;
            
...
            //Since the target angle can change every frame, tell the servo to use a new goal in the game's update.
            motor.Settings.Servo.Goal = targetAngleComputedFromOffset;

Here's another approach that might be closer to what you want:
Create a PointOnPlaneJoint for each spider leg. The planes are anchored to the blue box, and the points are anchored to the tip of each leg. The joints' SpringSettings would need to be weakened from their default near-rigid values. The effect would be each spider leg pulling on the plane attached to the middle box, aligning it in the middle (or as close as the springs can get it). Shoving the middle box around in this configuration would pull the spider legs if pulled away as well.

The blue box would still be hooked up to the platform in some way, too, of course.
seabert
Posts: 11
Joined: Sun Aug 29, 2010 10:33 pm

Re: Joints with changing positions?

Post by seabert »

Thanks for the suggestions Norbo.

I've tried them out and it seems my "idea" just a bit too unstable to be useful for a game.
I will have to work something else out :)

Thanks again!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Joints with changing positions?

Post by Norbo »

If it's the engine having trouble with the articulated joints, you could try increasing the Space.SimulationSettings.CollisionResponse.Iterations. If you have some CPU time to spare, it will improve the overall simulation quality.
Post Reply