Question about a particular Newton setup

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Question about a particular Newton setup

Postby misho » Mon Sep 26, 2022 3:41 pm

Hi everyone!

I haven't been on this forum for quite a while, since my project is using Newton and everything is working very well. However, I now have a specific situation and I am looking for a solution:

I need to define a newton PARENT body, with collisions, which will NOT be governed by forces within Newton engine, instead, body's position and orientation will be set from the outside.

To this body, I need to attach (using a "hard" hinge) a normal Newton CHILD body with collisions, governed by external forces from within the Newton engine, for now, mostly gravity.

How do I define the parent body? As a compound collision, or as a static collision?

In my project, I tried both:

when I define parent as a compound collision, the attached child body seems to be "unsteady" (it sometimes starts "shimmering") and follows the parent body, but with a lag, as if it is attached with a rubber band.

when I define parent as a static collision, the attached child body is rock solid in the position, however, it does not follow the parent body whatsoever...

Any thoughts on how to properly set this up?
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Question about a particular Newton setup

Postby misho » Mon Sep 26, 2022 3:56 pm

As an addendum, I'd like to describe the particular situation above in more detail, perhaps the actual application will clarify things:

I am developing an application which will allow attaching various cargo and stores to an airplane within a commercial flight simulator. This flight simulator does not have this functionality, but allows for creation of modules that can read internal data and interact with certain aspects.

The flight simulator provides data for the position and attitude (rotation) of the aircraft, but the aircraft itself is governed by simulator's OWN flight model (physics engine), NOT Newton physics engine. My application reads this data and creates a Newton body at the position and rotation of the aircraft. The position and rotation of the aircraft is imposed on to the position and rotation of the newton body, and the body has no other external influences from Newton.

To this aircraft, I'd like to attach a stores part, for example, a wing mounted fuel tank. When I detach this fuel tank, I want it to fall to the ground using gravitational forces applied through Newton.

What I have so far is, the object is aligned properly to the aircraft while aircraft is stationary, and I have confirmed through debugger that I have a valid "hard" hinge, however, as described in the main post, the hinge behaves either as a rubber band, or it does not seem to exist at all (the child object is not moving along with parent)

