Frozen Motor Bearings on the Oimo Car and Oimo Paddlewheel

    // Keep defaults consistant with other physics plugins
        if (maxForce !== undefined) {
            Logger.Warn("OimoJS plugin does not support setMotor with maxForce");
        }
        maxForce = 1e6;
        speed *= -1;

This is bad. I say reverse this immediately. Let’s not cut corners. PLEASE?! Let’s figure out why the maxForce is broken in Oimo, and just fix the ACTUAL problem, not “hotwire” it into working “ok”. Maxforce is an important property on motors… not something to be jury-rigged.

http://schteppe.github.io/cannon.js/docs/classes/HingeConstraint.html#method_setMotorMaxForce

Cannon has had maxforce active forever. Ammo probably has a maxforce, too. yeah, let’s stay consistent… by keeping maxforce active and historically consistent.

Bad policy. Pencil-whipping. Nuff said.

@Wingnut, I agree that this is not a good final fix and that there is a deeper issue within oimo, I can revert it back to have the old behavior but keep the warning.

Have you found any oimo docs on motors all i can find is the maxMotorForce references in the source Oimo.js/oimo.js at gh-pages · lo-th/Oimo.js · GitHub but nothing is obvious to me and the vehicle example doesn’t seem to be working either Oimo.js Vehicle

nod nothing obvious to me, either. We keep working/investigating. No hurry to close the issue. There’s no racing/deadlining that should be happening.

I say we revert back to BJS 2.4 as “the latest” until we get 2.5 ACTUALLY ready for release. Then climb up thru the mess one more time… see if we can get it right. (nobody will go for THAT, though).

Something killed Oimo setMotor in BJS 2.5, (if no OIMO LIB stuff changed during 2.5 release). It’s really just that simple. If OimoJS lib didn’t change during 2.5 release, then it has to be something with BJS.

Once we see a diffs report between 2.4 and 2.5, we might know more.

There’s no hurry, right? Let’s build a team and dig it out. I’ve done quite a bit of the prelims.

btw, even when you keep the warning ONLY in the code, does that “feel” like we “blew it off”?

By putting a warning in there… we might “check it off” (pencil whip it) from our issues list, or let it slide to a low low priority.

Really, it’s a very high priority, and needs to stay at the top of the issues list… until reason found.

I’m thinkin’… not JUST a warning, but the URL to a youtube video we make… that is just BEGGING for experts to help us find the reason why Oimo maxForce needs to be so high, or it stutters.

We’ll show children crying and stressed wives… complaining about how this terrible Oimo bug keeps their husbands at the office for 16 hour days… and show some wet, shivering puppies… just a real “cry me a river” beg for helpers. :smiley:

No? unh. I dislike the warning IF it drops the issue from the top of priority lists.

@Wingnut, @trevordev I have been giving it some more thought and that is what I did not do in the first place. What I was doing was to want a PG on motors that made something move and forgot that it was a simulation of the physical world. Having now given it more thought I realise that I missed out that n the physical world a motor will have angular velocity and torque (angular force). So for example a small hand held fan will have high speed and low force while a car motor will have lower speed and higher force.

Now thinking about the relationship between force and mass.

First take the linear case -

In this PG https://www.babylonjs-playground.com/#RHBQY9#16 you can change the impulsive force and the mass of the box before hitting run. The force needs to overcome the inertia of the box to get it to move at all. For a given force and changing the mass, the greater the mass the slower the harder it is to move the box up to a point where the mass is such that the force cannot overcome the inertia of the box.

In the angular case with a motor the same force (torque) applied to a wheel of increasing mass will find it harder to move the wheel round.

Currently as you will see in ths PG https://www.babylonjs-playground.com/#WWNQ10#1

While increasing the number in line 48 for set motor increases the speed but for a given speed increasing the mass in line 31 has no effect. (after the revert is deployed it will not work at all). This is not correct in a physical situation. So my apologies for being content with just getting things moving and not giving everything full consideration and leading people down the wrong path

