[Solved] How to get total linear&angular acceleration?

Post Reply
Tal
Posts: 3
Joined: Thu Apr 24, 2014 4:01 am

[Solved] How to get total linear&angular acceleration?

Post by Tal »

How can I get the total acceleration(linear&angular) I currently do:
acceleration = (total force/torque) / mass + gravity

This works... until collision!
In collision, if I understand correctly, the contact solver push it to the other side, but it doesn't included in the total force/torque!

The reason it's so important to me is network dead reckoning, which require the linear&angular velocity&acceleration.

I suppose I could just monitor the velocity over time while in contact, but isn't there any better solution?
Last edited by Tal on Wed Jan 28, 2015 9:36 am, edited 1 time in total.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: How to get total linear&angular acceleration?

Post by Basroil »

Well, bullet doesn't work with acceleration and forces in the normal sense of the words, instead it's mostly impulses, which means your acceleration is a dirac delta function. You can estimate the acceleration as (v(i)-v(i-1))/(delta t) for some things, but it'll simply be an average acceleration rather than instantaneous one, and will definitely fall apart at collisions (or really any external forces).

Have you considered just using the bullet collision and doing the physics in a more robust way (limited, but robust for what I would assume to be essentially a space simulation) ?
tal500
Posts: 5
Joined: Mon Nov 03, 2014 6:56 pm

Re: How to get total linear&angular acceleration?

Post by tal500 »

Basroil wrote:Well, bullet doesn't work with acceleration and forces in the normal sense of the words, instead it's mostly impulses, which means your acceleration is a dirac delta function. You can estimate the acceleration as (v(i)-v(i-1))/(delta t) for some things, but it'll simply be an average acceleration rather than instantaneous one, and will definitely fall apart at collisions (or really any external forces).
As I said in the topic, I use this fallback (v(i)-v(i-1))/(delta t) for acceleration, but I wish a more precise method.
I understand it's not precise acceleration, but I don't understand why it would fall apart at collision. The acceleration I need is for network dead reckoning.
Any non-host node won't compute a 100% physics with collision, it just use basic space physics.
Basroil wrote:Have you considered just using the bullet collision and doing the physics in a more robust way (limited, but robust for what I would assume to be essentially a space simulation) ?
Actually, I do the opposite. I detect the collision if any, create a static collision plane, re-step simulation and enjoy Bullet contact solver.
On the host node it looks cool, but on the other nodes it pops up and down from the other body in repeated long collision (e.g. ball on the ground).

In the end, you said Bullet movement is impulse based, doesn't it means that there's a global acceleration?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: How to get total linear&angular acceleration?

Post by drleviathan »

I've implemented remote motion extrapolation in a past project (ProjectA: server simulation --> client extrapolation) and am working on another one right now (ProjectB: local client simulation --> server extrapolation for distributed physics simulation across multiple clients).

In ProjectA the server did all the physics and the client would render the results. Parallel to the real simulation the server would also perform the same extrapolation as the client using the very transform+velocities that it had sent. Errors between the full simulation and the naive extrapolation would be used to decide when to send subsequent updates to the client. The types of dynamic objects in the world were typically objects that tumbled along the ground but could also be moving under Actions (vehicles, springs) and could have Scripts that applied force and impulse.

The physics engine we were using did not provide instantaneous acceleration of the object (same as Bullet) so we would have to measure it. This is what we settled on while trying to balance network bandwidth, visual artifacts across disparate content types, and server-side CPU computations:

(1) We measured acceleration AND velocity -- we didn't rely on Object.getVelocity(). This mattered most for tumbling objects that suffered many collisions... we found it better to send their effective velocity as measured over timescales of the network ping time rather than their instantaneous velocity (and definitely NOT their instantaneous acceleration, see item (2)) for smoothest client-side extrapolation. When we sent the instantaneous values as provided by the physics engine we got more overshoot on the receiving end and the server would have to send constant updates because the extrapolation was constantly going wrong fast. For non-tumbling objects the measured velocities were nearly the same as those provided by the engine.

(2) Even though we measured acceleration we never actually sent it over the wire. We found that sending a non-zero acceleration to the client paid off in only one case: ballistic trajectories over long timescales. Otherwise the acceleration was only good over very short timescales and the extrapolation would get ugly within fractions of a second. Nevertheless, we would measure acceleration and then compare it to the expected free-fall acceleration -- if they matched for some timescale then we would send the theoretical free-fall acceleration and my extrapolation prediction would be pretty good until the object landed.

(3) We lerped the rendered position of the object on the client toward its extrapolated position. This smooths out rubber-banding.

(4) For most dynamic motion it doesn't pay to measure or send angular acceleration.

ProjectB uses Bullet and I'm in the middle of tracking down an extrapolation bug for rapidly spinning objects. The unexpected error ranges from about 10% at 15 rotations/sec down to about 1% at 6 or 7 rotations/sec. At the end of yesterday, after eliminating all possibility that I was doing something wrong I looked at the Bullet code and discovered that it doesn't use the exact solution for rotation integration. Instead it approximates the integration using an exponential expansion trick. From what I understand this is done so that the derivatives of rotational dynamics can be accurately computed for Jacobians of constraints. I'm going to have to match this approximation in order to improve my own extrapolation for rapid spin.
tal500
Posts: 5
Joined: Mon Nov 03, 2014 6:56 pm

Re: How to get total linear&angular acceleration?

Post by tal500 »

Thanks for all of your answer, it really was what I need.