For object placement and linking, I am using the code I developed and verified to be functional on a group of linked Newton objects. The difference in this case is that the parent object is not being controlled by Newton (basically, it doesn't have NewtonBodySetForceAndTorqueCallback applied)
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Question about a particular Newton setup

Postby Julio Jerez » Mon Sep 26, 2022 6:36 pm

few years ago, there was a game Ship Simulator, with similar problems. at the time is was hard but possible.

few things first.
Is this a new project? if so them you should try newton 4, it fat easier to get this kind of thing going.
plus it better than 3.14 in every aspect.

the way to solve the problem is nu that hard at all.
basically you have a world that move around,

-you can represent that in newton 4 with a compound collision attached to a dynamics body with zero
mass.
-you can wrap the body in a model so that you get the call update
-in model Update you set the body linear and angular velocity
-this will make so the the contact the proper velocities when the contact joints is calculated.
-in model PostUpdate you integrate the model this will update the physics location.
-maybe some adjustment the to be done in case of some lag between the game engine and the physics, but that's very easy to calibrate.
-that should be it.

if the velocities match the game engine, which is not hard.
there every point on the body will have a velocity which will be transmitted to what even dynamics body is in contact with.

this is difficult in 3.14 because there listener call back does not have the proper callback.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Question about a particular Newton setup

Postby Julio Jerez » Mon Sep 26, 2022 6:46 pm

The flight simulator provides data for the position and attitude (rotation) of the aircraft, but the aircraft itself is governed by simulator's OWN flight model (physics engine),
My application reads this data and creates a Newton body at the position and rotation of the aircraft. The position and rotation of the aircraft is imposed on to the position and rotation of the newton body, and the body has no other external influences from Newton.

Teleporting will not do the trick. what you miss is the velocities,
do you get velocity and angular velocity form the engine?
if not, it that's ok, they can be extracted for line position and angular position using forward difference but will be more accurate if you can just read them form the engine.

To this aircraft, I'd like to attach a stores part, for example, a wing mounted fuel tank. When I detach this fuel tank, I want it to fall to the ground using gravitational forces applied through Newton.

what I explain before, will also work with joint I can add a small demo that attach a joint to a platform and move the platform.
essentially it is not different than what you already did with rocket.
expect that the big body is now integrated manually at the end of the simulation step in the model postupdate.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Question about a particular Newton setup

Postby misho » Tue Sep 27, 2022 8:48 pm

Hi Julio!

Thanks for your reply! Ok, this is a perfect time to switch to 4.0. Let me do that and then we'll go from there!

Cheers,
Misho
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Question about a particular Newton setup

Postby misho » Tue Sep 27, 2022 8:56 pm

Julio Jerez wrote:Teleporting will not do the trick. what you miss is the velocities,
do you get velocity and angular velocity form the engine?
if not, it that's ok, they can be extracted for line position and angular position using forward difference but will be more accurate if you can just read them form the engine.


Hi Julio,

I actually do get the velocities from the sim - but I have to see in what coordinate system they are and if I need to do some conversion. Here is the snippet of the data returned:

STRUCT SURFACE RELATIVE VELOCITY The relative surface velocity. SIMCONNECT_DATA_XYZ structure, feet per second N
STRUCT WORLDVELOCITY The world velocity. SIMCONNECT_DATA_XYZ structure, feet per second N
STRUCT WORLD ROTATION VELOCITY The world rotation velocity. SIMCONNECT_DATA_XYZ structure, radians per second N
STRUCT BODY VELOCITY The object body velocity. SIMCONNECT_DATA_XYZ structure, feet per second N
STRUCT BODY ROTATION VELOCITY The body rotation velocity. SIMCONNECT_DATA_XYZ structure, radians per second N


I think STRUCT WORLDVELOCITY and STRUCT WORLD ROTATION VELOCITY is what I need.

Cheers,
Misho
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Question about a particular Newton setup

Postby Julio Jerez » Tue Sep 27, 2022 11:51 pm

I think STRUCT WORLDVELOCITY and STRUCT WORLD ROTATION VELOCITY is what I need.

yes, do not forget you need to do this with newton 4, so that you can wrapper the static vehicle in a ndModel.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Question about a particular Newton setup

Postby misho » Wed Sep 28, 2022 11:59 am

Thanks Julio!

I am a complete novice with CMake and I have some growing pains. I opened the project (in both VS2017 and 2019) but I am getting the following error:

Code: Select all
Severity   Code   Description   Project   File   Line   Suppression State
Error      CMake Error at C:\newton-dynamics-master\newton-4.00\CMakeLists.txt:142 (if):
  if given arguments:

    "STREQUAL" "ARM" "OR" "STREQUAL" "ARM64"

  Unknown arguments specified   NewtonSDK   C:\newton-dynamics-master\newton-4.00\CMakeLists.txt   142   


Sorry if this was covered already - help?
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Question about a particular Newton setup

Postby Julio Jerez » Wed Sep 28, 2022 2:43 pm

I commented out probably a legacy bug form when I was trying to select ARM in cmake for visual studio. but I do not do that anymore since it has never worked.

I removed it please sync again

one source or error in that In C Make I set so that the output goes to a directory different tat the download. not doing that will generate error

in cmake

-click file->delete cache
-in "Where to build the binaries", select a folder different that the source code
-click configure
-select the compile (VS2017 or VS2019)
-open optional and select (x64 or win32)
-click finish
-click generate

and you should have a visual studio solution that you can use to build the DLL or lib base on your selected options.

in visual studi, build the library
them click install to copy the SDK to you destination folder specified by CMAKE_INSTALL_PREFIX
(bin, headers, debug pdb, etc)

if you leave CMAKE_INSTALL_PREFIX at default, this will be win64sdk or win32sdk for windows.
I assume you are in windows.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Question about a particular Newton setup

Postby misho » Mon Oct 03, 2022 11:55 pm

Ok, I got the CMake going, and followed your instructions - and now I am getting this error:

Image
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Question about a particular Newton setup

Postby JoeJ » Tue Oct 04, 2022 3:23 am

It says the reason is CMake not finding VisualStudio.
Do you have it installed?
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Question about a particular Newton setup

Postby misho » Tue Oct 04, 2022 7:10 pm

JoeJ wrote:It says the reason is CMake not finding VisualStudio.
Do you have it installed?


Aha! Somehow I mixed up VS17 (2022) to be VS2017. I fell for that little gem before :roll:

All good now. I got a clean compile with x64 debug and release:
Code: Select all
========== Rebuild All: 11 succeeded, 0 failed, 1 skipped ==========

Not sure why 1 was skipped, I am guessing either ALL_BUILD or ZERO_CHECK is skipped.

Going forward: I need DOUBLE versions (debug-double and release-double), and I don't see that in the x64 configuration - only "plain" debug and release configurations. How can I build "double"?
[EDIT] Ok I see options for those

I also need both MD and MT versions. How can I build those?
[EDIT] Ok I see options for those as well :D
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Question about a particular Newton setup

Postby Julio Jerez » Tue Oct 04, 2022 10:19 pm

Nice,
Yes you set all those options in cmake.

Also sync, I fix some compiler error in double with the last changes.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Question about a particular Newton setup

Postby misho » Wed Oct 05, 2022 1:15 am

Julio Jerez wrote:Nice,
Yes you set all those options in cmake.

Also sync, I fix some compiler error in double with the last changes.


Great, will do. Just as a general question, 4.00 is using the same API as 3.xx, correct? I theoretically don't have to change any of my code?
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Question about a particular Newton setup

Postby Julio Jerez » Wed Oct 05, 2022 5:18 am

Not newton 4 is cpp.

You will have to do some conversion.

But is not that difficult. Once you get the first few object converted, you will see that 4 is much simpler to use.

But it exposes a lot more functionality than the c interface of 3.14
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 18 guests

cron