Now consider the same situation using Oimo.js in the stable 3.3 version of BJS

https://www.babylonjs-playground.com/indexStable.html#WWNQ10#5

In this case the mass of the wheel is 1, and the two parameters for setMotor are 1, and 15000

In increase the first parameter to 10 and then 100 and run again and allow the wheel to run for a few seconds, 10 runs faster than 1 and 100 faster than 10.

Now leave the first value and decrease the second value. As the second value gets lower the harder it is for the wheel to move.

Increase the mass to 10 and you will find you have to increase the second motor value by a factor of 10 to get the same movement.

Thus I surmise that the second number represents the torque, the force required to overcome the wheel’s inertia and the first number is the speed (angular velocity) that the wheel will achieve when the inertia has been completely overcome.

For Cannon.js (BJS V3.3) https://www.babylonjs-playground.com/indexStable.html#WWNQ10#6

altering the second number (torque?) seems to have no effect thought the first does alter the speed.

In this Oimo Comments github lines 1975 - 1980 it states that

/**
	 * Set motor data into this constraint.
	 * @parammotorSpeed
	 * @parammaxMotorForce
	 */
	setMotor:function(){}...

That is the parameters for setMotor are speed and force

In RotationalMotorEquation - cannon

 setMotorMaxForce (

    maxForce 

)

Defined in src/constraints/HingeConstraint.js:95
Parameters:

    maxForce Number

setMotorSpeed (

    speed 

)

Defined in src/constraints/HingeConstraint.js:87
Parameters:

    speed Number

It again talks of speed and force

For Ammo (actually Bullet) in API

void btHingeConstraint::enableAngularMotor 	( 	bool  	enableMotor,
		btScalar  	targetVelocity,
		btScalar  	maxMotorImpulse 
	) 	

However in the BJS Physics Imposter line 195 it terms the parameters force and max force whereas perhaps the should be speed (angular velocity) and force (torque) force being a max force since its value limits its effect.

So to sum up there are a couple of issues

  1. setMotor should have two parameters speed and force that work in all plugins
  2. second parameter in Oimo seems very large for a small mass (something to do with a change from 2.4 to 2.5?)

Will raise as an issue

2 Likes

Exactly correct, top to bottom. Thanks John. It really doesn’t matter what the 2nd param is named… it has high-purpose, and should not be “fudged”.

The “thought” of the 1e6 kludge… makes me want to check for any rushing-to-clear-issues-lists that might be happening (and question the logic behind the rushing).

MaxForce on the OimoCar… is set at 6. When we get things right, the Oimo car will start working… with a fully-honored maxForce… of 6. Anything less, and we suck.

(Wingy dons a yellow vest. heh.)

Understanding how native Cannon.js, Oimo.js and Ammo.js works is a bit of a nightmare, docs that are understandable by me are few and far between. I note that Trevor did a revert PR on Oimo setMotor yesterday shortly after your post.

Will keep learning and see what i can help with.

Are you sure it was 2.4 to 2.5? I see from What’s New in the docs a re-write of Oimo and Cannon happened between 2.3 and 2.4 but nothing from 2.4 to 2.5

Original post: What breaking changes were there from v2.4 to v2.5 regarding Physics? - Questions & Answers - HTML5 Game Devs Forum

But still, we’ll take all the evidence/clues we can find, eh?

I still suspect transformNodes. Care to try to determine… in what BJS version… they were introduced/installed? (thx)

BJS PhysicsImpostor class has a suspicious and fairly new parameter named… umm… disableBidirectionalTransformation. It concerns me… not sure why. Need to ask Raanan why it was added and what its story is. Why it would ONLY affect Oimo joints… not sure. Something about Oimo Quats, I suspect.

https://playground.babylonjs.com/indexStable.html#5W5B6W#49

Enable/disable lines 293-295… to see it change the symptom.

I’m still awaiting/searching-for info about periodic caching operations, and system-wide isDirty servicing… if anything there… might happen at a 120 times-per-minute rate. Wingy operating blind… feeling around aimlessly… normal. :slight_smile:

