Autoorientate agent remove roll

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Autoorientate agent remove roll

Postby Lax » Sun Feb 14, 2021 6:41 am

Hi,

I have a physics question^^

I have some waypoints, which the agent (kinematicbody) will traverse.
The velocity equation is correct, as the agent will pass all waypoints. But the orientation of the agent is only correct for y (yaw). I must use NewtonBodySetOmega since its a kinematic body.
But now I have one waypoint which is higher in the air, as the other and I would like to pitch the agent. But as soon as I activate all axes (yaw, pitch, roll), the agent will lean to one side.

Now the question is: How can I just rotate about y and x axis and remove roll?

Here is my code so far:
Code: Select all
Ogre::Quaternion newOrientation = (physicsActiveKinematicComponent->getOrientation() * this->defaultDirection).getRotationTo(this->resultDirection);

Ogre::Vector3 resultVector = Ogre::Vector3::ZERO;

resultVector.x = newOrientation.getPitch().valueDegrees() * 0.1f;
resultVector.y = newOrientation.getYaw().valueDegrees() * 0.1f;
resultVector.z = newOrientation.getRoll().valueDegrees() * 0.1f;
physicsActiveKinematicComponent->setOmegaVelocity(resultVector);

Note: setOmegaVelocity = NewtonBodySetOmega

See also the attached video:
http://www.lukas-kalinowski.com/Homepage/wp-content/uploads/waypoints.mp4

I hope someone can help.

Best Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: Autoorientate agent remove roll

Postby Julio Jerez » Sun Feb 14, 2021 11:32 am

It is not clear to me, even after whaching the video.

For what I can gather you want the equivalent of an up vector for you player. But since it is kinematic it dos not a pet joints. Is that correct?

BTW, have you tried newto 4
I solve many of the issues you are having.

The play capsules and triggers are first classes.
Also ha a new object call model that replaces the okward listener interface.
The bigger difference is that it is native cpp, as oppose to 3.xx which is cpp but with a c interface.
In newton 4 the client app has access to all of the core funtionality of the engine which are very handy to have.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Autoorientate agent remove roll

Postby Lax » Mon Feb 15, 2021 11:42 am

Hi Julio,

It is not clear to me, even after whaching the video.

The issue is, that the agent is leaning to one side (roll) and I'm not able to correct that.

For what I can gather you want the equivalent of an up vector for you player. But since it is kinematic it dos not a pet joints. Is that correct?

Correct.

BTW, have you tried newto 4
I solve many of the issues you are having.

Yes, I'm passively reading the topics about newton 4.0 :D
But I have not enough energy now, to adapt everything from newton 3 to newton 4...

Actually I shy away from it for now :) , because of the tremendous amount of work.

Best Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: Autoorientate agent remove roll

Postby JoshKlint » Thu Feb 25, 2021 4:16 am

This will give you pitch and yaw for a Euler rotation:
Code: Select all
dFloat dist = sqrt(dir.x*dir.x+dir.z*dir.z);
dFloat pitch = -ATan2(dir.y,dist);
dFloat yaw = ATan2(dir.x,dir.z);
JoshKlint
 
Posts: 163
Joined: Sun Dec 10, 2017 8:03 pm

Re: Autoorientate agent remove roll

Postby Julio Jerez » Sat Feb 27, 2021 12:13 pm

This have me a bit confused.
If you are using a kinematic body, you are in control of the motion, they do not get affected by the rest of the scene.
This is what the player controller does.
It takes care of the interation of the kinematic body that represent the player. The transform will by whatever you set it to be.

This is one of the problem that newton 4 try to resolve.
The idea of listeners for making complex physic models seemed a good idea at the time.
But for few years a came to realized that it is just a variation of the old procedural way we did games in the pass. Where each object has an update function that gets called sequentially at the appropriate time and it is that function that is in charge of executing the physics for that model.
This creates all kind of problems, with sequential updated.
Even in a single thread system, the sequential update is alway problematic, because you never quite get the correct reaction between object in the scene. For multicore this only gets worse.
As a result all these listeners system end up reinventing a big chunk of the core functionality with very small nuances.
The final effect is that they get ignored by the user base. Too difficult to used and too susceptible to changes.

With Newto 4 we try to address these issues where these objects are part of the core funtionality, and the all get the same unified solver.
For example the player capsule is just a newton object
That has his methods that the application can respond to and set inputs, but does not do the physics calculation.
So are the vehicles, triggers, and more of the new objects.

We are trying to have a coherent unified solvers, for all these physic model.

We still have a new physics object call Model, which is meant to encapsulate collection of bodies that need general updates handling. But these function only apply inputs that may have dependencies. Fir example a vehicle may have a motor and brakes, but these inputs have dependencies on each other, yet they are represented by different bodies and joints. So the need a class that can group them, this class is the ndModel. Example of this are vehicles, animated ragdoll, triggers, and so on.
But these are very different that listeners, in the sense that they do not implement dedicated solvers the just control imput from the application. They are like the equivalent of a force and torque callback, but for a group of objects.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 26 guests

cron