Page 1 of 1
Help with joints
Posted: Tue Apr 26, 2011 10:47 pm
by damagex
Hate to resort to asking but I'm floundering with trial and error. I have a few questions:
I'll briefly describe what I'm trying to do, hopefully it will be clear. What I'd like to do is put a body on top of a snowboard. A fewthings I'm having trouble figuring out is the following:
1. I'd like to put a mechanism on the snowboard to "help" keep it straight (pointed down hill). I would like to apply some resistance (on the y_axis) to allow it to turn a little, but then always spring back to straight down the hill. Basically I wan to prevent it from spinning around. It would be good as well if there was a breaking point, in that if the force exceeds X, the "spring would break.
2. This may be similar to the previous only it would be between 2 objects. Say for example the player's knees. Assuming I'm using a ball joint (maybe even a hinge) to connect them, I would like the angle to default to say 45 degrees (for argument sake). I would also like there to be a spring-like tension to the joint. So when the player lands, some of the impact it taken up by the "spring joint" and settles back down to the 45 degree angle (os close to it).
3. I'm using your UprightSpring to help keep the board/player upright in order to keep him from falling - simulating balancing. Sound correct?
Thanks!
Re: Help with joints
Posted: Wed Apr 27, 2011 12:06 am
by Norbo
1. I'd like to put a mechanism on the snowboard to "help" keep it straight (pointed down hill). I would like to apply some resistance (on the y_axis) to allow it to turn a little, but then always spring back to straight down the hill. Basically I wan to prevent it from spinning around. It would be good as well if there was a breaking point, in that if the force exceeds X, the "spring would break.
You could use a RevoluteLimit or RevoluteAngularJoint to do this. They don't have built in breaking, but you can check their total applied force by looking at the TotalImpulse property; if it's greater than some value you define, you can remove it from the space. The spring settings can be adjusted to make it more springy instead of rigid.
2. This may be similar to the previous only it would be between 2 objects. Say for example the player's knees. Assuming I'm using a ball joint (maybe even a hinge) to connect them, I would like the angle to default to say 45 degrees (for argument sake). I would also like there to be a spring-like tension to the joint. So when the player lands, some of the impact it taken up by the "spring joint" and settles back down to the 45 degree angle (os close to it).
A RevoluteJoint could do it. However, it sounds like that particular situation would be better faked without any physical simulation.
3. I'm using your UprightSpring to help keep the board/player upright in order to keep him from falling - simulating balancing. Sound correct?
Should work; might run into some issues where the player can't do flips or can't stick to steep slopes. Those can be worked around by deactivating or modifying the system pretty easily though. You may want to consider not having a 'player' actually physically there, or alternatively, have no physical board and just use a character controller like system for skiing. This thread contains some information about that:
http://www.bepu-games.com/forums/viewto ... ?f=4&t=941 (just scan for the discussion about modifications to the SimpleCharacterController).
Re: Help with joints
Posted: Thu Apr 28, 2011 5:52 am
by damagex
Thanks for the reply, that's enough to get me going.
Re: Help with joints
Posted: Sat Nov 24, 2012 4:27 pm
by coimbra79
i have a broblem with joints too, i cant perform absolutely rigid joints...
if i use the defoult settings the spring is visibily soft, if i try to use the settings to let them be hardest, joints became unstables and 'tickfull'...
You can image a table, and the feet are (for ex.) boxes attached to board by a prismaticjoint... I set for the the motor of the prismat as suspension.. this way:
Code: Select all
var SospenzioneAD = new PrismaticJoint(table, foot, foot.Position, Vector3.Up, foot.Position);
var SospenzioneAS = new PrismaticJoint(table, foot, foot.Position, Vector3.Up, foot.Position);
var SospenzionePD = new PrismaticJoint(table, foot foot.Position, Vector3.Up, foot.Position);
var SospenzionePS = new PrismaticJoint(table, foot, foot.Position, Vector3.Up, foot.Position);
SospenzioneAD.Motor.IsActive = true;
SospenzioneAD.Motor.Settings.Mode = MotorMode.Servomechanism;
SospenzioneAD.Motor.Settings.Servo.Goal = 0;
SospenzioneAD.Motor.Settings.Servo.SpringSettings.StiffnessConstant /= 500;
SospenzioneAD.Motor.Settings.Servo.SpringSettings.DampingConstant /= 500;
this seem work properly... but the feet moves along yAxis and have some of pan and tilt too...
I know the cause of this iussue is to retrieve into 'springsettings'. Into a 'wonderfull world', setting the softness:
Code: Select all
SospenzioneAD.AngularJoint.SpringSettings.Advanced.Softness = 0;
SospenzioneAD.AngularJoint.SpringSettings.Advanced.ErrorReductionFactor = 0.9f;
SospenzioneAD.AngularJoint.SpringSettings.Advanced.UseAdvancedSettings = true;
all would be OK... but it isnt!
What the right way to perform an absolutely (or exremely) rigid joint...
very very thanks!
Re: Help with joints
Posted: Sat Nov 24, 2012 4:43 pm
by coimbra79
the green circled box is contrained to the board with a prismatic... but it seem free in y angular axis...
Re: Help with joints
Posted: Sat Nov 24, 2012 9:47 pm
by Norbo
Extremely rigid constraints make it harder for the solver to compute a good solution in some cases. Usually, this involves large mass ratios. If there are high mass objects which depend on relatively low mass objects, rigid constraints can cause issues. When the solver can't find a good solution in time, it results in jitter, instability, or explosions (depending on how bad the conditions are).
So, if there are very heavy objects objects depending on light objects, try to equalize the mass a bit.
If you still need an infinitely rigid joint, you can set the softness to zero. However, do not pick a high value for the error reduction factor. I would not recommend going over 0.2 with softness at 0. High error reduction factors will make it much less stable.
An example of a robust constraint-based car can be found in the SuspensionCarDemo in the BEPUphysicsDemos.
Re: Help with joints
Posted: Sat Nov 24, 2012 11:02 pm
by coimbra79
the board, feet and wheel have 30 of mass
wheel radius = 0.3
board = 1 x 3 x 0.5
feet = 0.25 x 0.25 x 0.8
board is joints with the feet with a prismatic in back and a lineslider in front, just to apply the revolutemotor to steer.
im using the example as starting for my proj... and naturally before call your help i study more than possible...
I apply the spring correction in prismatic and lineslider angularJoint (that's right??)...
Trying, i noticed that upscaling the feet localinertiatensor, the tick is resolved, but naturally when the vehicle steer the big tensor applied to feet dont let the vehicle turn properly (at low speed too...).
Re: Help with joints
Posted: Sun Nov 25, 2012 2:50 am
by Norbo
Usually, in the absence of mass ratio issues or obviously bad configuration, poor behavior is caused by a confluence of many different small factors. I can't really point to one spot with certainty.
The fact that increasing the inertia tensor helped implies that things are in a fairly difficult configuration with lots of high-leverage interactions.
Instead of trying to (futilely) remotely debug the configuration, here's a new variant of the suspension car demo which seems to do what you want robustly:
http://bepuphysics.codeplex.com/SourceC ... arDemo2.cs
Generally speaking, limiting the number of entities in a constraint chain improves behavior. The suspension blocks don't add a whole lot to the simulation by the looks of it; just using the unmodified SuspensionCarDemo would be faster and produce similar results.
Re: Help with joints
Posted: Sun Nov 25, 2012 2:23 pm
by coimbra79
your new demo is very similar to my procedure... the structures of joint in your engine are very friendly and i like them because everyone can use it easy.
I think i wrong some before... infact the bug occour every time i use joints (a single too): they are too soft in spring contraints, and if i try to set the spring to perform an 0softness, the sistem becames unstable untill crashing.
this is my way to use joints into my engine.
1-create all entities i need for jointed sistem (ex A,B,C).
2-assign the right position and orientation to them respect the sistem (ex A.pos=pos_a,B.pos=pos_b,c.pos=pos_C).
3-build joint (ex AjB,AjC) and relative motors and constraints.
4-create all joints builded (ex space.add(AjB), space.add(AjC)).
is it right?
Re: Help with joints
Posted: Sun Nov 25, 2012 2:30 pm
by coimbra79
...mmm... a note
if try to set differents mass and spring settings, max speed etc in you sample the joint-sistem mantains his stability. So i presume the mass is not the problem.
why this line works without the right parameters numer?
Code: Select all
steeringMotor = new RevoluteMotor(body, suspensionLeg, Vector3.Up);
Re: Help with joints
Posted: Sun Nov 25, 2012 2:57 pm
by coimbra79
The fact that increasing the inertia tensor helped implies that things are in a fairly difficult configuration with lots of high-leverage interactions.
bingo...
I dont know why the solver.iterationlimit was set to 1!!!
Now im happy like a kid into a toy-shop with the daddy credits card!
Im testig all the joints demo builded before and all work properly!
Very very thanks again!
NORBO 4 PRESIDENT!