On October 17 2016 nightly commit b6ce1ef updates babylon.max.js in 2.5 preview. At this point Oimo motor works correctly.

On October 18 2016 nightly commit b25adf8 updates babylon.max.js in 2.5 preview. At this point Oimo motor needs a large second number for it to turn.

I am making the assumption that abow’s commit 8d64a08 on 18/Oct/2016 is the reason it is to fix for oimojs plugin world scale issue. Perhaps it arose from this topic? oimo.js constant impulse - Questions & Answers - HTML5 Game Devs Forum

2 Likes

John, you are a GOD! Well done! Sorry I must ask this, but are your findings double-checked and sure-footed as possible?

link I think that is the right one.

Unfortunately, the Oimo plugin in my tests… doesn’t have a worldscale() method on its world obj.

Just the same, I’ve done some early tests with this.world.scale and other static methods.

https://playground.babylonjs.com/indexStable.html#5W5B6W#57

Lines 10/11 seem to do little… because line 16 console report says world.scale = 1.

Line 17 attempt to set world.scale = 5 … kills the scene.

Still early tests. Thanks for the sleuthing work, JK!


If I may include another finding… here is a PG I call “The Big Wheel

Smaller PG, all hijacks cleared-out, and wheel set to 40 diameter (big), but still normal sphereImpostor with a 10 mass setting.

Line 46… it requires over 51 million maxForce. (omg)

Line 48 reports that it has a mass of 335103+. Wow.

Oimo has “density” features. I’m not sure what it affects… maybe mass. Check this Oimo src link: link

Yep, for sphere shape… its radius affects density (I am using a semi-high-radius sphere-shape). Density affects mass, and inertia.

I think we, here at BJS Industries… have historically bypassed density usage in Oimo (along-with belongsTo and collidesWith).

link to OimoPlugin finds 4 occurrences of ‘density’ via document search. It looks like we have “hot-wired” density… to mass, somewhat.

Not sure if/how this is important or pertinent, but I thought I’d bring it up, just to add more brush to the fire. :slight_smile:

1 Like

I am never very sure of anything (or I might be wrong about that :woozy_face: )

I am pretty certain I have found the correct between dates for working and not working. At a first glance through the link I gave and you mentioned is the only one that mentioned Oimo however there could still be a file changed and committed without mentioning Oimo that still changed that plugin. Didn’t have time to check earlier also found a commit on the 16 Oct where my test with Oimo did not work but aagin haven’t had time to follow through.

In case you are interested I used things like

author-date:2016-06-18…2016-11-20

committer-date:2016-06-18…2016-11-20

author-date:2016-10-18…2016-10-20 author:deltakosh

in the BabylonJS/Babylon.js repository search bar making sure commits rather than code was selected after the first search (You seem to only get the option after you have made a search)

2 Likes

More problems looking at the OimoJSPlugin for 3.3 the ‘this.world.worldscale(1)’ has gone so somewhere along the way there was a change to the plugin that removed that line and transferred its effect elsewhere. Back to searching!!

1 Like

worldscale disappeared in commit b06eb6b so a simple one line that changed from 2.4 to 2.5 became a major change to the OimoJSPlugin between 3.1.1 and 3.2.

The question still remains - Why the first change to that forced the larger values for the maxforce?

EDIT Found it Change in worldscale first happened as a result of this post http://www.html5gamedevs.com/topic/25753-problems-with-bodylinearvelocity/?do=findComment&comment=147828

EDIT Have to do an edit as not allowed more than 3 consecutive replies. In the current Oimo,js file the equivalent of setting 'worldscale = 1` appears to be setting ‘this.scale = 1’ for rigidBodies and joints so maintaining the change that happened between 2.4 and 2.5.

However after further thought I am less convinced that this is a problem. Take a solid cylinder of mass 1 radius 5 turning about an axis through its central core perpendicular to its end faces with a angular velocity of 1. Its moment of inertia is found from 0. 5 x mass * radius * radius = 0.5 x 5 x 5. When we want the cylinder to go from 0 to 1 in one frame (ie 1/60th of a second) the angular acceleration is 1/(1/60) = 60.