However, I do have to ask on Project A, would you tried while in collision to subtract/reduce the collision normal projection from measured velocity, making it semi-horizontal? Was such approach solve the popping problem?
I ask this because we simulate on LAN(zero ping), therefore, we need to measure little steps, but I don't want to create a bottleneck on the network.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: How to get total linear&angular acceleration?

Post by drleviathan »

No, we never tried to subtract collision normal from post-collision velocity in an effort to filter out the collision effect (I think that is what you're asking).

If you're guaranteed to be on LAN then your ping will be low and your bandwidth limits may be quite high. In such a case I would guess that you might be able to get by using the instantaneous velocity of the object rather than measuring a filtered value. You might also be able to send acceleration of gravity -- you can try it but I wouldn't be surprised if that causes more visual problems and bandwidth than it solves. It might depend on your exact content (mostly ballistic object? or lots of sliding/rolling?).

Oh yeah I forgot to mention... When communicating remote simulations across the network ideally you only send updates when necessary. For the dynamic stuff you can send UDP -- if a packet gets lost it isn't a big problem because the simulation will soon be sending another, however when objects settle down you need a 100% reliable send method for getting that final zero-velocity update to the client. If you aren't using UDP and your send protocol is already 100% reliable then you don't need to worry about this problem (instead you need to worry about resends getting stale and blocked pipelines), but if you are using UDP then those final updates must be reliable or you'll be plagued by intermittent bugs.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: How to get total linear&angular acceleration?

Post by Erwin Coumans »

drleviathan wrote: ProjectB uses Bullet and I'm in the middle of tracking down an extrapolation bug for rapidly spinning objects. The unexpected error ranges from about 10% at 15 rotations/sec down to about 1% at 6 or 7 rotations/sec.
Another issue could be coriolis forces, did you enable them? If you enable the explicit integrated coriolis forces, it can add a lot of energy for fast rotating objects. The next version of Bullet will have implicit integrated coriolis forces. If you need this, send me a private message and I'll help you out with that.
Thanks!
Erwin
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: How to get total linear&angular acceleration?

Post by Erwin Coumans »

Tal wrote:How can I get the total acceleration(linear&angular) I currently do:
acceleration = (total force/torque) / mass + gravity

This works... until collision!
In collision, if I understand correctly, the contact solver push it to the other side, but it doesn't included in the total force/torque!

The reason it's so important to me is network dead reckoning, which require the linear&angular velocity&acceleration.

I suppose I could just monitor the velocity over time while in contact, but isn't there any better solution?
You can get the total applied force/torque (impulse over time) by the collision/friction constraint from the contact point information, have you tried that?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: How to get total linear&angular acceleration?

Post by drleviathan »

No, coriolis does not apply in my case. My repro is to throw a small dynamic sphere at a static box such that it hits at about 45 degrees to face normal. Thrown hard enough the ball will go careening off with a spin of about 15 rotations per second. I was computing a naive rotation integration that was not lining up with Bullet... the higher the speed the worse it performed. The culprit was btTransformUtil::integrateTransform() which uses an exponential expansion approximation and caps the effective angular velocity to remain within the range where the approximation is valid.

Today when I duplicated the approximation in my own code the two line up great at all speeds. Problem solved.
Tal
Posts: 3
Joined: Thu Apr 24, 2014 4:01 am

Re: How to get total linear&angular acceleration?

Post by Tal »

drleviathan wrote:No, we never tried to subtract collision normal from post-collision velocity in an effort to filter out the collision effect (I think that is what you're asking).

If you're guaranteed to be on LAN then your ping will be low and your bandwidth limits may be quite high. In such a case I would guess that you might be able to get by using the instantaneous velocity of the object rather than measuring a filtered value. You might also be able to send acceleration of gravity -- you can try it but I wouldn't be surprised if that causes more visual problems and bandwidth than it solves. It might depend on your exact content (mostly ballistic object? or lots of sliding/rolling?).

Oh yeah I forgot to mention... When communicating remote simulations across the network ideally you only send updates when necessary. For the dynamic stuff you can send UDP -- if a packet gets lost it isn't a big problem because the simulation will soon be sending another, however when objects settle down you need a 100% reliable send method for getting that final zero-velocity update to the client. If you aren't using UDP and your send protocol is already 100% reliable then you don't need to worry about this problem (instead you need to worry about resends getting stale and blocked pipelines), but if you are using UDP then those final updates must be reliable or you'll be plagued by intermittent bugs.
Specifically, I throw a grenade in the wide use DIS protocol (publish in UDP with time&state threshold).
I tried my suggestion with removing/reducing normal projection, and it pops a little bit, but at least it doesn't go below the ground/walls. Not perfect, but good enough for my needs.
I should mention I disable smoothing, only dead reckoning is active now. Smoothing must be either disabled or with minimal period.
Erwin Coumans wrote:
Tal wrote:How can I get the total acceleration(linear&angular) I currently do:
acceleration = (total force/torque) / mass + gravity

This works... until collision!
In collision, if I understand correctly, the contact solver push it to the other side, but it doesn't included in the total force/torque!

The reason it's so important to me is network dead reckoning, which require the linear&angular velocity&acceleration.

I suppose I could just monitor the velocity over time while in contact, but isn't there any better solution?
You can get the total applied force/torque (impulse over time) by the collision/friction constraint from the contact point information, have you tried that?
I didn't know this option, it could had helped me, but I prefer measuring velocity after this discussion.

Thanks all!
Post Reply