Torque = Moment of Inertia * Angular Acceleration = 0.5 * 5 * 5 * 60 = 25 x 30 = 1250.

In the following PG with a cylinder mesh (radius = 5) as wheel with a cylinder impostor (mass = 1) and setting the motor with speed = 1 and maxForce (torque) = 1250 you get what is expected

https://www.babylonjs-playground.com/#WWNQ10#9

1 Like

https://www.babylonjs-playground.com/#WWNQ10#12

I got John’s playground rolling on a maxForce of 13 with mass=1 cyl-impostor! Beat that! :slight_smile:

(the original Oimo car easily beats it, rolling a 10-mass wheel on a maxforce of 6.)

Lines 86-111 - yikes.

Back in the old days, I don’t remember EVER dealing-with body1.shapes or body2.shapes. I only remember joint.body1 and joint.body2. AND… if I remember correctly (I don’t)… then mass, friction, and restitution were ALL properties on body1 and body2. These are the joint1.physicsImpostor.physicsBodys attached-to the “ends” of the joint. They are not mesh, nor are they BJS PhysicsImpostors. They are physicsBodies… which are Oimo objects, I believe. RigidBodys

In some of John’s links, I noticed lots of talk about ‘shapes’ in one of the github diff windows, and no talk of shapes in the other. hmm. Did Oimo start using ‘shapes’ in the newer version? Seems new to me, but might have originally been intended for compoundImpostors… which we have been fighting-with for years.

To sum it all up, I noticed that .mass and .massInfo properties… were members on the physicsBody objects, and .friction and .restitution… were members of body1/2 SHAPES objects. That seemed strange to me… not like my memories (but they are foggy at best).

So, lines 86 to 107… move .mass and .massInfo… from body objects… to body.shapes objects (place them along-side friction and restitution properties). AND I killed the old ones. AND… I “tweaked” all the mass values (4 of them)… all == 1. This is because I was seeing some oversize values in .mass and .massInfo.mass.

MassInfo seems new to me, as well.

There is another test that could be done. Move friction and restitution… from body.shapes objects… to body objects… deleting old ones after the move.

SO much heavy stuff, huh? In that thread you reffed, John… did you read DBawel’s discouraging comments about Oimo? He loved it and had to abandon it due to too much breakage. Sad.

We might have layers of bugs, atop layers of bugs… atop chewing-gum fixes, atop duct-tape fixes. Disheartening.

The wheel should work on maxForce 1. The stuttering… is a giant hint to something. It is something that MIGHT be able to be seen at console (likely, with an onBeforeRender streaming of some value… to console). sigh. (Wingy scrubs his beard so aggressively… that it starts on-fire) :slight_smile:

UPDATE: pg#13 … only lines 88 and 97 are needed… delete the mass from the body objects. Still needs 13+ in line 51. 12 causes stutters.

PS: As needed, just shove the line 34 llamas out of your way. :slight_smile:

Sorry @Wingnut it seems I have gone over to the dark side. My recommendation (which is described in this probable docs entry) for setMotor is

For a perfect theoretical motor you need to set a target speed (angular velocity) for it to reach and sufficient torque (force) for it to reach that speed. Depending on the shape and mass of the body for the motor to turn the torque will have to overcome the moment of inertia of the body. A too low value for the torque will make the body struggle and stutter to reach the target speed . Even simulating a virtual motor in zero gravity with no friction and a zero mass for the axel joint turning a cylinder can make determining an appropriate value for the torque difficult. Adding gravity, friction and further bodies, that the motored body has to move, makes it even more difficult. Sometimes in your project all you will want is for the motor to turn. This can be achieved by just setting the target speed for the motor as in

joint.setMotor(speed)

Other times it will be important to set a value for the torque that limits the motor operation, you can do this with

joint.setMotor(speed, force); 

Different engines use differing scales for torquee and a little trial and error is necessary
For Cannon.js try torque values between 1/100 to 1/10 of the mass value
For Oimo.js values can get large try between 10 and 1000 times the mass value
For Ammo.js try torque values between 1/100 and 1/10 of mass value

You can play around with mass and torque with two separate wheels in this https://www.babylonjs-playground.com/#WWNQ10#15

EDIT to correct wrong statements about Ammo.js

:slight_smile: That’s fun and all, but I’m just trying to get the Oimo Car and Oimo Paddlewheel working as they once did… for years. Never before have I seen a motor stutter, and I’ve done some serious Oimo joint/motor work.

Heads-up… setLimit is not involved with maxForce. SetLimits are angle limits… usually between PI and neg PI. AmmoJS setMotor() uses exact same format as OimoPlugin. 3-4 params when called from the plugin, and 2 params when called from the joint/native-layer.

Many times, in my “human leg” demo… I didn’t have enough maxForce on a knee joint… to lift the lower leg to 90 degrees. When the maxForce limit is hit, the motor just spins in place… no stuttering… just smooth slippage and some joint back-skidding. The back-skidding-then-re-lifting… never repeats at a set rate, and the motors never stop instantly. When they run out-of maxforce power, they ease to a stop, and then the back-sliding eases into motion, as well. (just like real-life limited-slip electric motors - stick your finger in an active, small personal fan. No stuttering… even if you rotate the fan blade the wrong way, against the motor maxForce)

Then Oimo-in-BJS changed yet again, and killed the whole human leg project. That project used special Oimo plugin and Oimo-only Impostor class… which honored impostor belongsTo and collidesWith… necessary features for human leg joints (I could have done it native, too, though). My version of the OimoPlugin was being groomed to PERMANENTLY honor belongsTo and collidesWith.

Pissed away. It didn’t matter. Nobody gave a shit about the hundreds of hours I put into it and teaching what I was testing/doing. Nobody understood or cared. Few people enjoy reading.

It was Raanan saying “If I get some time, I will build a basic leg joint”… that made me launch the project. He was already being pinged to death with others delegating all their physics problems… to him. I wanted to take-up some of that workload.

I’ve got 40 hours into getting the Oimo Car and paddle wheel working properly, again. I’ve been teaching the whole way. Why? Because I like pain, apparently. Thank God YOU got interested, John, or I probably would have committed suicide.

After we blow-off the Oimo engine and plugin… letting it die for no reason, we’ll do the same for Cannon, because everyone has Ammo fever right now. They think that a more powerful physics engine will make physics life… a bowl of cherries - wonderful. It won’t. Ammo and Oimo have similar names… for a reason.

I dunno, John. Where do we go from here? A 10 mass sphereImpostor once rolled with 6 max force… in Oimo. It did it… on a VERY important physics project… BJS’s FIRST EVER physics-active car.

THAT is the benchmark to re-reach, imho.

Physics helpers… we/ya’ll can do whatever ya wish, of course. We/Ya’ll can paint-up fancy numbers and excuses all we/ya want. Me, I’m striving for our original OimoCar benchmark… which uses maxForce values that match magnitude with Cannon joint maxForce values, or I’ll die trying.

We all know those 300000+ mass values we are seeing… are wrong and broken. We can fix 'em, or blow-off Oimo, like core-team/admin appear to WANT to do. Why would “we” compress OimoJS… 9 days ago? It is the LEAST wise time to compress our Oimo lib. It tells me… that somebody is hurried and railroaded toward doing SOMETHING, and they need to get something wrapped-up in a pretty ribbon and bow… in a hurry.

We gotta back-out of 4.0. Get back to 3.3 and sit there until we fix this crap. Stop playing games to kiss the asses of the mobiles, and stop the railroading towards webpacking. That’s my opinion. No need to quote angular force numbers… when big dog forces are shoving shit around and intentionally ignoring issues. Our investigative work might get wasted… by the authorities.

We can either clean-up, or continue playing games. All my attempts to promote cleaning-up… have been met with pure silence (except for you, JK). Sorry if this ruffles anyone’s feathers, but it’s how I feel. Thoughts?

Only the impulses are broken in some of the human leg playgrounds. https://www.babylonjs-playground.com/#1ND6TH#196 - this one allows some motor-work (speed adjust) with sliding the red sliders. Not sure why THAT is working properly. Not even a 3.3 playground! Holy crap.

Anyway, we can see what maxForce-reaching and blacksliding is supposed to look like. My maxforce settings in that demo… are at 25000, so this demo was created AFTER “the overpower issue” arrived… but possibly BEFORE the stutter issue arrived (yes, they could be two different issues).

And yes, it appears that… motor speed DOES affect motor force (it probably shouldn’t). Those red-puck sliders… prove it. (I didn’t know this - but johnK hinted at it). Impulses are looking good on this PG, once again. Click on the left/right sides of ANY red LABEL… to do impulsings on the femur. The further from red label CENTER… that the click happens, the more powerful the impulsing.

Somebody should probably test locking the speed to a set value, and then hooking the sliders to maxForce… see what blows up… see if we can get some stuttering. :slight_smile:

I mean BJS setLimit as in CannonJSPlugin.js

 public setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number) {
        if (!motorIndex) {
            joint.physicsJoint.enableMotor();
            joint.physicsJoint.setMotorSpeed(speed);
            if (maxForce) {
                this.setLimit(joint, maxForce);
            }
        }
    }

    public setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number) {
        joint.physicsJoint.motorEquation.maxForce = upperLimit;
        joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
    }

but you are right I did get confused and took the meanings in OimoJSPlugin and AmmoJSPlugin to be the same as that in CannonJSPlugin however I now realise they are a different type of limit

Edited my previous post

Ohhh, I think that setLimit is incorrectly coded. (thx for showing me that).

http://schteppe.github.io/cannon.js/docs/classes/HingeConstraint.html

Cannon hingeConstraint (hingeJoint)… shows no limits allowed. So, this setLimit is yet another bubblegum kludge… to try to make CannonPlugin match OimoPlugin, api-wise. Forum question generator. :slight_smile:

My earlier idea of abolishing all the BJS physics classes, and making everyone “go native”… doesn’t sound so far-fetched, does it? heh. When we get-to 10 different physics engines, the plugin/impostor/joint maintenance… will become overwhelming. Hell, we’re overwhelmed at 3 physics engines.

Not so sure

HingeConstraint (

    bodyA bodyB [options] 

)

Defined in src/constraints/HingeConstraint.js:10
Parameters:

    bodyA Body
    bodyB Body
    [options] Object optional
        [pivotA] Vec3 optional

        A point defined locally in bodyA. This defines the offset of axisA.
        [axisA] Vec3 optional

        An axis that bodyA can rotate around, defined locally in bodyA.
        [pivotB] Vec3 optional
        [axisB] Vec3 optional
        [maxForce=1e6] Number optional

Cannon.js has always had maxForce settable but itself has a default of 1e6 and you can set speed and maxForce directly same page under methods

 enableMotor ()

Defined in src/constraints/HingeConstraint.js:73
setMotorMaxForce (

    maxForce 

)

Defined in src/constraints/HingeConstraint.js:95
Parameters:

    maxForce Number

setMotorSpeed (

    speed 

)

Defined in src/constraints/HingeConstraint.js:87
Parameters:

    speed Number

If in the OimoJSPlugin and the AmmoJSPlugin the public method setLimit is setting a limit on angles rather than maxForce of motor then the one in CannonJSPlugin could have been called something like setTorque or setMaxForce but too late now as that would throw backwards compatibility way out and it is noted in the BJS API

setLimit
Find examples in Playground

    setLimit(upperLimit: number, lowerLimit?: number): void

    Set the motor's limits. Attention, this function is plugin specific. Engines won't react 100% the same.
    Parameters
        upperLimit: number

        The upper limit of the motor
        Optional lowerLimit: number

        The lower limit of the motor
    Returns void

1 Like